diff --git a/CHANGELOG.md b/CHANGELOG.md index ac0ca40..e311be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to the "claude-dev" extension will be documented in this fil +## [1.2.0] + +- Add support for Prompt Caching to significantly reduce costs and response times (currently only available through Anthropic API for Claude 3.5 Sonnet and Claude 3.0 Haiku) + ## [1.1.1] - Adds option to choose other Claude models (+ GPT-4o, DeepSeek, and Mistral if you use OpenRouter) diff --git a/package.json b/package.json index a0811a3..bb06610 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "claude-dev", "displayName": "Claude Dev", "description": "Autonomous software engineer right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.", - "version": "1.1.15", + "version": "1.2.0", "icon": "icon.png", "engines": { "vscode": "^1.84.0" diff --git a/src/ClaudeDev.ts b/src/ClaudeDev.ts index e1c1eeb..dbcee19 100644 --- a/src/ClaudeDev.ts +++ b/src/ClaudeDev.ts @@ -417,12 +417,12 @@ export class ClaudeDev { cacheCreationInputTokens?: number, cacheReadInputTokens?: number ): number { - const modelCacheWritesPrice = this.api.getModel().info.cacheWrites + const modelCacheWritesPrice = this.api.getModel().info.cacheWritesPrice let cacheWritesCost = 0 if (cacheCreationInputTokens && modelCacheWritesPrice) { cacheWritesCost = (modelCacheWritesPrice / 1_000_000) * cacheCreationInputTokens } - const modelCacheReadsPrice = this.api.getModel().info.cacheReads + const modelCacheReadsPrice = this.api.getModel().info.cacheReadsPrice let cacheReadsCost = 0 if (cacheReadInputTokens && modelCacheReadsPrice) { cacheReadsCost = (modelCacheReadsPrice / 1_000_000) * cacheReadInputTokens diff --git a/src/providers/ClaudeDevProvider.ts b/src/providers/ClaudeDevProvider.ts index fb04877..884e690 100644 --- a/src/providers/ClaudeDevProvider.ts +++ b/src/providers/ClaudeDevProvider.ts @@ -25,7 +25,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider { private disposables: vscode.Disposable[] = [] private view?: vscode.WebviewView | vscode.WebviewPanel private claudeDev?: ClaudeDev - private latestAnnouncementId = "aug-11-2024" // update to some unique identifier when we add a new announcement + private latestAnnouncementId = "aug-15-2024" // update to some unique identifier when we add a new announcement constructor( private readonly context: vscode.ExtensionContext, diff --git a/src/shared/api.ts b/src/shared/api.ts index 82ec5b2..563fc10 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -21,8 +21,8 @@ export interface ModelInfo { supportsPromptCache: boolean inputPrice: number outputPrice: number - cacheWrites?: number - cacheReads?: number + cacheWritesPrice?: number + cacheReadsPrice?: number } export type ApiModelId = AnthropicModelId | OpenRouterModelId | BedrockModelId @@ -38,8 +38,8 @@ export const anthropicModels = { supportsPromptCache: true, inputPrice: 3.0, // $3 per million input tokens outputPrice: 15.0, // $15 per million output tokens - cacheWrites: 3.75, // $3.75 per million tokens - cacheReads: 0.3, // $0.30 per million tokens + cacheWritesPrice: 3.75, // $3.75 per million tokens + cacheReadsPrice: 0.3, // $0.30 per million tokens }, "claude-3-opus-20240229": { maxTokens: 4096, @@ -47,8 +47,8 @@ export const anthropicModels = { supportsPromptCache: false, inputPrice: 15.0, outputPrice: 75.0, - cacheWrites: 18.75, - cacheReads: 1.5, + cacheWritesPrice: 18.75, + cacheReadsPrice: 1.5, }, "claude-3-sonnet-20240229": { maxTokens: 4096, @@ -63,8 +63,8 @@ export const anthropicModels = { supportsPromptCache: true, inputPrice: 0.25, outputPrice: 1.25, - cacheWrites: 0.3, - cacheReads: 0.03, + cacheWritesPrice: 0.3, + cacheReadsPrice: 0.03, }, } as const satisfies Record // as const assertion makes the object deeply readonly diff --git a/webview-ui/src/components/Announcement.tsx b/webview-ui/src/components/Announcement.tsx index f8dd28f..9830ba7 100644 --- a/webview-ui/src/components/Announcement.tsx +++ b/webview-ui/src/components/Announcement.tsx @@ -27,18 +27,25 @@ const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => { 🎉{" "}New in v{version}

Follow me for more updates!{" "} diff --git a/webview-ui/src/components/ApiOptions.tsx b/webview-ui/src/components/ApiOptions.tsx index 5232a83..826269e 100644 --- a/webview-ui/src/components/ApiOptions.tsx +++ b/webview-ui/src/components/ApiOptions.tsx @@ -215,13 +215,19 @@ const ModelInfoView = ({ modelInfo }: { modelInfo: ModelInfo }) => { }).format(price) } + const showPromptCachingPrices = + modelInfo.supportsPromptCache && modelInfo.cacheWritesPrice && modelInfo.cacheReadsPrice + return (

+ supportsLabel="Supports prompt caching" + doesNotSupportLabel="Does not support prompt caching" + />{" "} + + (what is this?) +
{
Max output: {modelInfo.maxTokens.toLocaleString()} tokens
- Input price: {formatPrice(modelInfo.inputPrice)} per million tokens + + {showPromptCachingPrices ? "Base input price:" : "Input price:"} + {" "} + {formatPrice(modelInfo.inputPrice)} per million tokens + {showPromptCachingPrices && ( + <> +
+ Prompt caching write price:{" "} + {formatPrice(modelInfo.cacheWritesPrice || 0)} per million tokens +
+ Prompt caching read price:{" "} + {formatPrice(modelInfo.cacheReadsPrice || 0)} per million tokens + + )}
Output price: {formatPrice(modelInfo.outputPrice)} per million tokens