From 5ea24f59fa64bc27ffb47b349d3d011b080a3f3c Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 17 Jul 2025 13:48:15 +0800 Subject: [PATCH] fix: clear useless parameters --- lua/avante/llm.lua | 4 ++-- lua/avante/llm_tools/attempt_completion.lua | 2 +- lua/avante/llm_tools/bash.lua | 2 +- lua/avante/llm_tools/edit_file.lua | 2 +- lua/avante/llm_tools/init.lua | 2 +- lua/avante/llm_tools/str_replace.lua | 2 +- lua/avante/llm_tools/write_to_file.lua | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index 038672a..a9dd1ac 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -830,12 +830,12 @@ function M._stream(opts) ---@type AvanteLLMToolFuncOpts local tool_use_opts = { session_ctx = opts.session_ctx, + tool_use_id = partial_tool_use.id, + streaming = partial_tool_use.state == "generating", } if partial_tool_use.state == "generating" and not is_edit_tool_use and not support_streaming then return end - if type(partial_tool_use.input) == "table" then tool_use_opts.tool_use_id = partial_tool_use.id end if partial_tool_use.state == "generating" then if type(partial_tool_use.input) == "table" then - tool_use_opts.streaming = true LLMTools.process_tool_use(prompt_opts.tools, partial_tool_use, tool_use_opts) end return diff --git a/lua/avante/llm_tools/attempt_completion.lua b/lua/avante/llm_tools/attempt_completion.lua index 5ddcbff..92ef524 100644 --- a/lua/avante/llm_tools/attempt_completion.lua +++ b/lua/avante/llm_tools/attempt_completion.lua @@ -3,7 +3,7 @@ local Config = require("avante.config") local Highlights = require("avante.highlights") local Line = require("avante.ui.line") ----@alias AttemptCompletionInput {result: string, command?: string, streaming?: boolean} +---@alias AttemptCompletionInput {result: string, command?: string} ---@class AvanteLLMTool local M = setmetatable({}, Base) diff --git a/lua/avante/llm_tools/bash.lua b/lua/avante/llm_tools/bash.lua index 52e8c1c..b40b04a 100644 --- a/lua/avante/llm_tools/bash.lua +++ b/lua/avante/llm_tools/bash.lua @@ -214,7 +214,7 @@ M.returns = { }, } ----@type AvanteLLMToolFunc<{ path: string, command: string, streaming?: boolean }> +---@type AvanteLLMToolFunc<{ path: string, command: string }> function M.func(input, opts) local is_streaming = opts.streaming or false if is_streaming then diff --git a/lua/avante/llm_tools/edit_file.lua b/lua/avante/llm_tools/edit_file.lua index eb0ca64..8534431 100644 --- a/lua/avante/llm_tools/edit_file.lua +++ b/lua/avante/llm_tools/edit_file.lua @@ -51,7 +51,7 @@ M.returns = { }, } ----@type AvanteLLMToolFunc<{ target_file: string, instructions: string, code_edit: string, streaming?: boolean, tool_use_id?: string }> +---@type AvanteLLMToolFunc<{ target_file: string, instructions: string, code_edit: string }> M.func = vim.schedule_wrap(function(input, opts) local on_complete = opts.on_complete if not on_complete then return false, "on_complete not provided" end diff --git a/lua/avante/llm_tools/init.lua b/lua/avante/llm_tools/init.lua index fbc61f2..8d5ffcd 100644 --- a/lua/avante/llm_tools/init.lua +++ b/lua/avante/llm_tools/init.lua @@ -31,7 +31,7 @@ function M.str_replace_editor(input, opts) return M.str_replace_based_edit_tool(input, opts) end ----@type AvanteLLMToolFunc<{ command: "view" | "str_replace" | "create" | "insert", path: string, old_str?: string, new_str?: string, file_text?: string, insert_line?: integer, new_str?: string, view_range?: integer[], streaming?: boolean }> +---@type AvanteLLMToolFunc<{ command: "view" | "str_replace" | "create" | "insert", path: string, old_str?: string, new_str?: string, file_text?: string, insert_line?: integer, new_str?: string, view_range?: integer[] }> function M.str_replace_based_edit_tool(input, opts) local on_log = opts.on_log local on_complete = opts.on_complete diff --git a/lua/avante/llm_tools/str_replace.lua b/lua/avante/llm_tools/str_replace.lua index f5f78e9..9a1cdc6 100644 --- a/lua/avante/llm_tools/str_replace.lua +++ b/lua/avante/llm_tools/str_replace.lua @@ -53,7 +53,7 @@ M.returns = { }, } ----@type AvanteLLMToolFunc<{ path: string, old_str: string, new_str: string, streaming?: boolean, tool_use_id?: string }> +---@type AvanteLLMToolFunc<{ path: string, old_str: string, new_str: string }> function M.func(input, opts) local replace_in_file = require("avante.llm_tools.replace_in_file") local diff = "------- SEARCH\n" .. input.old_str .. "\n=======\n" .. input.new_str diff --git a/lua/avante/llm_tools/write_to_file.lua b/lua/avante/llm_tools/write_to_file.lua index 076ef09..ccbef83 100644 --- a/lua/avante/llm_tools/write_to_file.lua +++ b/lua/avante/llm_tools/write_to_file.lua @@ -58,7 +58,7 @@ M.returns = { } --- IMPORTANT: Using "the_content" instead of "content" is to avoid LLM streaming generating function parameters in alphabetical order, which would result in generating "path" after "content", making it impossible to achieve a stream diff view. ----@type AvanteLLMToolFunc<{ path: string, content: string, the_content?: string, streaming?: boolean, tool_use_id?: string }> +---@type AvanteLLMToolFunc<{ path: string, content: string, the_content?: string }> function M.func(input, opts) if input.the_content ~= nil then input.content = input.the_content