From ae1e85e166a7e2849ea35aa04efa0769caae6ff7 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Sun, 20 Oct 2024 02:38:25 +0000 Subject: [PATCH] Update Anthropic token counting logic --- pkg/api/provider/anthropic/anthropic.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/api/provider/anthropic/anthropic.go b/pkg/api/provider/anthropic/anthropic.go index 4da2ae3..e471959 100644 --- a/pkg/api/provider/anthropic/anthropic.go +++ b/pkg/api/provider/anthropic/anthropic.go @@ -353,7 +353,8 @@ func (c *AnthropicClient) CreateChatCompletionStream( block.Text += text output <- provider.Chunk{ Content: text, - TokenCount: 1, + // rough, anthropic performs some chunking + TokenCount: uint(len(strings.Split(text, " "))), } } case "input_json_delta":