livekit-plugins-anthropic 0.2.2__py3-none-any.whl → 0.2.3__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.
@@ -111,6 +111,7 @@ class LLM(llm.LLM):
111
111
  latest_system_message = _latest_system_message(chat_ctx)
112
112
  anthropic_ctx = _build_anthropic_context(chat_ctx.messages, id(self))
113
113
  collaped_anthropic_ctx = _merge_messages(anthropic_ctx)
114
+
114
115
  stream = self._client.messages.create(
115
116
  max_tokens=opts.get("max_tokens", 1024),
116
117
  system=latest_system_message,
@@ -155,10 +156,10 @@ class LLMStream(llm.LLMStream):
155
156
  self._output_tokens = 0
156
157
 
157
158
  async def _main_task(self) -> None:
158
- if not self._anthropic_stream:
159
- self._anthropic_stream = await self._awaitable_anthropic_stream
160
-
161
159
  try:
160
+ if not self._anthropic_stream:
161
+ self._anthropic_stream = await self._awaitable_anthropic_stream
162
+
162
163
  async with self._anthropic_stream as stream:
163
164
  async for event in stream:
164
165
  chat_chunk = self._parse_event(event)
@@ -325,7 +326,7 @@ def _build_anthropic_message(
325
326
  a_content = a_msg["content"]
326
327
 
327
328
  # add content if provided
328
- if isinstance(msg.content, str):
329
+ if isinstance(msg.content, str) and msg.content:
329
330
  a_msg["content"].append(
330
331
  anthropic.types.TextBlock(
331
332
  text=msg.content,
@@ -334,7 +335,7 @@ def _build_anthropic_message(
334
335
  )
335
336
  elif isinstance(msg.content, list):
336
337
  for cnt in msg.content:
337
- if isinstance(cnt, str):
338
+ if isinstance(cnt, str) and cnt:
338
339
  content: anthropic.types.TextBlock = anthropic.types.TextBlock(
339
340
  text=cnt,
340
341
  type="text",
@@ -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.2"
15
+ __version__ = "0.2.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: livekit-plugins-anthropic
3
- Version: 0.2.2
3
+ Version: 0.2.3
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
@@ -0,0 +1,10 @@
1
+ livekit/plugins/anthropic/__init__.py,sha256=1WCyNEaR6qBsX54qJQM0SeY-QHIucww16PLXcSnMqRo,1175
2
+ livekit/plugins/anthropic/llm.py,sha256=6rNtLJOfvB72gmmkFk8qN-N8fKnm-vhflpiBKTU_gqM,18921
3
+ livekit/plugins/anthropic/log.py,sha256=fG1pYSY88AnT738gZrmzF9FO4l4BdGENj3VKHMQB3Yo,72
4
+ livekit/plugins/anthropic/models.py,sha256=AVEhrEtKfWxsd-R03u7R74hcKjJq4oDVSTukvoPQGb0,179
5
+ livekit/plugins/anthropic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ livekit/plugins/anthropic/version.py,sha256=A5eBQ2sWvNCBt2aefaSvtvK0XRwtGa-rgF4340O8cjk,600
7
+ livekit_plugins_anthropic-0.2.3.dist-info/METADATA,sha256=dttEt-3lS_LDVl0XZkgnINXr560oPngIyXyzeJvih6c,1265
8
+ livekit_plugins_anthropic-0.2.3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
9
+ livekit_plugins_anthropic-0.2.3.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
+ livekit_plugins_anthropic-0.2.3.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- livekit/plugins/anthropic/__init__.py,sha256=1WCyNEaR6qBsX54qJQM0SeY-QHIucww16PLXcSnMqRo,1175
2
- livekit/plugins/anthropic/llm.py,sha256=mcTBYT3_ZVAWx9ZnCUj_96NM44dF6SF1R0ZLMUQt79Y,18888
3
- livekit/plugins/anthropic/log.py,sha256=fG1pYSY88AnT738gZrmzF9FO4l4BdGENj3VKHMQB3Yo,72
4
- livekit/plugins/anthropic/models.py,sha256=AVEhrEtKfWxsd-R03u7R74hcKjJq4oDVSTukvoPQGb0,179
5
- livekit/plugins/anthropic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- livekit/plugins/anthropic/version.py,sha256=vseqf_ctDD3TBGPSArXT_dFZvNHkuJc4_8GgQSvrKrM,600
7
- livekit_plugins_anthropic-0.2.2.dist-info/METADATA,sha256=KWqm8V_Ooo_sGKJ2JNAVrfOCu1sfuSLLBHkOC4tZHfQ,1265
8
- livekit_plugins_anthropic-0.2.2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
9
- livekit_plugins_anthropic-0.2.2.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
- livekit_plugins_anthropic-0.2.2.dist-info/RECORD,,