Skip to content

Fix incorrectly parsing event fieldnames in yielding responses #2363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

idantene
Copy link

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

Changes being requested

Remove requirement for event names to end with a dot if they're "response" or "transcript", and extend the notion of a "valid" event name to be either missing, response, transcript, or an extended of either (response. and transcript.), with separate logic to reduce code duplicity.

Additional context & links

When parsing the SSE in a streaming request, the captured event (if any) is parsed to ensure it is valid/matches the expected event.
It seems there are three options for a "valid event" - a missing one, and either a response or transcript one. In the current implementation, the latter are forced to have a trailing dot (supposedly to offer more granular information on the event type, such as response.foo), but this is out of scope for SSEs.
In fact, a server yielding event:response gets the wrong path and ends up with a response chunk of process_data(data={"data": data, "event": sse.event}, cast_to=cast_to, response=response), which is then incorrectly parsed on the client side.

@idantene idantene requested a review from a team as a code owner May 19, 2025 11:27
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.

1 participant