Skip to content

Commit 7788e25

Browse files
committed
cached-tokens
Signed-off-by: yxia216 <yxia216@bloomberg.net>
1 parent 55bb744 commit 7788e25

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

internal/translator/anthropic_helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,12 +1061,12 @@ func (p *anthropicStreamParser) handleAnthropicStreamEvent(eventType []byte, dat
10611061
if output, ok := usage.OutputTokens(); ok {
10621062
p.tokenUsage.AddOutputTokens(output)
10631063
}
1064-
// Update cache token details from delta (don't add to InputTokens — already included in message_start)
1064+
// Set (not add) cache token details from delta — message_start already set these once
10651065
if cached, ok := usage.CachedInputTokens(); ok {
1066-
p.tokenUsage.AddCachedInputTokens(cached)
1066+
p.tokenUsage.SetCachedInputTokens(cached)
10671067
}
10681068
if cacheCreation, ok := usage.CacheCreationInputTokens(); ok {
1069-
p.tokenUsage.AddCacheCreationInputTokens(cacheCreation)
1069+
p.tokenUsage.SetCacheCreationInputTokens(cacheCreation)
10701070
}
10711071
p.tokenUsage.SetReasoningTokens(uint32(u.OutputTokensDetails.ThinkingTokens)) //nolint:gosec
10721072
if event.Delta.StopReason != "" {

0 commit comments

Comments
 (0)