Skip to content

Conversation

yatarkan
Copy link
Contributor

@yatarkan yatarkan commented Oct 10, 2025

Description

This PR introduces a new ChatHistory class to replace the previous vector-based chat history implementation, providing a more structured and type-safe way to handle conversation messages. The implementation uses JsonContainer internally for message storage and adds Python bindings for the new class.

Ticket: CVS-170884

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 - N/A

@github-actions github-actions bot added category: visual language Visual language pipeline category: LLM LLM pipeline (stateful, static) category: tokenizers Tokenizer class or submodule update category: Python API Python API for GenAI category: CPP API Changes in GenAI C++ public headers no-match-files category: GGUF GGUF file reader labels Oct 10, 2025
@yatarkan
Copy link
Contributor Author

@Retribution98 Could you please review JS bindings?

Copy link
Contributor

@Retribution98 Retribution98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS part is ok
I left a couple of comments. Changes to the types are also required to provide users with the correct API, but I can do all of that myself in a separate pull request.

return env.Global().Get("Number").ToObject().Get("isInteger").As<Napi::Function>().Call({num}).ToBoolean().Value();
}

std::string json_stringify(const Napi::Env& env, const Napi::Value& value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest moving it into the JavaScript part and sending a JSON-like string to the Node addon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the API perspective I think it would be better for users to work with chat history as an array of objects (like in Python).
Using json stringify is the simplest way now to convert JS Napi value and construct chat history C++ via JsonContainer. Conversion from JS to C++ also can be done through ov::AnyMap, but it does not preserve keys order (as AnyMap sorts object keys alphabetically, while converting through json string keeps the order)

Copy link
Contributor Author

@yatarkan yatarkan Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later we can optimize the conversion from JS to C++ JsonContainer with direct native method instead of string serialization.

@Wovchena Wovchena requested a review from Copilot October 16, 2025 09:19
Copy link
Contributor

@Copilot 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 26 out of 26 changed files in this pull request and generated 11 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@apaniukov apaniukov added this pull request to the merge queue Oct 17, 2025
Merged via the queue into openvinotoolkit:master with commit 8da0387 Oct 17, 2025
189 of 198 checks passed
@yatarkan yatarkan mentioned this pull request Oct 17, 2025
3 tasks
@yatarkan yatarkan deleted the yt/json-chat-history branch October 17, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: CPP API Changes in GenAI C++ public headers category: GGUF GGUF file reader category: JS API GenAI JS API category: LLM LLM pipeline (stateful, static) category: Python API Python API for GenAI category: tokenizers Tokenizer class or submodule update category: visual language Visual language pipeline Code Freeze no-match-files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants