Skip to content

Commit 56ca463

Browse files
rjoshistainless-app[bot]
authored andcommitted
fix(structured outputs): avoid parsing empty empty content (#2023)
Fixing openai/openai-python#1763 where parsing often fails when content is empty string instead of None.
1 parent 519ed62 commit 56ca463

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/openai/lib/_parsing/_completions.py

Lines changed: 1 addition & 1 deletion
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)