refactor(history): change HistoryMessage:new() to accept role and item

Change the constructor to accept role and a single content item instead
of raw AvanteLLMMessage instance. This will help when we will start
changing message.content from being a string or a list of tables to just
a string or a single table.
This commit is contained in:
Dmitry Torokhov
2025-07-18 15:08:19 -07:00
committed by yetone
parent 2d9f8fd252
commit aa606b6147
9 changed files with 171 additions and 252 deletions

View File

@@ -14,10 +14,7 @@ function M.get_history_messages(history)
local messages = {}
for _, entry in ipairs(history.entries or {}) do
if entry.request and entry.request ~= "" then
local message = Message:new({
role = "user",
content = entry.request,
}, {
local message = Message:new("user", entry.request, {
timestamp = entry.timestamp,
is_user_submission = true,
visible = entry.visible,
@@ -27,10 +24,7 @@ function M.get_history_messages(history)
table.insert(messages, message)
end
if entry.response and entry.response ~= "" then
local message = Message:new({
role = "assistant",
content = entry.response,
}, {
local message = Message:new("assistant", entry.response, {
timestamp = entry.timestamp,
visible = entry.visible,
})