From 26369ca48b53e6cb9b89c068ab7c7d7ae37cad7e Mon Sep 17 00:00:00 2001 From: kinandan Date: Wed, 29 Jan 2025 17:35:31 +0530 Subject: [PATCH] Fixing anthropic model caching in roo-code --- src/api/providers/unbound.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/api/providers/unbound.ts b/src/api/providers/unbound.ts index 23e419c..921f07b 100644 --- a/src/api/providers/unbound.ts +++ b/src/api/providers/unbound.ts @@ -106,10 +106,20 @@ export class UnboundHandler implements ApiHandler, SingleCompletionHandler { } if (usage) { - yield { - type: "usage", - inputTokens: usage?.prompt_tokens || 0, - outputTokens: usage?.completion_tokens || 0, + if (this.getModel().id.startsWith("anthropic/")) { + yield { + type: "usage", + inputTokens: usage?.prompt_tokens || 0, + outputTokens: usage?.completion_tokens || 0, + cacheWriteTokens: (usage as any)?.cache_creation_input_tokens || 0, + cacheReadTokens: (usage as any)?.cache_read_input_tokens || 0, + } + } else { + yield { + type: "usage", + inputTokens: usage?.prompt_tokens || 0, + outputTokens: usage?.completion_tokens || 0, + } } } }