From 662b6a547b2214232e7ff9e2dd3ba15fc22ca75a Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 6 Mar 2025 00:08:59 +0800 Subject: [PATCH] fix: cache prompt count (#1499) --- lua/avante/providers/claude.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/avante/providers/claude.lua b/lua/avante/providers/claude.lua index a834597..1ba2135 100644 --- a/lua/avante/providers/claude.lua +++ b/lua/avante/providers/claude.lua @@ -49,9 +49,9 @@ function M.parse_messages(opts) table.sort(messages_with_length, function(a, b) return a.length > b.length end) ---@type table - local top_three = {} - for i = 1, math.min(3, #messages_with_length) do - top_three[messages_with_length[i].idx] = true + local top_two = {} + for i = 1, math.min(2, #messages_with_length) do + top_two[messages_with_length[i].idx] = true end for idx, message in ipairs(opts.messages) do @@ -61,7 +61,7 @@ function M.parse_messages(opts) { type = "text", text = message.content, - cache_control = top_three[idx] and { type = "ephemeral" } or nil, + cache_control = top_two[idx] and { type = "ephemeral" } or nil, }, }, })