feat: claude text editor tool (#1631)

This commit is contained in:
yetone
2025-03-19 00:09:49 +08:00
committed by GitHub
parent a8baee4354
commit 191d7b8783
11 changed files with 308 additions and 45 deletions

View File

@@ -1,6 +1,7 @@
local Utils = require("avante.utils")
local Clipboard = require("avante.clipboard")
local P = require("avante.providers")
local Config = require("avante.config")
---@class AvanteProviderFunctor
local M = {}
@@ -343,6 +344,20 @@ function M:parse_curl_args(prompt_opts)
end
end
if prompt_opts.tools and Config.behaviour.enable_claude_text_editor_tool_mode then
if provider_conf.model:match("claude%-3%-7%-sonnet") then
table.insert(tools, {
type = "text_editor_20250124",
name = "str_replace_editor",
})
elseif provider_conf.model:match("claude%-3%-5%-instruct") then
table.insert(tools, {
type = "text_editor_20241022",
name = "str_replace_editor",
})
end
end
if self.support_prompt_caching and #tools > 0 then
local last_tool = vim.deepcopy(tools[#tools])
last_tool.cache_control = { type = "ephemeral" }