Skip to content
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

Fix Stream parser expects additional space after colon "data:" #502

Closed

Conversation

AshiishKarhade
Copy link

This commit updates the SSE parser to handle cases where there is an optional space after the "data:" prefix. Described in detail here - #498

To address this, I modified the parser code to use the startswith method and then strip any leading or trailing whitespaces from the line. This ensures that the parser can handle both cases where there is a space after "data:" and where there isn't. The modified code now correctly decodes the line as UTF-8 and returns the parsed data.

This change improves compatibility with different SSE implementations and ensures that the parser functions correctly in various scenarios. It provides a more flexible solution that aligns with the SSE specification and accommodates libraries like springframework that omit the space after "data:".

Fixes #498

…#498

This commit updates the SSE parser to handle cases where there is an optional space after the "data:" prefix. Described in detail here - openai#498

To address this, I modified the parser code to use the `startswith` method and then strip any leading or trailing whitespaces from the line. This ensures that the parser can handle both cases where there is a space after "data:" and where there isn't. The modified code now correctly decodes the line as UTF-8 and returns the parsed data. 

This change improves compatibility with different SSE implementations and ensures that the parser functions correctly in various scenarios. It provides a more flexible solution that aligns with the SSE specification and accommodates libraries like springframework that omit the space after "data:".

Fixes openai#498
@AshiishKarhade AshiishKarhade changed the title Fix Stream parser expects additional space after colon "data:" #498 Fix Stream parser expects additional space after colon "data:" Jun 25, 2023
@michaelfeil
Copy link
Contributor

#559 was merged, this can be closed.

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.

SSE Stream parser expects additional space after colon "data:"
2 participants