Update output's content.text to be nullable.#3105
Update output's content.text to be nullable.#3105grace-young wants to merge 1 commit intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13d8b3e256
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| """The annotations of the text output.""" | ||
|
|
||
| text: str | ||
| text: Optional[str]: |
There was a problem hiding this comment.
Remove stray colon from
text type annotation
The field declaration text: Optional[str]: is invalid Python syntax, so importing this module raises a SyntaxError before runtime logic can execute. Any code path that imports openai.types.responses.response_output_text (including from openai.types.responses.response import Response) will fail immediately, making the responses types unusable.
Useful? React with 👍 / 👎.
| for content in output.content: | ||
| if content.type == "output_text": | ||
| texts.append(content.text) | ||
| if content.text != None: |
There was a problem hiding this comment.
Keep type guard before reading
content.text
This change removes the content.type == "output_text" check and directly accesses content.text, but output.content can include ResponseOutputRefusal entries that do not define a text attribute. In responses containing refusal content, accessing response.output_text will now raise AttributeError instead of returning aggregated text.
Useful? React with 👍 / 👎.
Changes being requested
Ignore output_text that is None, and make text Optional.
Additional context & links
#3063