Open
Conversation
zeiler
commented
Mar 14, 2026
| """Create chat completions with retry logic.""" | ||
| return self.client.chat.completions.create(**kwargs) | ||
|
|
||
| def _raw_sse_stream(self, completion_args: Dict[str, Any]) -> Iterator[str]: |
Member
Author
There was a problem hiding this comment.
@luv-bansal do you think this needs a retry decorator too?
Minimum allowed line rate is |
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.
This pull request introduces optimizations to streaming and serialization logic for model outputs, focusing on reducing overhead and improving performance in common cases. The main improvements are fast-paths for single-output streaming, efficient status handling, and bypassing unnecessary parsing in OpenAI-compatible streaming.
Performance optimizations for streaming and serialization:
generate_wrapper, precomputing the serializer and signature info to avoid repeated overhead in the serialization process.runner_item_generate, including a fast-path for single output with SUCCESS status and improved handling for batch/multi-output cases. [1] [2]OpenAI-compatible streaming improvements:
_raw_sse_streaminopenai_class.pyto stream raw SSE JSON strings, bypassing Pydantic parsing and reducing per-chunk overhead.openai_stream_transportto use the new_raw_sse_streammethod for chat completions, further improving streaming performance by skipping unnecessary parsing.General codebase updates:
serializer_from_signatureinmodel_class.pyto support the new fast serialization logic.jsonas_jsoninopenai_class.pyfor efficient JSON handling in streaming.