-
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?
Changes from 5 commits
2be242f
4017fb5
6e5dcc2
ae2f662
a8764fe
23fa222
3a8e302
db57dd4
48a0b14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,18 +20,6 @@ class ReasoningIncrementalParser::ReasoningParserImpl { | |||||||||||
| bool m_think_tag_opened = false; | ||||||||||||
| std::string m_text_cache = ""; | ||||||||||||
| bool m_deactivated = false; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @brief Ensure required fields exist in the message container. | ||||||||||||
| */ | ||||||||||||
| void ensure_message_fields(JsonContainer& message) { | ||||||||||||
| if (!message.contains("reasoning_content")) { | ||||||||||||
| message["reasoning_content"] = ""; | ||||||||||||
| } | ||||||||||||
| if (!message.contains("content")) { | ||||||||||||
| message["content"] = ""; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @brief Find the longest suffix of text that is a prefix of the close tag. | ||||||||||||
|
|
@@ -61,8 +49,8 @@ class ReasoningIncrementalParser::ReasoningParserImpl { | |||||||||||
| void handle_complete_reasoning(JsonContainer& message, std::string_view txt_chunk, | ||||||||||||
| size_t open_idx, size_t close_idx, std::string& delta_text) { | ||||||||||||
| // Extract reasoning content between tags | ||||||||||||
| message["reasoning_content"] = std::string(txt_chunk.substr(open_idx + m_open_tag.size(), | ||||||||||||
| close_idx - (open_idx + m_open_tag.size()))); | ||||||||||||
| message["reasoning_content"] = std::string(txt_chunk.substr(open_idx + m_open_tag.size(), close_idx - (open_idx + m_open_tag.size()))); | ||||||||||||
|
||||||||||||
| message["reasoning_content"] = std::string(txt_chunk.substr(open_idx + m_open_tag.size(), close_idx - (open_idx + m_open_tag.size()))); | |
| size_t reasoning_length = close_idx - (open_idx + m_open_tag.size()); | |
| message["reasoning_content"] = std::string(txt_chunk.substr(open_idx + m_open_tag.size(), reasoning_length)); |
pavel-esir marked this conversation as resolved.
Show resolved
Hide resolved
pavel-esir marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
pavel-esir marked this conversation as resolved.
Show resolved
Hide resolved
pavel-esir marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 28, 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.
[nitpick] The comment above this line describes why delta_text is cleared, but it should be updated to reflect that this intentional clearing is part of the caching strategy while waiting for the full <think> tag.
| // Intentionally clear delta_text: no delta content is returned to the user during this phase | |
| // (we are waiting for the <think> tag to be fully detected in the cache). | |
| // Intentionally clear delta_text as part of the caching strategy: | |
| // no delta content is returned to the user during this phase because we are | |
| // accumulating partial data in m_text_cache until the full <think> tag is detected. |
Uh oh!
There was an error while loading. Please reload this page.
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.
Update doc. Replace message -> delta_message in
@param message JsonContainer to store parsed results and reasoning metadata