Compare commits

..

1 Commits

9 changed files with 7 additions and 302 deletions

View File

@ -60,7 +60,6 @@ For building binary if you wish to build from source, then `cargo` is required.
timeout = 30000, -- timeout in milliseconds
temperature = 0, -- adjust if needed
max_tokens = 4096,
reasoning_effort = "high" -- only supported for "o" models
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`

View File

@ -36,7 +36,7 @@ M._defaults = {
include_answer = "basic",
},
---@type WebSearchEngineProviderResponseBodyFormatter
format_response_body = function(body) return body.answer, nil end,
format_response_body = function(body) return body.anwser, nil end,
},
serpapi = {
api_key_name = "SERPAPI_API_KEY",
@ -200,7 +200,6 @@ M._defaults = {
temperature = 0,
max_tokens = 8000,
},
---@type AvanteSupportedProvider
["claude-opus"] = {
__inherited_from = "claude",
@ -314,12 +313,8 @@ M._defaults = {
files = {
add_current = "<leader>ac", -- Add current buffer to selected files
},
providers = {
show_provides = "<leader>ap", -- Show providers selector
},
},
windows = {
---@alias AvantePosition "right" | "left" | "top" | "bottom" | "smart"
position = "right",
wrap = true, -- similar to vim.o.wrap

View File

@ -68,11 +68,6 @@ H.keymaps = function()
vim.keymap.set("n", "<Plug>(AvanteToggleHint)", function() M.toggle.hint() end)
vim.keymap.set("n", "<Plug>(AvanteToggleSuggestion)", function() M.toggle.suggestion() end)
vim.keymap.set("n", "<Plug>(AvanteShowProviders)", function()
local sidebar = M.get()
if sidebar then sidebar:show_providers_selector() end
end, { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "<Plug>(AvanteConflictOurs)", function() Diff.choose("ours") end)
vim.keymap.set({ "n", "v" }, "<Plug>(AvanteConflictBoth)", function() Diff.choose("both") end)
vim.keymap.set({ "n", "v" }, "<Plug>(AvanteConflictTheirs)", function() Diff.choose("theirs") end)
@ -126,14 +121,6 @@ H.keymaps = function()
function() M.toggle.suggestion() end,
{ desc = "avante: toggle suggestion" }
)
Utils.safe_keymap_set("n", Config.mappings.show_providers, function()
local sidebar = M.get()
if sidebar then sidebar:show_providers_selector() end
end, {
desc = "avante: show providers selector",
noremap = true,
silent = true,
})
Utils.safe_keymap_set("n", Config.mappings.toggle.repomap, function() require("avante.repo_map").show() end, {
desc = "avante: display repo map",
noremap = true,

View File

@ -64,7 +64,6 @@ local DressingState = { winid = nil, input_winid = nil, input_bufnr = nil }
---@field __inherited_from? string
---@field temperature? number
---@field max_tokens? number
---@field reasoning_effort? string
---
---@class AvanteLLMUsage
---@field input_tokens number
@ -137,7 +136,6 @@ local DressingState = { winid = nil, input_winid = nil, input_bufnr = nil }
---@field gemini AvanteProviderFunctor
---@field cohere AvanteProviderFunctor
---@field bedrock AvanteBedrockProviderFunctor
local M = {}
---@class EnvironmentHandler

View File

@ -196,6 +196,10 @@ M.parse_messages = function(opts)
end
M.parse_response = function(ctx, data_stream, _, opts)
if data_stream:match('"%[DONE%]":') then
opts.on_stop({ reason = "complete" })
return
end
if data_stream:match('"delta":') then
---@type OpenAIChatResponse
local jsn = vim.json.decode(data_stream)
@ -223,7 +227,7 @@ M.parse_response = function(ctx, data_stream, _, opts)
end
ctx.last_think_content = choice.delta.reasoning
opts.on_chunk(choice.delta.reasoning)
elseif choice.delta.tool_calls and choice.delta.tool_calls ~= vim.NIL then
elseif choice.delta.tool_calls then
local tool_call = choice.delta.tool_calls[1]
if not ctx.tool_use_list then ctx.tool_use_list = {} end
if not ctx.tool_use_list[tool_call.index + 1] then
@ -270,7 +274,6 @@ M.parse_response_without_stream = function(data, _, opts)
end
end
local Log = require("avante.utils.log")
M.parse_curl_args = function(provider, prompt_opts)
local provider_conf, request_body = P.parse_config(provider)
local disable_tools = provider_conf.disable_tools or false
@ -279,20 +282,7 @@ M.parse_curl_args = function(provider, prompt_opts)
["Content-Type"] = "application/json",
}
<<<<<<< HEAD
-- Add appid header for baidu provider
if Config.provider == "baidu" then
local baidu_config = Config.get_provider("baidu")
if not baidu_config.appid or baidu_config.appid == "" then
error("Baidu provider requires 'appid' to be set in config")
end
headers["appid"] = baidu_config.appid
end
if P.env.require_api_key(base) then
=======
if P.env.require_api_key(provider_conf) then
>>>>>>> b6ae4dfe7fe443362f5f31d71797173ec12c2598
local api_key = provider.parse_api_key()
if api_key == nil then
error(Config.provider .. " API key is not set, please set it in your environment variable or config file")
@ -337,8 +327,6 @@ M.parse_curl_args = function(provider, prompt_opts)
tools = tools,
}, request_body),
}
-- 记录请求详细信息
Log.log_request(request.url, request.headers, request.body)
return request
end
return M

View File

@ -1081,76 +1081,6 @@ function Sidebar:on_mount(opts)
})
end
-- Add keymap to add current buffer while sidebar is open
if Config.mappings.providers and Config.mappings.providers.show_providers then
vim.keymap.set("n", Config.mappings.providers.show_providers, function()
local providers = require("avante.providers")
local current_provider = Config.provider
-- Create a new buffer
local bufnr = api.nvim_create_buf(false, true)
-- Set buffer content
local lines = {}
for provider, _ in pairs(providers) do
if provider == current_provider then
table.insert(lines, "> " .. provider .. " <")
else
table.insert(lines, " " .. provider)
end
end
api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
-- Create a floating window
local width = 40
local height = #lines
local win_opts = {
relative = "editor",
width = width,
height = height,
col = (vim.o.columns - width) / 2,
row = (vim.o.lines - height) / 2 - 1,
style = "minimal",
border = "rounded",
}
local winid = api.nvim_open_win(bufnr, true, win_opts)
-- Highlight current provider
api.nvim_buf_add_highlight(bufnr, -1, "AvanteProviderCurrent", 0, 0, -1)
-- Key mappings
local function move_selection(direction)
local cursor = api.nvim_win_get_cursor(winid)
local line = cursor[1]
if direction == "up" and line > 1 then
api.nvim_win_set_cursor(winid, { line - 1, 0 })
elseif direction == "down" and line < #lines then
api.nvim_win_set_cursor(winid, { line + 1, 0 })
end
end
local function select_provider()
local cursor = api.nvim_win_get_cursor(winid)
local line = cursor[1]
local selected_provider = lines[line]:match("%S+$")
if selected_provider and selected_provider ~= current_provider then providers.refresh(selected_provider) end
api.nvim_win_close(winid, true)
end
vim.keymap.set("n", "<Up>", function() move_selection("up") end, { buffer = bufnr })
vim.keymap.set("n", "<Down>", function() move_selection("down") end, { buffer = bufnr })
vim.keymap.set("n", "<CR>", select_provider, { buffer = bufnr })
vim.keymap.set("n", "q", function() api.nvim_win_close(winid, true) end, { buffer = bufnr })
end, {
desc = "avante: show providers selector",
noremap = true,
silent = true,
})
end
api.nvim_set_option_value("wrap", Config.windows.wrap, { win = self.result_container.winid })
local current_apply_extmark_id = nil
@ -1353,12 +1283,6 @@ end
--- Initialize the sidebar instance.
--- @return avante.Sidebar The Sidebar instance.
function Sidebar:initialize()
-- Add keymap to show providers selector
vim.keymap.set("n", "<leader>ap", function() self:show_providers_selector() end, { noremap = true, silent = true })
self.code.winid = api.nvim_get_current_win()
self.code.bufnr = api.nvim_get_current_buf()
self.code.selection = Utils.get_visual_selection_and_range()
self.code.winid = api.nvim_get_current_win()
self.code.bufnr = api.nvim_get_current_buf()
self.code.selection = Utils.get_visual_selection_and_range()
@ -2415,70 +2339,6 @@ function Sidebar:render(opts)
return self
end
function Sidebar:show_providers_selector()
local providers = require("avante.providers")
local current_provider = Config.provider
-- Create a new buffer
local bufnr = api.nvim_create_buf(false, true)
-- Set buffer content
local lines = {}
for provider, _ in pairs(providers) do
if provider == current_provider then
table.insert(lines, "> " .. provider .. " <")
else
table.insert(lines, " " .. provider)
end
end
api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
-- Create a floating window
local width = 40
local height = #lines
local win_opts = {
relative = "editor",
width = width,
height = height,
col = (vim.o.columns - width) / 2,
row = (vim.o.lines - height) / 2 - 1,
style = "minimal",
border = "rounded",
}
local winid = api.nvim_open_win(bufnr, true, win_opts)
-- Highlight current provider
api.nvim_buf_add_highlight(bufnr, -1, "AvanteProviderCurrent", 0, 0, -1)
-- Key mappings
local function move_selection(direction)
local cursor = api.nvim_win_get_cursor(winid)
local line = cursor[1]
if direction == "up" and line > 1 then
api.nvim_win_set_cursor(winid, { line - 1, 0 })
elseif direction == "down" and line < #lines then
api.nvim_win_set_cursor(winid, { line + 1, 0 })
end
end
local function select_provider()
local cursor = api.nvim_win_get_cursor(winid)
local line = cursor[1]
local selected_provider = lines[line]:match("%S+$")
if selected_provider and selected_provider ~= current_provider then providers.refresh(selected_provider) end
api.nvim_win_close(winid, true)
end
vim.keymap.set("n", "<Up>", function() move_selection("up") end, { buffer = bufnr })
vim.keymap.set("n", "<Down>", function() move_selection("down") end, { buffer = bufnr })
vim.keymap.set("n", "<CR>", select_provider, { buffer = bufnr })
vim.keymap.set("n", "q", function() api.nvim_win_close(winid, true) end, { buffer = bufnr })
end
function Sidebar:create_selected_files_container()
if self.selected_files_container then self.selected_files_container:unmount() end

View File

@ -1,31 +0,0 @@
local M = {}
--
-- local log_file = vim.fn.stdpath("cache") .. "/avante_requests.log"
local log_file = "/tmp/avante/avante_requests.log"
function M.log_request(url, headers, body)
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local log_entry = string.format(
[[
[%s] Request Details:
URL: %s
Headers:
%s
Body:
%s
]],
timestamp,
url,
vim.inspect(headers),
vim.inspect(body)
)
-- Append to log file
local file = io.open(log_file, "a")
if file then
file:write(log_entry .. "\n\n")
file:close()
end
end
return M

View File

@ -1,22 +0,0 @@
Failed to run `config` for avante.nvim
...share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/keys.lua:35: attempt to index local 'ret' (a nil value)
# stacktrace:
- /lazy.nvim/lua/lazy/core/util.lua:123 _in_ **__index**
- /lazy.nvim/lua/lazy/core/handler/keys.lua:35 _in_ **parse**
- /lazy.nvim/lua/lazy/core/handler/keys.lua:63 _in_ **have**
- /avante.nvim/lua/avante/utils/init.lua:163 _in_ **func**
- vim/shared.lua:274 _in_ **tbl_filter**
- /avante.nvim/lua/avante/utils/init.lua:163 _in_ **safe_keymap_set**
- /avante.nvim/lua/avante/init.lua:129 _in_ **keymaps**
- /avante.nvim/lua/avante/init.lua:386 _in_ **setup**
- /lazy.nvim/lua/lazy/core/loader.lua:387
- /lazy.nvim/lua/lazy/core/util.lua:135 _in_ **try**
- /lazy.nvim/lua/lazy/core/loader.lua:395 _in_ **config**
- /lazy.nvim/lua/lazy/core/loader.lua:362 _in_ **_load**
- /lazy.nvim/lua/lazy/core/loader.lua:197 _in_ **load**
- /lazy.nvim/lua/lazy/core/loader.lua:127 _in_ **startup**
- /lazy.nvim/lua/lazy/init.lua:112 _in_ **setup**
- ~/.config/nvim/lua/config/lazy.lua:17
- ~/.config/nvim/init.lua:2

View File

@ -1,69 +0,0 @@
.
├── autoload
│   └── avante.vim
├── Build.ps1
├── build.sh
├─ ─ Cargo.lock
├── Cargo.toml
├── crates
│   ├── avante-html2md
│   │   ├── Cargo.toml
│   │   └── src
│   ├── avante-repo-map
│   │   ├── Cargo.toml
│   │   ├── queries
│   │   └── src
│   ├── avante-templates
│   │   ├── Cargo.toml
│   │   └── src
│   └── avante-tokenizers
│   ├── Cargo.lock
│   ├── Cargo.toml
│   ├── README.md
│   └── src
├── LICENSE
├── lua
│   ├── avante
│   │   ├── api.lua
│   │   ├── clipboard.lua
│   │   ├── config.lua
│   │   ├── diff.lua
│   │   ├── file_selector.lua
│   │   ├── health.lua
│   │   ├── highlights.lua
│   │   ├── html2md.lua
│   │   ├── init.lua
│   │   ├── llm.lua
│   │   ├── llm_tools.lua
│   │   ├── path.lua
│   │   ├── prompt_input.lua
│   │   ├── providers
│   │   ├── range.lua
│   │   ├── repo_map.lua
│   │   ├── selection.lua
│   │   ├── selection_result.lua
│   │   ├── sidebar.lua
│   │   ├── suggestion.lua
│   │   ├── templates
│   │   ├── tokenizers.lua
│   │   ├── types.lua
│   │   └── utils
│   ├── avante_lib.lua
│   └── cmp_avante
│   ├── commands.lua
│   └── mentions.lua
├── Makefile
├── plugin
│   └── avante.lua
├── README.md
├── stylua.toml
├── syntax
│   └── jinja.vim
├── tests
│   ├── llm_tools_spec.lua
│   └── utils
│   ├── file_spec.lua
│   └── init_spec.lua
└── tree.txt
21 directories, 45 files