Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 246bc5b

Browse filesBrowse files
fix(parsing): handle whitespace only strings (#2007)
* fix: add a check to handle empty or newline-only strings before calling `from_json` * style: adjust comment format for better readability Co-authored-by: Robert Craigie <robert@craigie.dev> --------- Co-authored-by: SenorSpes <138108569+senorNox@users.noreply.github.com> Co-authored-by: Robert Craigie <robert@craigie.dev>
1 parent fad098f commit 246bc5b
Copy full SHA for 246bc5b

File tree

Expand file treeCollapse file tree

1 file changed

+2
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-0
lines changed

‎src/openai/lib/streaming/chat/_completions.py

Copy file name to clipboardExpand all lines: src/openai/lib/streaming/chat/_completions.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ def _accumulate_chunk(self, chunk: ChatCompletionChunk) -> ParsedChatCompletionS
438438
choice_snapshot.message.content
439439
and not choice_snapshot.message.refusal
440440
and is_given(self._rich_response_format)
441+
# partial parsing fails on white-space
442+
and choice_snapshot.message.content.strip()
441443
):
442444
choice_snapshot.message.parsed = from_json(
443445
bytes(choice_snapshot.message.content, "utf-8"),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.