fix: handle null output_text content#3113
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3518e6a86d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| text: str | ||
| """The text output from the model.""" | ||
| text: Optional[str] = None |
There was a problem hiding this comment.
Guard streamed text concatenation after making text nullable
Changing ResponseOutputText.text to nullable allows response.content_part.added events to carry text: null, but ResponseStreamState.accumulate_event still does content.text += event.delta (src/openai/lib/streaming/responses/_responses.py:349-355). In streams where a content part starts with null and later receives response.output_text.delta, this will raise a TypeError and terminate the stream; initializing null text to "" (or branching before concatenation) avoids the crash.
Useful? React with 👍 / 👎.
Fixes #3063
Summary
ResponseOutputText.textto be null in typed modelsresponse.output_textTesting
python -m pytest -o addopts="" tests/lib/responses/test_responses.py -q