Skip to content

Commit

Permalink
skip processing of choice.delta when it is None (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Sep 4, 2024
1 parent 179717a commit 2f5e7e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-berries-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-plugins-openai": patch
---

skip processing of choice.delta when it is None
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2f5e7e6

Please sign in to comment.