-
Notifications
You must be signed in to change notification settings - Fork 302
write chunks in TextParserStreamer #3025
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
base: master
Are you sure you want to change the base?
write chunks in TextParserStreamer #3025
Conversation
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.
Pull Request Overview
This PR refactors the TextParserStreamer to return incremental delta messages in the write() callback instead of accumulated messages, while still maintaining accumulated message access via get_parsed_message(). The key changes update the reasoning parser implementation to properly handle delta messages and modify the concatenation logic in the streamer.
- Modified
TextParserStreamerto write delta messages instead of accumulated messages - Updated
ReasoningIncrementalParserto populate message fields for incremental output - Added
concatenate_json_containers()helper function for message accumulation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/python_tests/test_parsers.py | Updated tests to use get_parsed_message() for assertions and removed manual message accumulation in custom streamers |
| src/cpp/src/text_streamer.cpp | Added concatenate_json_containers() function and modified write() to return delta messages while maintaining internal accumulation |
| src/cpp/src/parsers.cpp | Refactored ReasoningIncrementalParser to populate content field in delta messages and removed keep_original_content logic from helper methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9b7cd5c to
a41f0d0
Compare
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
tests/python_tests/test_parsers.py:1
- Assignment to
reason_strloses previously accumulated reasoning content. The variable should be appended to, not replaced, to preserve partial reasoning text from previous chunks.
# Copyright (C) 2023-2025 Intel Corporation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d71fc3f to
4017fb5
Compare
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.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| prompt = "Please say \"hello\"" | ||
| res = pipe.generate([prompt], max_new_tokens=600, parsers=[Phi4ReasoningParser()]) | ||
| res = pipe.generate([prompt], max_new_tokens=600, parsers=[ReasoningParser(keep_original_content=False)]) |
Copilot
AI
Nov 27, 2025
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.
The parser class 'ReasoningParser' is not imported. The removed import at line 7 shows 'Phi4ReasoningParser' was available, but 'ReasoningParser' is not in the import list. This will cause a NameError at runtime.
| } | ||
|
|
||
| // Every time we start to cycle through iterative parsers we create a new delta_message. | ||
| // Parsers should neither delete fields nor rewrite they should only append or add new fields. |
Copilot
AI
Nov 27, 2025
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.
Missing punctuation after 'rewrite'. The sentence should read 'Parsers should neither delete fields nor rewrite; they should only append or add new fields.' or split into two sentences.
| // Parsers should neither delete fields nor rewrite they should only append or add new fields. | |
| // Parsers should neither delete fields nor rewrite; they should only append or add new fields. |
|
|
||
| // Every time we start to cycle through iterative parsers we create a new delta_message. | ||
| // Parsers should neither delete fields nor rewrite they should only append or add new fields. | ||
| // The only field is updated automaticall is "content": delta_text is put there. |
Copilot
AI
Nov 27, 2025
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.
Corrected spelling of 'automaticall' to 'automatically'.
| // The only field is updated automaticall is "content": delta_text is put there. | |
| // The only field that is updated automatically is "content": delta_text is put there. |
| OPENVINO_ASSERT(src_val.is_string(), "JsonContainer concatenate supports only string concatenation for object values."); | ||
| auto& dst_val = (*dst_)[it.key()]; |
Copilot
AI
Nov 27, 2025
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.
The error message states that only string concatenation is supported, but the assertion only checks if src_val is a string. If dst_val exists and is not a string, the concatenation on line 426 will fail with a different error. Consider checking both src_val and dst_val are strings, or improve the error message to be more specific about which value is not a string.
| OPENVINO_ASSERT(src_val.is_string(), "JsonContainer concatenate supports only string concatenation for object values."); | |
| auto& dst_val = (*dst_)[it.key()]; | |
| auto& dst_val = (*dst_)[it.key()]; | |
| OPENVINO_ASSERT( | |
| src_val.is_string() && dst_val.is_string(), | |
| "JsonContainer concatenate supports only string concatenation for object values. " | |
| "Key: '", it.key(), "', src_val type: '", src_val.type_name(), "', dst_val type: '", dst_val.type_name(), "'." | |
| ); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Return DeltaMessage in incremental
TextStreamerParserinstead of accumulated msg. But accumulated is still available viaget_parsed_message()CVS-CVS-176146
Fixes #(issue)
Checklist: