feat: tool logs (#1190)

This commit is contained in:
yetone
2025-02-06 15:15:44 +08:00
committed by GitHub
parent 252a9e7818
commit 4f41154e83
3 changed files with 68 additions and 12 deletions

View File

@@ -1810,6 +1810,17 @@ function Sidebar:create_input_container(opts)
displayed_response = cur_displayed_response
end
local on_tool_log = function(tool_name, log)
if transformed_response:sub(-1) ~= "\n" then transformed_response = transformed_response .. "\n" end
transformed_response = transformed_response .. "[" .. tool_name .. "]: " .. log
local breakline = ""
if displayed_response:sub(-1) ~= "\n" then breakline = "\n" end
displayed_response = displayed_response .. breakline .. "[" .. tool_name .. "]: " .. log
self:update_content(content_prefix .. displayed_response .. "\n", {
scroll = scroll,
})
end
---@type AvanteLLMStopCallback
local on_stop = function(stop_opts)
pcall(function()
@@ -1870,6 +1881,7 @@ function Sidebar:create_input_container(opts)
on_start = on_start,
on_chunk = on_chunk,
on_stop = on_stop,
on_tool_log = on_tool_log,
})
Llm.stream(stream_options)