fix: increase history max_tokens (#1609)
This commit is contained in:
@@ -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