Skip to content

Commit 445b739

Browse files
committed
feat(aws-llm): replace raise with logging
1 parent 53e5076 commit 445b739

File tree

2 files changed

+25
-25
lines changed
  • livekit-agents/livekit/agents/llm/_provider_format
  • livekit-plugins/livekit-plugins-aws/livekit/plugins/aws

2 files changed

+25
-25
lines changed

livekit-agents/livekit/agents/llm/_provider_format/aws.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from dataclasses import dataclass
66

77
from livekit.agents import llm
8+
from livekit.agents.log import logger
89

910
from .utils import group_tool_calls
1011

@@ -34,7 +35,8 @@ def to_chat_ctx(
3435
elif msg.type == "function_call_output":
3536
role = "user"
3637
else:
37-
raise ValueError(f"Unknown message type: {msg.type!r}")
38+
logger.warning("Skipping unknown message type %r", msg.type)
39+
continue
3840

3941
# if the effective role changed, finalize the previous turn.
4042
if role != current_role:

livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/llm.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -321,28 +321,26 @@ def _parse_chunk(
321321
),
322322
)
323323
elif "contentBlockStop" in chunk:
324-
if self._tool_call_id is None:
325-
logger.warning("aws bedrock llm: no tool call id in the response")
326-
return None
327-
if self._fnc_name is None:
328-
logger.warning("aws bedrock llm: no function name in the response")
329-
return None
330-
if self._fnc_arg_parts is None:
331-
logger.warning("aws bedrock llm: no function arguments in the response")
332-
return None
333-
chat_chunk = llm.ChatChunk(
334-
id=request_id,
335-
delta=llm.ChoiceDelta(
336-
role="assistant",
337-
tool_calls=[
338-
FunctionToolCall(
339-
arguments="".join(self._fnc_arg_parts),
340-
name=self._fnc_name,
341-
call_id=self._tool_call_id,
342-
),
343-
],
344-
),
345-
)
346-
self._tool_call_id = self._fnc_name = self._fnc_arg_parts = None
347-
return chat_chunk
324+
if self._tool_call_id:
325+
if self._fnc_name is None:
326+
logger.warning("aws bedrock llm: no function name in the response")
327+
return None
328+
if self._fnc_arg_parts is None:
329+
logger.warning("aws bedrock llm: no function arguments in the response")
330+
return None
331+
chat_chunk = llm.ChatChunk(
332+
id=request_id,
333+
delta=llm.ChoiceDelta(
334+
role="assistant",
335+
tool_calls=[
336+
FunctionToolCall(
337+
arguments="".join(self._fnc_arg_parts),
338+
name=self._fnc_name,
339+
call_id=self._tool_call_id,
340+
),
341+
],
342+
),
343+
)
344+
self._tool_call_id = self._fnc_name = self._fnc_arg_parts = None
345+
return chat_chunk
348346
return None

0 commit comments

Comments
 (0)