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 and stainless-app[bot] committed Jan 17, 2025
1 parent bf5bebb commit 08ab62b
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 08ab62b

Please sign in to comment.