livekit-plugins-anthropic 0.2.11__py3-none-any.whl → 0.2.13__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.
@@ -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
- if parallel_tool_calls is not None and parallel_tool_calls is False:
185
- anthropic_tool_choice["disable_parallel_tool_use"] = True
186
- opts["tool_choice"] = anthropic_tool_choice
187
-
188
- latest_system_message: anthropic.types.TextBlockParam = _latest_system_message(
189
- chat_ctx, caching=self._opts.caching
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
- system_text_block = anthropic.types.TextBlockParam(
385
- text=latest_system_str,
386
- type="text",
387
- cache_control=CACHE_CONTROL_EPHEMERAL if caching == "ephemeral" else None,
388
- )
389
- return system_text_block
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(
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "0.2.11"
15
+ __version__ = "0.2.13"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: livekit-plugins-anthropic
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Summary: Agent Framework plugin for services from Anthropic
5
5
  Home-page: https://github.com/livekit/agents
6
6
  License: Apache-2.0
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Requires-Python: >=3.9.0
21
21
  Description-Content-Type: text/markdown
22
- Requires-Dist: livekit-agents>=0.12.3
22
+ Requires-Dist: livekit-agents<1.0.0,>=0.12.16
23
23
  Requires-Dist: anthropic>=0.34
24
24
  Dynamic: classifier
25
25
  Dynamic: description
@@ -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=DC7zV-PQt-EaJK0DNm_kMuF_1mO7oPlaMVvGD0eDMwA,601
7
+ livekit_plugins_anthropic-0.2.13.dist-info/METADATA,sha256=M4I1liRz8JcHrEGBAIKqKGzm49s9_6BNLHCzVTFxzsk,1489
8
+ livekit_plugins_anthropic-0.2.13.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
9
+ livekit_plugins_anthropic-0.2.13.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
+ livekit_plugins_anthropic-0.2.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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,,