fix: increase history max_tokens (#1609)
This commit is contained in:
@@ -195,7 +195,7 @@ M._defaults = {
|
|||||||
model = "gpt-4o",
|
model = "gpt-4o",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 16384,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
copilot = {
|
copilot = {
|
||||||
@@ -205,7 +205,7 @@ M._defaults = {
|
|||||||
allow_insecure = false, -- Allow insecure server connections
|
allow_insecure = false, -- Allow insecure server connections
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteAzureProvider
|
---@type AvanteAzureProvider
|
||||||
azure = {
|
azure = {
|
||||||
@@ -214,7 +214,7 @@ M._defaults = {
|
|||||||
api_version = "2024-06-01",
|
api_version = "2024-06-01",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
claude = {
|
claude = {
|
||||||
@@ -222,14 +222,14 @@ M._defaults = {
|
|||||||
model = "claude-3-7-sonnet-20250219",
|
model = "claude-3-7-sonnet-20250219",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
bedrock = {
|
bedrock = {
|
||||||
model = "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
model = "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
gemini = {
|
gemini = {
|
||||||
@@ -237,7 +237,7 @@ M._defaults = {
|
|||||||
model = "gemini-1.5-flash-latest",
|
model = "gemini-1.5-flash-latest",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
vertex = {
|
vertex = {
|
||||||
@@ -245,7 +245,7 @@ M._defaults = {
|
|||||||
model = "gemini-1.5-flash-002",
|
model = "gemini-1.5-flash-002",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
cohere = {
|
cohere = {
|
||||||
@@ -253,7 +253,7 @@ M._defaults = {
|
|||||||
model = "command-r-plus-08-2024",
|
model = "command-r-plus-08-2024",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
ollama = {
|
ollama = {
|
||||||
@@ -261,7 +261,7 @@ M._defaults = {
|
|||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
options = {
|
options = {
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
num_ctx = 10240,
|
num_ctx = 20480,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
@@ -270,7 +270,7 @@ M._defaults = {
|
|||||||
model = "claude-3-5-sonnet-v2@20241022",
|
model = "claude-3-5-sonnet-v2@20241022",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---To add support for custom provider, follow the format below
|
---To add support for custom provider, follow the format below
|
||||||
---See https://github.com/yetone/avante.nvim/wiki#custom-providers for more details
|
---See https://github.com/yetone/avante.nvim/wiki#custom-providers for more details
|
||||||
@@ -282,7 +282,7 @@ M._defaults = {
|
|||||||
model = "claude-3-5-haiku-20241022",
|
model = "claude-3-5-haiku-20241022",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
---@type AvanteSupportedProvider
|
---@type AvanteSupportedProvider
|
||||||
["claude-opus"] = {
|
["claude-opus"] = {
|
||||||
@@ -290,7 +290,7 @@ M._defaults = {
|
|||||||
model = "claude-3-opus-20240229",
|
model = "claude-3-opus-20240229",
|
||||||
timeout = 30000, -- Timeout in milliseconds
|
timeout = 30000, -- Timeout in milliseconds
|
||||||
temperature = 0,
|
temperature = 0,
|
||||||
max_tokens = 10240,
|
max_tokens = 20480,
|
||||||
},
|
},
|
||||||
["openai-gpt-4o-mini"] = {
|
["openai-gpt-4o-mini"] = {
|
||||||
__inherited_from = "openai",
|
__inherited_from = "openai",
|
||||||
@@ -340,7 +340,7 @@ M._defaults = {
|
|||||||
use_cwd_as_project_root = false,
|
use_cwd_as_project_root = false,
|
||||||
},
|
},
|
||||||
history = {
|
history = {
|
||||||
max_tokens = 4096,
|
max_tokens = 8192,
|
||||||
storage_path = vim.fn.stdpath("state") .. "/avante",
|
storage_path = vim.fn.stdpath("state") .. "/avante",
|
||||||
paste = {
|
paste = {
|
||||||
extension = "png",
|
extension = "png",
|
||||||
|
|||||||
@@ -2458,12 +2458,12 @@ function Sidebar:create_input_container(opts)
|
|||||||
|
|
||||||
if self.chat_history.memory then prompts_opts.memory = self.chat_history.memory.content end
|
if self.chat_history.memory then prompts_opts.memory = self.chat_history.memory.content end
|
||||||
|
|
||||||
if not summarize_memory or #history_messages < 8 then
|
if not summarize_memory or #history_messages < 12 then
|
||||||
cb(prompts_opts)
|
cb(prompts_opts)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
prompts_opts.history_messages = vim.list_slice(prompts_opts.history_messages, 5)
|
prompts_opts.history_messages = vim.list_slice(prompts_opts.history_messages, 7)
|
||||||
|
|
||||||
Llm.summarize_memory(self.code.bufnr, self.chat_history, function(memory)
|
Llm.summarize_memory(self.code.bufnr, self.chat_history, function(memory)
|
||||||
if memory then prompts_opts.memory = memory.content end
|
if memory then prompts_opts.memory = memory.content end
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
local Utils = require("avante.utils")
|
local Utils = require("avante.utils")
|
||||||
|
local Config = require("avante.config")
|
||||||
|
|
||||||
---@class avante.utils.history
|
---@class avante.utils.history
|
||||||
local M = {}
|
local M = {}
|
||||||
@@ -20,6 +21,7 @@ end
|
|||||||
---@param entries avante.ChatHistoryEntry[]
|
---@param entries avante.ChatHistoryEntry[]
|
||||||
---@return AvanteLLMMessage[]
|
---@return AvanteLLMMessage[]
|
||||||
function M.entries_to_llm_messages(entries)
|
function M.entries_to_llm_messages(entries)
|
||||||
|
local current_provider_name = Config.provider
|
||||||
local messages = {}
|
local messages = {}
|
||||||
for _, entry in ipairs(entries) do
|
for _, entry in ipairs(entries) do
|
||||||
if entry.selected_filepaths ~= nil and #entry.selected_filepaths > 0 then
|
if entry.selected_filepaths ~= nil and #entry.selected_filepaths > 0 then
|
||||||
@@ -41,7 +43,7 @@ function M.entries_to_llm_messages(entries)
|
|||||||
if entry.request ~= nil and entry.request ~= "" then
|
if entry.request ~= nil and entry.request ~= "" then
|
||||||
table.insert(messages, { role = "user", content = entry.request })
|
table.insert(messages, { role = "user", content = entry.request })
|
||||||
end
|
end
|
||||||
if entry.tool_histories ~= nil and #entry.tool_histories > 0 then
|
if entry.tool_histories ~= nil and #entry.tool_histories > 0 and entry.provider == current_provider_name then
|
||||||
for _, tool_history in ipairs(entry.tool_histories) do
|
for _, tool_history in ipairs(entry.tool_histories) do
|
||||||
local assistant_content = {}
|
local assistant_content = {}
|
||||||
if tool_history.tool_use ~= nil then
|
if tool_history.tool_use ~= nil then
|
||||||
|
|||||||
@@ -25,10 +25,8 @@ function Tokens.calculate_tokens(content)
|
|||||||
text = text .. item.text
|
text = text .. item.text
|
||||||
elseif type(item) == "table" and item.type == "image" then
|
elseif type(item) == "table" and item.type == "image" then
|
||||||
text = text .. item.source.data
|
text = text .. item.source.data
|
||||||
elseif type(item) == "table" and item.type == "tool_use" then
|
|
||||||
text = text .. item.name .. item.id
|
|
||||||
elseif type(item) == "table" and item.type == "tool_result" then
|
elseif type(item) == "table" and item.type == "tool_result" then
|
||||||
text = text .. item.tool_use_id .. item.content
|
text = text .. item.content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user