Update Anthropic token counting logic

This commit is contained in:
Matt Low 2024-10-20 02:38:25 +00:00
parent 304820c919
commit ae1e85e166

View File

@ -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":