Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pydantic_ai_slim/pydantic_ai/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:

# Handle the text part of the response
content = choice.delta.content
if content is not None:
if (delta := choice.delta) is not None and (content := delta.content) is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will already have failed on the previous line won't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are completely right. Sorry about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to continue to the next chunk when choice.delta is None.

maybe_event = self._parts_manager.handle_text_delta(
vendor_part_id='content',
content=content,
Expand Down
Loading