From 505e7ea481141cd8580177485264e6760937d4cc Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:10:17 -0800 Subject: [PATCH] Fix deepseek price reporting --- src/api/providers/deepseek.ts | 6 +++--- src/api/providers/openrouter.ts | 4 ---- src/core/webview/ClineProvider.ts | 5 ----- src/shared/api.ts | 6 +++--- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/api/providers/deepseek.ts b/src/api/providers/deepseek.ts index 48afab68ba..0cadd57200 100644 --- a/src/api/providers/deepseek.ts +++ b/src/api/providers/deepseek.ts @@ -39,12 +39,12 @@ export class DeepSeekHandler implements ApiHandler { if (chunk.usage) { yield { type: "usage", - inputTokens: 0, //chunk.usage.prompt_tokens || 0, (deepseek reports total input AND cache reads/writes, see context caching: https://api-docs.deepseek.com/guides/kv_cache) + inputTokens: chunk.usage.prompt_tokens || 0, // (deepseek reports total input AND cache reads/writes, see context caching: https://api-docs.deepseek.com/guides/kv_cache) but we use this to do the truncation algo, so we can't report cache stats right now because of how deepseek api reports input AND the cache reads/writes, while anthropic reports them as separate tokens outputTokens: chunk.usage.completion_tokens || 0, // @ts-ignore-next-line - cacheReadTokens: chunk.usage.prompt_cache_hit_tokens || 0, + // cacheReadTokens: chunk.usage.prompt_cache_hit_tokens || 0, // @ts-ignore-next-line - cacheWriteTokens: chunk.usage.prompt_cache_miss_tokens || 0, + // cacheWriteTokens: chunk.usage.prompt_cache_miss_tokens || 0, } } } diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index ccdde6c378..8170d41afc 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -98,10 +98,6 @@ export class OpenRouterHandler implements ApiHandler { // Removes messages in the middle when close to context window limit. Should not be applied to models that support prompt caching since it would continuously break the cache. let shouldApplyMiddleOutTransform = !this.getModel().info.supportsPromptCache - // except for deepseek (which we set supportsPromptCache to true for), where because the context window is so small our truncation algo might miss and we should use openrouter's middle-out transform as a fallback to ensure we don't exceed the context window - if (this.getModel().id === "deepseek/deepseek-chat") { - shouldApplyMiddleOutTransform = true - } // @ts-ignore-next-line const stream = await this.client.chat.completions.create({ diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 4081e617dd..78cc71b460 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -726,11 +726,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { modelInfo.cacheWritesPrice = 0.3 modelInfo.cacheReadsPrice = 0.03 break - case "deepseek/deepseek-chat": - modelInfo.supportsPromptCache = true - modelInfo.cacheWritesPrice = 0.14 - modelInfo.cacheReadsPrice = 0.014 - break } models[rawModel.id] = modelInfo diff --git a/src/shared/api.ts b/src/shared/api.ts index 578b1083e1..5f2b42b416 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -359,10 +359,10 @@ export const deepSeekModels = { maxTokens: 8_000, contextWindow: 64_000, supportsImages: false, - supportsPromptCache: true, + supportsPromptCache: false, // technically supports context caching, but not in the way anthropic does it (deepseek reports input tokens and reads/writes in the same usage report) FIXME: we need to show users cache stats how deepseek does it inputPrice: 0.14, outputPrice: 0.28, - cacheWritesPrice: 0.14, - cacheReadsPrice: 0.014, + // cacheWritesPrice: 0.14, + // cacheReadsPrice: 0.014, }, } as const satisfies Record