Skip to content

Conversation

@LuminaX-alt
Copy link
Owner

…espace in JSON chunks

Fix EOFError in structured output streaming due to leading whitespace

This commit resolves issue openai#2082 where structured output streaming would fail with an EOFError or JSONDecodeError when responses contained leading whitespace or newlines before the JSON object.

Changes:

  • Added safe_json_parse() to strip leading whitespace/newlines before json.loads().
  • Updated streaming parsers to use safe_json_parse() for robust decoding.

Fixes: openai#2082

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Additional context & links

…espace in JSON chunks

Fix EOFError in structured output streaming due to leading whitespace

This commit resolves issue openai#2082 where structured output streaming would fail
with an EOFError or JSONDecodeError when responses contained leading whitespace
or newlines before the JSON object. 

Changes:
- Added safe_json_parse() to strip leading whitespace/newlines before json.loads().
- Updated streaming parsers to use safe_json_parse() for robust decoding.

Fixes: openai#2082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EOF error in GPT structured output streaming due to unexpected leading whitespace in JSON schema

2 participants