Skip to content

Conversation

@pavel-esir
Copy link
Contributor

@pavel-esir pavel-esir commented Nov 17, 2025

Description

Return DeltaMessage in incremental TextStreamerParser instead of accumulated msg. But accumulated is still available via get_parsed_message()

CVS-CVS-176146

Fixes #(issue)

Checklist:

  • Tests have been updated or added to cover the new code.
  • This patch fully addresses the ticket.
  • I have made corresponding changes to the documentation. TODO

Copilot AI review requested due to automatic review settings November 17, 2025 11:58
@pavel-esir pavel-esir requested a review from apaniukov November 17, 2025 11:59
Copy link
Contributor

Copilot AI left a 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 TextParserStreamer to write delta messages instead of accumulated messages
  • Updated ReasoningIncrementalParser to 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.

@pavel-esir pavel-esir force-pushed the write_chunks_during_parse branch from 9b7cd5c to a41f0d0 Compare November 21, 2025 12:08
Copilot AI review requested due to automatic review settings November 21, 2025 12:08
Copy link
Contributor

Copilot AI left a 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_str loses 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.

@pavel-esir pavel-esir force-pushed the write_chunks_during_parse branch 2 times, most recently from d71fc3f to 4017fb5 Compare November 21, 2025 12:23
Copilot AI review requested due to automatic review settings November 21, 2025 12:23
Copy link
Contributor

Copilot AI left a 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.

Copilot AI review requested due to automatic review settings November 27, 2025 23:31
@github-actions github-actions bot added the category: CPP API Changes in GenAI C++ public headers label Nov 27, 2025
Copy link
Contributor

Copilot AI left a 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.

Copy link
Contributor

Copilot AI left a 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.

Copilot AI review requested due to automatic review settings November 27, 2025 23:36
Copy link
Contributor

Copilot AI left a 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>
Copilot AI review requested due to automatic review settings November 27, 2025 23:40
Copy link
Contributor

Copilot AI left a 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>
Copilot AI review requested due to automatic review settings November 27, 2025 23:45
Copy link
Contributor

Copilot AI left a 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)])
Copy link

Copilot AI Nov 27, 2025

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.

Copilot uses AI. Check for mistakes.
}

// 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.
Copy link

Copilot AI Nov 27, 2025

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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.

// 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.
Copy link

Copilot AI Nov 27, 2025

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'.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Comment on lines +424 to +425
OPENVINO_ASSERT(src_val.is_string(), "JsonContainer concatenate supports only string concatenation for object values.");
auto& dst_val = (*dst_)[it.key()];
Copy link

Copilot AI Nov 27, 2025

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.

Suggested change
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(), "'."
);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants