feat: disable tools with config (#1459)

* chore: use missing generic for AvanteLLMToolFunc

* feat: add disabled_tools config
This commit is contained in:
Peter Cardenas
2025-03-01 19:29:23 -08:00
committed by GitHub
parent e471f2347b
commit ac9d2b3888
3 changed files with 5 additions and 3 deletions

View File

@@ -408,6 +408,7 @@ M._defaults = {
debounce = 600,
throttle = 600,
},
disabled_tools = {}, ---@type string[]
}
---@type avante.Config

View File

@@ -569,7 +569,9 @@ end
function M.get_tools()
return vim
.iter(M._tools)
:filter(function(tool)
:filter(function(tool) ---@param tool AvanteLLMTool
-- Always disable tools that are explicitly disabled
if vim.tbl_contains(Config.disabled_tools, tool.name) then return false end
if tool.enabled == nil then
return true
else

View File

@@ -2317,8 +2317,7 @@ function Sidebar:create_input_container(opts)
table.insert(tools, {
name = "remove_file_from_context",
description = "Remove a file from the context",
---@param input { rel_path: string }
---@type AvanteLLMToolFunc
---@type AvanteLLMToolFunc<{ rel_path: string }>
func = function(input)
self.file_selector:remove_selected_file(input.rel_path)
return "Removed file from context", nil