diff --git a/.changeset/yellow-berries-play.md b/.changeset/yellow-berries-play.md new file mode 100644 index 000000000..2f94493c3 --- /dev/null +++ b/.changeset/yellow-berries-play.md @@ -0,0 +1,5 @@ +--- +"livekit-plugins-openai": patch +--- + +skip processing of choice.delta when it is None diff --git a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py index e531932db..8dcb67a65 100644 --- a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py +++ b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py @@ -349,6 +349,11 @@ async def __anext__(self): def _parse_choice(self, choice: Choice) -> llm.ChatChunk | None: delta = choice.delta + # https://github.com/livekit/agents/issues/688 + # the delta can be None when using Azure OpenAI using content filtering + if delta is None: + return None + if delta.tool_calls: # check if we have functions to calls for tool in delta.tool_calls: