Skip to content

Commit

Permalink
Fix bug related to Azure OpenAI streaming response
Browse files Browse the repository at this point in the history
  • Loading branch information
uinfante committed Feb 15, 2025
1 parent ef80e23 commit cfedf07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pydantic_ai_slim/pydantic_ai/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,11 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
continue

# Handle the text part of the response
content = choice.delta.content
if content is not None:
yield self._parts_manager.handle_text_delta(vendor_part_id='content', content=content)
if (
(delta := choice.delta) is not None
and (content := delta.content) is not None
):
yield self._parts_manager.handle_text_delta(vendor_part_id="content", content=content)

for dtc in choice.delta.tool_calls or []:
maybe_event = self._parts_manager.handle_tool_call_delta(
Expand Down

0 comments on commit cfedf07

Please sign in to comment.