Compare commits

...

1 Commits

Author SHA1 Message Date
Cline Evaluation ab149cb2a9 Fixing OpenAI compatible to support cache token display 2025-06-01 00:17:46 +05:30
3 changed files with 13 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
fixing token counting for xai provider
+4
View File
@@ -98,6 +98,10 @@ export class OpenAiHandler implements ApiHandler {
type: "usage",
inputTokens: chunk.usage.prompt_tokens || 0,
outputTokens: chunk.usage.completion_tokens || 0,
// @ts-ignore-next-line
cacheReadTokens: chunk.usage.prompt_tokens_details?.cached_tokens || 0,
// @ts-ignore-next-line
cacheWriteTokens: chunk.usage.prompt_cache_miss_tokens || 0,
}
}
}
@@ -141,10 +141,10 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
}, [apiConfiguration?.apiProvider, apiConfiguration?.openAiModelInfo])
const shouldShowPromptCacheInfo = () => {
return (
doesModelSupportPromptCache &&
((cacheReads !== undefined && cacheReads > 0) || (cacheWrites !== undefined && cacheWrites > 0))
)
// Hybrid logic: Show cache info if we have actual cache data,
// regardless of whether the model explicitly supports prompt cache.
// This allows OpenAI-compatible providers to show cache tokens.
return (cacheReads !== undefined && cacheReads > 0) || (cacheWrites !== undefined && cacheWrites > 0)
}
console.log("IS_DEV", { IS_DEV, isItTrue: IS_DEV === '"true"' })