You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: handle whitespace-only content in structured output parsing
This commit fixes an issue where the API client would crash with JSON parsing
errors when a model returns whitespace-only content (spaces, newlines, etc.)
during structured output parsing.
Changes:
- Add a check in _parse_content to detect and gracefully handle empty or
whitespace-only content before attempting JSON parsing
- Improve streaming parser to skip JSON parsing for whitespace-only content
- Update maybe_parse_content to catch and log parsing errors instead of
letting them propagate
- Add similar checks for tool argument parsing
This fixes cases where users were getting "EOF while parsing a value" errors
when using client.beta.chat.completions.parse with models that occasionally
return only whitespace instead of structured JSON.
With this change, parsing whitespace-only content now returns None for the
parsed field instead of raising an exception, with an appropriate warning
logged.
0 commit comments