Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the OpenAI HTTP streaming implementation to iterate over decoded text lines again (instead of splitting raw byte chunks), while still skipping blank newline separators, to avoid JSON parsing failures when a single SSE line is split across multiple network reads.
Changes:
- Switch
_aiter_lines()fromResponse.aiter_bytes()+split(b"\n\n")toResponse.aiter_lines() - Preserve behavior of skipping blank/whitespace-only lines during streaming
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jaredoconnell
left a comment
There was a problem hiding this comment.
Looks fine. Are there any potential problems with skipping blank lines?
dbutenhof
left a comment
There was a problem hiding this comment.
Let's get this in and freeze v0.6.
There shouldn't be. Its mainly to account for the fact that every data portion ends with It does not seem like any of the OpenAI endpoints use this feature though since all of the data is on one line. |
Signed-off-by: Samuel Monson <smonson@redhat.com>
e097472 to
155efd1
Compare
Summary
Partially reverts #663 to iterating over lines, but keeps the skipping of blank newlines.
Details
#663 switched the HTTP backend to iterating over byte strings. The problem is that is did not handle the case where a line was split over multiple iterations.
Test Plan
Run a benchmark with known errored request rate (preferably 0) and ensure that there are no failed requests due to
orjson.JSONDecodeError: unexpected end of data.Use of AI
## WRITTEN BY AI ##)