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

View File

@@ -18,10 +18,13 @@ M.__index = M
---@field just_for_display? boolean ---@field just_for_display? boolean
---@field visible? boolean ---@field visible? boolean
--- ---
---@param message AvanteLLMMessage ---@param role "user" | "assistant"
---@param content AvanteLLMMessageContentItem
---@param opts? avante.HistoryMessage.Opts ---@param opts? avante.HistoryMessage.Opts
---@return avante.HistoryMessage ---@return avante.HistoryMessage
function M:new(message, opts) function M:new(role, content, opts)
---@type AvanteLLMMessage
local message = { role = role, content = type(content) == "string" and content or { content } }
local obj = { local obj = {
message = message, message = message,
uuid = Utils.uuid(), uuid = Utils.uuid(),
@@ -36,20 +39,17 @@ end
---Creates a new instance of synthetic (dummy) history message ---Creates a new instance of synthetic (dummy) history message
---@param role "assistant" | "user" ---@param role "assistant" | "user"
---@param item AvanteLLMMessageContentItem | string ---@param item AvanteLLMMessageContentItem
---@return avante.HistoryMessage ---@return avante.HistoryMessage
function M:new_synthetic(role, item) function M:new_synthetic(role, item) return M:new(role, item, { is_dummy = true }) end
local content = type(item) == "string" and item or { item }
return M:new({ role = role, content = content }, { is_dummy = true })
end
---Creates a new instance of synthetic (dummy) history message attributed to the assistant ---Creates a new instance of synthetic (dummy) history message attributed to the assistant
---@param item AvanteLLMMessageContentItem | string ---@param item AvanteLLMMessageContentItem
---@return avante.HistoryMessage ---@return avante.HistoryMessage
function M:new_assistant_synthetic(item) return M:new_synthetic("assistant", item) end function M:new_assistant_synthetic(item) return M:new_synthetic("assistant", item) end
---Creates a new instance of synthetic (dummy) history message attributed to the user ---Creates a new instance of synthetic (dummy) history message attributed to the user
---@param item AvanteLLMMessageContentItem | string ---@param item AvanteLLMMessageContentItem
---@return avante.HistoryMessage ---@return avante.HistoryMessage
function M:new_user_synthetic(item) return M:new_synthetic("user", item) end function M:new_user_synthetic(item) return M:new_synthetic("user", item) end

View File

@@ -779,17 +779,12 @@ function M._stream(opts)
---@type avante.HistoryMessage[] ---@type avante.HistoryMessage[]
local messages = {} local messages = {}
for _, tool_result in ipairs(tool_results) do for _, tool_result in ipairs(tool_results) do
messages[#messages + 1] = History.Message:new({ messages[#messages + 1] = History.Message:new("user", {
role = "user",
content = {
{
type = "tool_result", type = "tool_result",
tool_use_id = tool_result.tool_use_id, tool_use_id = tool_result.tool_use_id,
content = tool_result.content, content = tool_result.content,
is_error = tool_result.is_error, is_error = tool_result.is_error,
is_user_declined = tool_result.is_user_declined, is_user_declined = tool_result.is_user_declined,
},
},
}) })
end end
if opts.on_messages_add then opts.on_messages_add(messages) end if opts.on_messages_add then opts.on_messages_add(messages) end
@@ -822,12 +817,10 @@ function M._stream(opts)
-- Special handling for cancellation signal from tools -- Special handling for cancellation signal from tools
if error == LLMToolHelpers.CANCEL_TOKEN then if error == LLMToolHelpers.CANCEL_TOKEN then
Utils.debug("Tool execution was cancelled by user") Utils.debug("Tool execution was cancelled by user")
if opts.on_chunk then opts.on_chunk("\n*[Request cancelled by user during tool execution.]*\n") end local cancelled_text = "\n*[Request cancelled by user during tool execution.]*\n"
if opts.on_chunk then opts.on_chunk(cancelled_text) end
if opts.on_messages_add then if opts.on_messages_add then
local message = History.Message:new({ local message = History.Message:new("assistant", cancelled_text, {
role = "assistant",
content = "\n*[Request cancelled by user during tool execution.]*\n",
}, {
just_for_display = true, just_for_display = true,
}) })
opts.on_messages_add({ message }) opts.on_messages_add({ message })
@@ -878,12 +871,10 @@ function M._stream(opts)
if result ~= nil or error ~= nil then return handle_tool_result(result, error) end if result ~= nil or error ~= nil then return handle_tool_result(result, error) end
end end
if stop_opts.reason == "cancelled" then if stop_opts.reason == "cancelled" then
if opts.on_chunk then opts.on_chunk("\n*[Request cancelled by user.]*\n") end local cancelled_text = "\n*[Request cancelled by user.]*\n"
if opts.on_chunk then opts.on_chunk(cancelled_text) end
if opts.on_messages_add then if opts.on_messages_add then
local message = History.Message:new({ local message = History.Message:new("assistant", cancelled_text, {
role = "assistant",
content = "\n*[Request cancelled by user.]*\n",
}, {
just_for_display = true, just_for_display = true,
}) })
opts.on_messages_add({ message }) opts.on_messages_add({ message })
@@ -922,19 +913,21 @@ function M._stream(opts)
Utils.debug("user reminder count", user_reminder_count) Utils.debug("user reminder count", user_reminder_count)
local message local message
if #unfinished_todos > 0 then if #unfinished_todos > 0 then
message = History.Message:new({ message = History.Message:new(
role = "user", "user",
content = "<user-reminder>You should use tool calls to answer the question, for example, use update_todo_status if the task step is done or cancelled.</user-reminder>", "<user-reminder>You should use tool calls to answer the question, for example, use update_todo_status if the task step is done or cancelled.</user-reminder>",
}, { {
visible = false, visible = false,
}) }
)
else else
message = History.Message:new({ message = History.Message:new(
role = "user", "user",
content = "<user-reminder>You should use tool calls to answer the question, for example, use attempt_completion if the job is done.</user-reminder>", "<user-reminder>You should use tool calls to answer the question, for example, use attempt_completion if the job is done.</user-reminder>",
}, { {
visible = false, visible = false,
}) }
)
end end
opts.on_messages_add({ message }) opts.on_messages_add({ message })
local new_opts = vim.tbl_deep_extend("force", opts, { local new_opts = vim.tbl_deep_extend("force", opts, {
@@ -958,12 +951,13 @@ function M._stream(opts)
end end
if stop_opts.reason == "rate_limit" then if stop_opts.reason == "rate_limit" then
local message = opts.on_messages_add local message = opts.on_messages_add
and History.Message:new({ and History.Message:new(
role = "assistant", "assistant",
content = "", -- Actual content will be set below "", -- Actual content will be set below
}, { {
just_for_display = true, just_for_display = true,
}) }
)
local timer = vim.loop.new_timer() local timer = vim.loop.new_timer()
if timer then if timer then

View File

@@ -263,10 +263,7 @@ When you're done, provide a clear and concise summary of what you found.]]):gsub
.. elapsed_time .. elapsed_time
.. "s)" .. "s)"
if session_ctx.on_messages_add then if session_ctx.on_messages_add then
local message = History.Message:new({ local message = History.Message:new("assistant", "\n\n" .. summary, {
role = "assistant",
content = "\n\n" .. summary,
}, {
just_for_display = true, just_for_display = true,
}) })
session_ctx.on_messages_add({ message }) session_ctx.on_messages_add({ message })

View File

@@ -161,6 +161,24 @@ function M:parse_response(ctx, data_stream, event_state, opts)
end end
end end
if ctx.content_blocks == nil then ctx.content_blocks = {} end if ctx.content_blocks == nil then ctx.content_blocks = {} end
---@param content AvanteLLMMessageContentItem
---@param uuid? string
---@return avante.HistoryMessage
local function new_assistant_message(content, uuid)
assert(
event_state == "content_block_start"
or event_state == "content_block_delta"
or event_state == "content_block_stop",
"called with unexpected event_state: " .. event_state
)
return HistoryMessage:new("assistant", content, {
state = event_state == "content_block_stop" and "generated" or "generating",
turn_id = ctx.turn_id,
uuid = uuid,
})
end
if event_state == "message_start" then if event_state == "message_start" then
local ok, jsn = pcall(vim.json.decode, data_stream) local ok, jsn = pcall(vim.json.decode, data_stream)
if not ok then return end if not ok then return end
@@ -172,56 +190,34 @@ function M:parse_response(ctx, data_stream, event_state, opts)
content_block.stoppped = false content_block.stoppped = false
ctx.content_blocks[jsn.index + 1] = content_block ctx.content_blocks[jsn.index + 1] = content_block
if content_block.type == "text" then if content_block.type == "text" then
local msg = HistoryMessage:new({ local msg = new_assistant_message(content_block.text)
role = "assistant",
content = content_block.text,
}, {
state = "generating",
turn_id = ctx.turn_id,
})
content_block.uuid = msg.uuid content_block.uuid = msg.uuid
if opts.on_messages_add then opts.on_messages_add({ msg }) end if opts.on_messages_add then opts.on_messages_add({ msg }) end
end elseif content_block.type == "thinking" then
if content_block.type == "thinking" then
if opts.on_chunk then opts.on_chunk("<think>\n") end if opts.on_chunk then opts.on_chunk("<think>\n") end
if opts.on_messages_add then if opts.on_messages_add then
local msg = HistoryMessage:new({ local msg = new_assistant_message({
role = "assistant",
content = {
{
type = "thinking", type = "thinking",
thinking = content_block.thinking, thinking = content_block.thinking,
signature = content_block.signature, signature = content_block.signature,
},
},
}, {
state = "generating",
turn_id = ctx.turn_id,
}) })
content_block.uuid = msg.uuid content_block.uuid = msg.uuid
opts.on_messages_add({ msg }) opts.on_messages_add({ msg })
end end
end elseif content_block.type == "tool_use" then
if content_block.type == "tool_use" and opts.on_messages_add then if opts.on_messages_add then
local incomplete_json = JsonParser.parse(content_block.input_json) local incomplete_json = JsonParser.parse(content_block.input_json)
local msg = HistoryMessage:new({ local msg = new_assistant_message({
role = "assistant",
content = {
{
type = "tool_use", type = "tool_use",
name = content_block.name, name = content_block.name,
id = content_block.id, id = content_block.id,
input = incomplete_json or {}, input = incomplete_json or {},
},
},
}, {
state = "generating",
turn_id = ctx.turn_id,
}) })
content_block.uuid = msg.uuid content_block.uuid = msg.uuid
opts.on_messages_add({ msg }) opts.on_messages_add({ msg })
-- opts.on_stop({ reason = "tool_use", streaming_tool_use = true }) -- opts.on_stop({ reason = "tool_use", streaming_tool_use = true })
end end
end
elseif event_state == "content_block_delta" then elseif event_state == "content_block_delta" then
local ok, jsn = pcall(vim.json.decode, data_stream) local ok, jsn = pcall(vim.json.decode, data_stream)
if not ok then return end if not ok then return end
@@ -233,33 +229,21 @@ function M:parse_response(ctx, data_stream, event_state, opts)
elseif jsn.delta.type == "thinking_delta" then elseif jsn.delta.type == "thinking_delta" then
content_block.thinking = content_block.thinking .. jsn.delta.thinking content_block.thinking = content_block.thinking .. jsn.delta.thinking
if opts.on_chunk then opts.on_chunk(jsn.delta.thinking) end if opts.on_chunk then opts.on_chunk(jsn.delta.thinking) end
local msg = HistoryMessage:new({ if opts.on_messages_add then
role = "assistant", local msg = new_assistant_message({
content = {
{
type = "thinking", type = "thinking",
thinking = content_block.thinking, thinking = content_block.thinking,
signature = content_block.signature, signature = content_block.signature,
}, }, content_block.uuid)
}, opts.on_messages_add({ msg })
}, { end
state = "generating",
uuid = content_block.uuid,
turn_id = ctx.turn_id,
})
if opts.on_messages_add then opts.on_messages_add({ msg }) end
elseif jsn.delta.type == "text_delta" then elseif jsn.delta.type == "text_delta" then
content_block.text = content_block.text .. jsn.delta.text content_block.text = content_block.text .. jsn.delta.text
if opts.on_chunk then opts.on_chunk(jsn.delta.text) end if opts.on_chunk then opts.on_chunk(jsn.delta.text) end
local msg = HistoryMessage:new({ if opts.on_messages_add then
role = "assistant", local msg = new_assistant_message(content_block.text, content_block.uuid)
content = content_block.text, opts.on_messages_add({ msg })
}, { end
state = "generating",
uuid = content_block.uuid,
turn_id = ctx.turn_id,
})
if opts.on_messages_add then opts.on_messages_add({ msg }) end
elseif jsn.delta.type == "signature_delta" then elseif jsn.delta.type == "signature_delta" then
if ctx.content_blocks[jsn.index + 1].signature == nil then ctx.content_blocks[jsn.index + 1].signature = "" end if ctx.content_blocks[jsn.index + 1].signature == nil then ctx.content_blocks[jsn.index + 1].signature = "" end
ctx.content_blocks[jsn.index + 1].signature = ctx.content_blocks[jsn.index + 1].signature .. jsn.delta.signature ctx.content_blocks[jsn.index + 1].signature = ctx.content_blocks[jsn.index + 1].signature .. jsn.delta.signature
@@ -270,36 +254,11 @@ function M:parse_response(ctx, data_stream, event_state, opts)
local content_block = ctx.content_blocks[jsn.index + 1] local content_block = ctx.content_blocks[jsn.index + 1]
content_block.stoppped = true content_block.stoppped = true
if content_block.type == "text" then if content_block.type == "text" then
local msg = HistoryMessage:new({ if opts.on_messages_add then
role = "assistant", local msg = new_assistant_message(content_block.text, content_block.uuid)
content = content_block.text, opts.on_messages_add({ msg })
}, {
state = "generated",
uuid = content_block.uuid,
turn_id = ctx.turn_id,
})
if opts.on_messages_add then opts.on_messages_add({ msg }) end
end end
if content_block.type == "tool_use" then elseif content_block.type == "thinking" then
local complete_json = vim.json.decode(content_block.input_json)
local msg = HistoryMessage:new({
role = "assistant",
content = {
{
type = "tool_use",
name = content_block.name,
id = content_block.id,
input = complete_json or {},
},
},
}, {
state = "generated",
uuid = content_block.uuid,
turn_id = ctx.turn_id,
})
if opts.on_messages_add then opts.on_messages_add({ msg }) end
end
if content_block.type == "thinking" then
if opts.on_chunk then if opts.on_chunk then
if content_block.thinking and content_block.thinking ~= vim.NIL and content_block.thinking:sub(-1) ~= "\n" then if content_block.thinking and content_block.thinking ~= vim.NIL and content_block.thinking:sub(-1) ~= "\n" then
opts.on_chunk("\n</think>\n\n") opts.on_chunk("\n</think>\n\n")
@@ -307,21 +266,25 @@ function M:parse_response(ctx, data_stream, event_state, opts)
opts.on_chunk("</think>\n\n") opts.on_chunk("</think>\n\n")
end end
end end
local msg = HistoryMessage:new({ if opts.on_messages_add then
role = "assistant", local msg = new_assistant_message({
content = {
{
type = "thinking", type = "thinking",
thinking = content_block.thinking, thinking = content_block.thinking,
signature = content_block.signature, signature = content_block.signature,
}, }, content_block.uuid)
}, opts.on_messages_add({ msg })
}, { end
state = "generated", elseif content_block.type == "tool_use" then
uuid = content_block.uuid, if opts.on_messages_add then
turn_id = ctx.turn_id, local complete_json = vim.json.decode(content_block.input_json)
}) local msg = new_assistant_message({
if opts.on_messages_add then opts.on_messages_add({ msg }) end type = "tool_use",
name = content_block.name,
id = content_block.id,
input = complete_json or {},
}, content_block.uuid)
opts.on_messages_add({ msg })
end
end end
elseif event_state == "message_delta" then elseif event_state == "message_delta" then
local ok, jsn = pcall(vim.json.decode, data_stream) local ok, jsn = pcall(vim.json.decode, data_stream)

View File

@@ -135,27 +135,24 @@ function M:is_disable_stream() return false end
---@param tool_calls avante.OllamaToolCall[] ---@param tool_calls avante.OllamaToolCall[]
---@param opts AvanteLLMStreamOptions ---@param opts AvanteLLMStreamOptions
function M:add_tool_use_messages(tool_calls, opts) function M:add_tool_use_messages(tool_calls, opts)
if opts.on_messages_add then
local msgs = {} local msgs = {}
for _, tool_call in ipairs(tool_calls) do for _, tool_call in ipairs(tool_calls) do
local id = Utils.uuid() local id = Utils.uuid()
local func = tool_call["function"] local func = tool_call["function"]
local msg = HistoryMessage:new({ local msg = HistoryMessage:new("assistant", {
role = "assistant",
content = {
{
type = "tool_use", type = "tool_use",
name = func.name, name = func.name,
id = id, id = id,
input = func.arguments, input = func.arguments,
},
},
}, { }, {
state = "generated", state = "generated",
uuid = id, uuid = id,
}) })
table.insert(msgs, msg) table.insert(msgs, msg)
end end
if opts.on_messages_add then opts.on_messages_add(msgs) end opts.on_messages_add(msgs)
end
end end
function M:parse_stream_data(ctx, data, opts) function M:parse_stream_data(ctx, data, opts)

View File

@@ -231,10 +231,7 @@ function M:add_text_message(ctx, text, state, opts)
local content = local content =
ctx.content:gsub("<tool_code>", ""):gsub("</tool_code>", ""):gsub("<tool_call>", ""):gsub("</tool_call>", "") ctx.content:gsub("<tool_code>", ""):gsub("</tool_code>", ""):gsub("<tool_call>", ""):gsub("</tool_call>", "")
ctx.content = content ctx.content = content
local msg = HistoryMessage:new({ local msg = HistoryMessage:new("assistant", ctx.content, {
role = "assistant",
content = ctx.content,
}, {
state = state, state = state,
uuid = ctx.content_uuid, uuid = ctx.content_uuid,
original_content = ctx.content, original_content = ctx.content,
@@ -299,16 +296,11 @@ function M:add_text_message(ctx, text, state, opts)
has_tool_use = true has_tool_use = true
local msg_uuid = ctx.content_uuid .. "-" .. idx local msg_uuid = ctx.content_uuid .. "-" .. idx
local tool_use_id = msg_uuid local tool_use_id = msg_uuid
local msg_ = HistoryMessage:new({ local msg_ = HistoryMessage:new("assistant", {
role = "assistant",
content = {
{
type = "tool_use", type = "tool_use",
name = item.tool_name, name = item.tool_name,
id = tool_use_id, id = tool_use_id,
input = input, input = input,
},
},
}, { }, {
state = state, state = state,
uuid = msg_uuid, uuid = msg_uuid,
@@ -342,15 +334,10 @@ end
function M:add_thinking_message(ctx, text, state, opts) function M:add_thinking_message(ctx, text, state, opts)
if ctx.reasonging_content == nil then ctx.reasonging_content = "" end if ctx.reasonging_content == nil then ctx.reasonging_content = "" end
ctx.reasonging_content = ctx.reasonging_content .. text ctx.reasonging_content = ctx.reasonging_content .. text
local msg = HistoryMessage:new({ local msg = HistoryMessage:new("assistant", {
role = "assistant",
content = {
{
type = "thinking", type = "thinking",
thinking = ctx.reasonging_content, thinking = ctx.reasonging_content,
signature = "", signature = "",
},
},
}, { }, {
state = state, state = state,
uuid = ctx.reasonging_content_uuid, uuid = ctx.reasonging_content_uuid,
@@ -362,16 +349,11 @@ end
function M:add_tool_use_message(ctx, tool_use, state, opts) function M:add_tool_use_message(ctx, tool_use, state, opts)
local jsn = JsonParser.parse(tool_use.input_json) local jsn = JsonParser.parse(tool_use.input_json)
local msg = HistoryMessage:new({ local msg = HistoryMessage:new("assistant", {
role = "assistant",
content = {
{
type = "tool_use", type = "tool_use",
name = tool_use.name, name = tool_use.name,
id = tool_use.id, id = tool_use.id,
input = jsn or {}, input = jsn or {},
},
},
}, { }, {
state = state, state = state,
uuid = tool_use.uuid, uuid = tool_use.uuid,

View File

@@ -2094,6 +2094,7 @@ function Sidebar:add_history_messages(messages)
end) end)
end end
-- FIXME: this is used by external plugin users
---@param messages AvanteLLMMessage | AvanteLLMMessage[] ---@param messages AvanteLLMMessage | AvanteLLMMessage[]
---@param options {visible?: boolean} ---@param options {visible?: boolean}
function Sidebar:add_chat_history(messages, options) function Sidebar:add_chat_history(messages, options)
@@ -2102,25 +2103,18 @@ function Sidebar:add_chat_history(messages, options)
local is_first_user = true local is_first_user = true
local history_messages = {} local history_messages = {}
for _, message in ipairs(messages) do for _, message in ipairs(messages) do
local content = message.content local role = message.role
if message.role == "system" and type(content) == "string" then if role == "system" and type(message.content) == "string" then
---@cast content string self.chat_history.system_prompt = message.content --[[@as string]]
self.chat_history.system_prompt = content else
goto continue ---@type AvanteLLMMessageContentItem
end local content = type(message.content) ~= "table" and message.content or message.content[1]
local history_message = History.Message:new(message) local msg_opts = { visible = options.visible }
if message.role == "user" and is_first_user then if role == "user" and is_first_user then
msg_opts.is_user_submission = true
is_first_user = false is_first_user = false
history_message.is_user_submission = true
history_message.provider = Config.provider
history_message.model = Config.get_provider_config(Config.provider).model
end end
table.insert(history_messages, history_message) table.insert(history_messages, History.Message:new(role, content, msg_opts))
::continue::
end
if options.visible ~= nil then
for _, history_message in ipairs(history_messages) do
history_message.visible = options.visible
end end
end end
self:add_history_messages(history_messages) self:add_history_messages(history_messages)
@@ -2415,7 +2409,7 @@ function Sidebar:create_input_container()
if self.is_generating then if self.is_generating then
self:add_history_messages({ self:add_history_messages({
History.Message:new({ role = "user", content = request }), History.Message:new("user", request),
}) })
return return
end end
@@ -2553,10 +2547,7 @@ function Sidebar:create_input_container()
local msg_content = stop_opts.error local msg_content = stop_opts.error
if type(msg_content) ~= "string" then msg_content = vim.inspect(msg_content) end if type(msg_content) ~= "string" then msg_content = vim.inspect(msg_content) end
self:add_history_messages({ self:add_history_messages({
History.Message:new({ History.Message:new("assistant", "\n\nError: " .. msg_content, {
role = "assistant",
content = "\n\nError: " .. msg_content,
}, {
just_for_display = true, just_for_display = true,
}), }),
}) })
@@ -2584,10 +2575,7 @@ function Sidebar:create_input_container()
if request and request ~= "" then if request and request ~= "" then
self:add_history_messages({ self:add_history_messages({
History.Message:new({ History.Message:new("user", request, {
role = "user",
content = request,
}, {
is_user_submission = true, is_user_submission = true,
selected_filepaths = selected_filepaths, selected_filepaths = selected_filepaths,
selected_code = selected_code, selected_code = selected_code,
@@ -2812,6 +2800,7 @@ function Sidebar:create_input_container()
}) })
end end
-- FIXME: this is used by external plugin users
---@param value string ---@param value string
function Sidebar:set_input_value(value) function Sidebar:set_input_value(value)
if not self.containers.input then return end if not self.containers.input then return end

View File

@@ -231,7 +231,10 @@ L5: pass
}, },
} }
local history_messages = vim.iter(llm_messages):map(function(msg) return HistoryMessage:new(msg) end):totable() local history_messages = vim
.iter(llm_messages)
:map(function(msg) return HistoryMessage:new(msg.role, msg.content) end)
:totable()
local diagnostics = Utils.lsp.get_diagnostics(bufnr) local diagnostics = Utils.lsp.get_diagnostics(bufnr)