-
Notifications
You must be signed in to change notification settings - Fork 559
refactor(streaming): introduce END_OF_STREAM sentinel and update handling #1185
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1185 +/- ##
===========================================
+ Coverage 68.57% 68.62% +0.05%
===========================================
Files 161 161
Lines 15943 15966 +23
===========================================
+ Hits 10933 10957 +24
+ Misses 5010 5009 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
|
Adding
|
tgasser-nv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I like using an object to mark the end of stream rather than other values like None or "". Looks a little weird with the is comparisons in the logic rather than == but we need to check memory locations not values. Thanks!
|
…ling - Replaced inconsistent use of `None` and `""` for stream termination in `StreamingHandler` with a dedicated `END_OF_STREAM` sentinel object. - Modified `push_chunk` to convert `None` to `END_OF_STREAM`. - Updated `__anext__` to raise `StopAsyncIteration` only for `END_OF_STREAM` and to return empty strings or dicts with empty/None text as data. - Adjusted `_process` to correctly handle `END_OF_STREAM` for buffering and queueing logic. - Updated `on_llm_end` to use `END_OF_STREAM`. - Revised tests in `test_streaming_handler.py` to reflect these changes, including how empty first tokens are handled and how `__anext__` behaves with various inputs.
fb86618 to
151f6b5
Compare
…ling (#1185) * refactor(streaming): introduce END_OF_STREAM sentinel and update handling - Replaced inconsistent use of `None` and `""` for stream termination in `StreamingHandler` with a dedicated `END_OF_STREAM` sentinel object. - Modified `push_chunk` to convert `None` to `END_OF_STREAM`. - Updated `__anext__` to raise `StopAsyncIteration` only for `END_OF_STREAM` and to return empty strings or dicts with empty/None text as data. - Adjusted `_process` to correctly handle `END_OF_STREAM` for buffering and queueing logic. - Updated `on_llm_end` to use `END_OF_STREAM`. - Revised tests in `test_streaming_handler.py` to reflect these changes, including how empty first tokens are handled and how `__anext__` behaves with various inputs. * coverage to the moon: fix missing generation_info and add more tests
This PR resolves #1184 by introducing END_OF_STREAM sentinel and update streaming handling.
Replaced inconsistent use of
Noneand""for stream terminationin
StreamingHandlerwith a dedicatedEND_OF_STREAMsentinel object.Modified
push_chunkto convertNonetoEND_OF_STREAM.Updated
__anext__to raiseStopAsyncIterationonly forEND_OF_STREAMand to return empty strings or dicts with empty/None text as data.
Adjusted
_processto correctly handleEND_OF_STREAMfor bufferingand queueing logic.
Updated
on_llm_endto useEND_OF_STREAM.Revised tests in
test_streaming_handler.pyto reflect these changes,including how empty first tokens are handled and how
__anext__behaveswith various inputs.
requires:
fix(tests): ensure proper asyncio task cleanup in test_streaming_handler.py #1182
test(streaming): add extensive tests for StreamingHandler to enhance coverage #1183