Repository navigation
fix: ignore empty SSE data frames in OpenAI-compatible and Google providers - #762
Open
harshitgavita-07 wants to merge 3 commits into
Open
harshitgavita-07 wants to merge 3 commits into
harshitgavita-07 wants to merge 3 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
An SSE frame with an empty payload (
data:followed by nothing) is valid and is sent as a keep-alive by some proxies. #680 made the Anthropic parser ignore these frames. The OpenAI-compatible and Google parsers still return""for them,_loads_object("")fails, and the stream ends with a fatal "Provider returned invalid JSON chunk" (or "Google returned an invalid JSON stream chunk") error even though the rest of the response is fine. This is the same failure reported for the Anthropic path in #679.Changes
src/tau_ai/openai_compatible.pyandsrc/tau_ai/google.py:_parse_sse_linereturnsNonewhen the payload afterdata:is empty, same asanthropic.py. The OpenAI-compatible change covers both the chat completions and Responses paths since they share the helper.tests/test_sse_empty_data_frames.py: streams a response with an emptydata:frame in the middle through the OpenAI-compatible, Google and Mistral providers and expects a normal completed message.No behavior change for non-empty frames,
[DONE], or other lines.Tests
mainthe OpenAI-compatible and Google cases fail with the invalid JSON chunk error; the Mistral case already passes and is included as a guard. All 3 pass with the change.-k "tau_ai or provider or sse or openai or google or chat_channels or prompt_caching or multimodal").ruff check,ruff format --checkandmypypass.pytestrun was stopped at about 76% for time; the remaining tests were not run for this PR.