livekit-plugins-anthropic 0.2.11__py3-none-any.whl → 0.2.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- livekit/plugins/anthropic/llm.py +23 -15
- livekit/plugins/anthropic/version.py +1 -1
- {livekit_plugins_anthropic-0.2.11.dist-info → livekit_plugins_anthropic-0.2.12.dist-info}/METADATA +1 -1
- livekit_plugins_anthropic-0.2.12.dist-info/RECORD +10 -0
- {livekit_plugins_anthropic-0.2.11.dist-info → livekit_plugins_anthropic-0.2.12.dist-info}/WHEEL +1 -1
- livekit_plugins_anthropic-0.2.11.dist-info/RECORD +0 -10
- {livekit_plugins_anthropic-0.2.11.dist-info → livekit_plugins_anthropic-0.2.12.dist-info}/top_level.txt +0 -0
livekit/plugins/anthropic/llm.py
CHANGED
@@ -171,7 +171,7 @@ class LLM(llm.LLM):
|
|
171
171
|
|
172
172
|
opts["tools"] = fncs_desc
|
173
173
|
if tool_choice is not None:
|
174
|
-
anthropic_tool_choice: dict[str, Any] = {"type": "auto"}
|
174
|
+
anthropic_tool_choice: dict[str, Any] | None = {"type": "auto"}
|
175
175
|
if isinstance(tool_choice, ToolChoice):
|
176
176
|
if tool_choice.type == "function":
|
177
177
|
anthropic_tool_choice = {
|
@@ -181,13 +181,20 @@ class LLM(llm.LLM):
|
|
181
181
|
elif isinstance(tool_choice, str):
|
182
182
|
if tool_choice == "required":
|
183
183
|
anthropic_tool_choice = {"type": "any"}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
184
|
+
elif tool_choice == "none":
|
185
|
+
opts["tools"] = []
|
186
|
+
anthropic_tool_choice = None
|
187
|
+
if anthropic_tool_choice is not None:
|
188
|
+
if parallel_tool_calls is False:
|
189
|
+
anthropic_tool_choice["disable_parallel_tool_use"] = True
|
190
|
+
opts["tool_choice"] = anthropic_tool_choice
|
191
|
+
|
192
|
+
latest_system_message: anthropic.types.TextBlockParam | None = (
|
193
|
+
_latest_system_message(chat_ctx, caching=self._opts.caching)
|
190
194
|
)
|
195
|
+
if latest_system_message:
|
196
|
+
opts["system"] = [latest_system_message]
|
197
|
+
|
191
198
|
anthropic_ctx = _build_anthropic_context(
|
192
199
|
chat_ctx.messages,
|
193
200
|
id(self),
|
@@ -197,7 +204,6 @@ class LLM(llm.LLM):
|
|
197
204
|
|
198
205
|
stream = self._client.messages.create(
|
199
206
|
max_tokens=opts.get("max_tokens", 1024),
|
200
|
-
system=[latest_system_message],
|
201
207
|
messages=collaped_anthropic_ctx,
|
202
208
|
model=self._opts.model,
|
203
209
|
temperature=temperature or anthropic.NOT_GIVEN,
|
@@ -366,7 +372,7 @@ class LLMStream(llm.LLMStream):
|
|
366
372
|
|
367
373
|
def _latest_system_message(
|
368
374
|
chat_ctx: llm.ChatContext, caching: Literal["ephemeral"] | None = None
|
369
|
-
) -> anthropic.types.TextBlockParam:
|
375
|
+
) -> anthropic.types.TextBlockParam | None:
|
370
376
|
latest_system_message: llm.ChatMessage | None = None
|
371
377
|
for m in chat_ctx.messages:
|
372
378
|
if m.role == "system":
|
@@ -381,12 +387,14 @@ def _latest_system_message(
|
|
381
387
|
latest_system_str = " ".join(
|
382
388
|
[c for c in latest_system_message.content if isinstance(c, str)]
|
383
389
|
)
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
+
if latest_system_str:
|
391
|
+
system_text_block = anthropic.types.TextBlockParam(
|
392
|
+
text=latest_system_str,
|
393
|
+
type="text",
|
394
|
+
cache_control=CACHE_CONTROL_EPHEMERAL if caching == "ephemeral" else None,
|
395
|
+
)
|
396
|
+
return system_text_block
|
397
|
+
return None
|
390
398
|
|
391
399
|
|
392
400
|
def _merge_messages(
|
@@ -0,0 +1,10 @@
|
|
1
|
+
livekit/plugins/anthropic/__init__.py,sha256=1WCyNEaR6qBsX54qJQM0SeY-QHIucww16PLXcSnMqRo,1175
|
2
|
+
livekit/plugins/anthropic/llm.py,sha256=dtIA1qWxMPWFxG4QbAeQ-xztmJZxRxBzYxqLFty59dA,23374
|
3
|
+
livekit/plugins/anthropic/log.py,sha256=fG1pYSY88AnT738gZrmzF9FO4l4BdGENj3VKHMQB3Yo,72
|
4
|
+
livekit/plugins/anthropic/models.py,sha256=wyTr2nl6SL4ylN6s4mHJcqtmgV2mjJysZo89FknWdhI,213
|
5
|
+
livekit/plugins/anthropic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
livekit/plugins/anthropic/version.py,sha256=L9v54yZpBzq0Hizz-thIscGPt87Ydvf01GZclaT0Yuw,601
|
7
|
+
livekit_plugins_anthropic-0.2.12.dist-info/METADATA,sha256=ZVjHKrbkK6a81xnO_oH-6-8gBrX_R_esQqJb15s_lhI,1481
|
8
|
+
livekit_plugins_anthropic-0.2.12.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
9
|
+
livekit_plugins_anthropic-0.2.12.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
+
livekit_plugins_anthropic-0.2.12.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
livekit/plugins/anthropic/__init__.py,sha256=1WCyNEaR6qBsX54qJQM0SeY-QHIucww16PLXcSnMqRo,1175
|
2
|
-
livekit/plugins/anthropic/llm.py,sha256=JgY7x1DlngrQNsXss_Vc0VMNge4jza3D3-tde7WtNwU,23071
|
3
|
-
livekit/plugins/anthropic/log.py,sha256=fG1pYSY88AnT738gZrmzF9FO4l4BdGENj3VKHMQB3Yo,72
|
4
|
-
livekit/plugins/anthropic/models.py,sha256=wyTr2nl6SL4ylN6s4mHJcqtmgV2mjJysZo89FknWdhI,213
|
5
|
-
livekit/plugins/anthropic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
livekit/plugins/anthropic/version.py,sha256=tQf5iSQsEO0Vr1TimFhAqVDGkoj_Na4Qfj_agnoO3NQ,601
|
7
|
-
livekit_plugins_anthropic-0.2.11.dist-info/METADATA,sha256=IY-JVBfw4xdAXlZZfIYqcOqBrBKAPGDUBP34cItva60,1481
|
8
|
-
livekit_plugins_anthropic-0.2.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
9
|
-
livekit_plugins_anthropic-0.2.11.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
-
livekit_plugins_anthropic-0.2.11.dist-info/RECORD,,
|
File without changes
|