feat: streaming diff (#2107)

This commit is contained in:
yetone
2025-06-02 16:44:33 +08:00
committed by GitHub
parent bc403ddcbf
commit 746f071b37
12 changed files with 1449 additions and 130 deletions

View File

@@ -54,13 +54,16 @@ M.returns = {
},
}
---@type AvanteLLMToolFunc<{ path: string, old_str: string, new_str: string }>
---@type AvanteLLMToolFunc<{ path: string, old_str: string, new_str: string, streaming?: boolean, tool_use_id?: string }>
function M.func(opts, on_log, on_complete, session_ctx)
local replace_in_file = require("avante.llm_tools.replace_in_file")
local diff = "<<<<<<< SEARCH\n" .. opts.old_str .. "\n=======\n" .. opts.new_str .. "\n>>>>>>> REPLACE"
local diff = "<<<<<<< SEARCH\n" .. opts.old_str .. "\n=======\n" .. opts.new_str
if not opts.streaming then diff = diff .. "\n>>>>>>> REPLACE" end
local new_opts = {
path = opts.path,
diff = diff,
streaming = opts.streaming,
tool_use_id = opts.tool_use_id,
}
return replace_in_file.func(new_opts, on_log, on_complete, session_ctx)
end