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