Skip to content

Commit 08ab62b

Browse files
rjoshistainless-app[bot]
authored andcommitted
fix(structured outputs): avoid parsing empty empty content (#2023)
Fixing #1763 where parsing often fails when content is empty string instead of None.
1 parent bf5bebb commit 08ab62b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/openai/lib/_parsing/_completions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def maybe_parse_content(
157157
response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven,
158158
message: ChatCompletionMessage | ParsedChatCompletionMessage[object],
159159
) -> ResponseFormatT | None:
160-
if has_rich_response_format(response_format) and message.content is not None and not message.refusal:
160+
if has_rich_response_format(response_format) and message.content and not message.refusal:
161161
return _parse_content(response_format, message.content)
162162

163163
return None

0 commit comments

Comments
 (0)