fix: improve condition check for streaming token callback in handle_on_chain_stream#11362
fix: improve condition check for streaming token callback in handle_on_chain_stream#11362ricofurtado merged 5 commits intomainfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughA condition check in the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #11362 +/- ##
==========================================
- Coverage 35.26% 35.23% -0.03%
==========================================
Files 1521 1521
Lines 72960 72941 -19
Branches 10938 10932 -6
==========================================
- Hits 25729 25704 -25
- Misses 45835 45842 +7
+ Partials 1396 1395 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Adam-Aghili
left a comment
There was a problem hiding this comment.
Do we want to allow whitespace only stings, such as " "?
|
Yes, we want. That was the original issue; the chunks outputs were different from the text outputs. e.g. "PISA 2022" was becoming "PISA2022" when accumulating the chunks. |
| # Note: we should expect the callback, but we keep it optional for backwards compatibility | ||
| # as of v1.6.5 | ||
| if output_text and output_text.strip() and send_token_callback and message_id: | ||
| if output_text is not None and output_text != "" and send_token_callback and message_id: |
There was a problem hiding this comment.
| if output_text is not None and output_text != "" and send_token_callback and message_id: | |
| if output_text is not None and output_text.lstrip() and output_text.rstrip() and output_text != "" and send_token_callback and message_id: |
Based on the tests failing I think it would be safe to use either lstrip or rstrip to preserve the previous intent of ignoring " " but allowing "PISA 2022".
We could use both but that seems unnecessary
There was a problem hiding this comment.
We want to allow " " spaces. So using lstrip() or rstrip() will return falsy, defeating the purpose.
There was a problem hiding this comment.
if you want to allow " " that is fine but the UTs need to be updated.
There was a problem hiding this comment.
What happened to this PR? Was it abandoned? I find the issue I resported pretty serious: #10970
…n_chain_stream (langflow-ai#11362) * fix: improve condition check for streaming token callback in handle_on_chain_stream * [autofix.ci] apply automated fixes * bug: fixed test for streaming skip empty chunks --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This pull request makes a minor update to the logic for streaming token events in the
handle_on_chain_streamfunction. The change improves the condition that checks whether to send a token event, ensuring it is more explicit and reliable.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.