Skip to content

Commit

Permalink
fix(structured outputs): avoid parsing empty empty content (#2023)
Browse files Browse the repository at this point in the history
Fixing #1763 where parsing often fails when content is empty string instead of None.
  • Loading branch information
rjoshi authored Jan 16, 2025
1 parent 0a9a0f5 commit 6d3513c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/openai/lib/_parsing/_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def maybe_parse_content(
response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven,
message: ChatCompletionMessage | ParsedChatCompletionMessage[object],
) -> ResponseFormatT | None:
if has_rich_response_format(response_format) and message.content is not None and not message.refusal:
if has_rich_response_format(response_format) and message.content and not message.refusal:
return _parse_content(response_format, message.content)

return None
Expand Down

0 comments on commit 6d3513c

Please sign in to comment.