-
Notifications
You must be signed in to change notification settings - Fork 290
Introduce chat history class #2816
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
Introduce chat history class #2816
Conversation
@Retribution98 Could you please review JS bindings? |
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.
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) { |
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.
I would suggest moving it into the JavaScript part and sending a JSON-like string to the Node addon.
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.
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)
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.
Later we can optimize the conversion from JS to C++ JsonContainer with direct native method instead of string serialization.
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 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.
8da0387
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 usesJsonContainer
internally for message storage and adds Python bindings for the new class.Ticket: CVS-170884
Checklist: