From 421e1972ad901acbd987229bcfa0e1ffae10d553 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Tue, 11 Mar 2025 00:43:18 -0400 Subject: [PATCH] Add prompt caching to OpenAI-compatible custom model info --- .changeset/thin-fans-deliver.md | 5 + .../src/components/settings/ApiOptions.tsx | 114 +++++++++++++++++- 2 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 .changeset/thin-fans-deliver.md diff --git a/.changeset/thin-fans-deliver.md b/.changeset/thin-fans-deliver.md new file mode 100644 index 0000000000..5244b7d0d7 --- /dev/null +++ b/.changeset/thin-fans-deliver.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Add prompt caching to OpenAI-compatible custom model info diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 656a6831cb..049292767f 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -819,7 +819,7 @@ const ApiOptions = ({ style={{ fontSize: "12px" }} /> -
+
Is this model capable of processing and understanding images?
@@ -842,11 +842,34 @@ const ApiOptions = ({ style={{ fontSize: "12px" }} /> -
+
Is this model capable of interacting with a browser? (e.g. Claude 3.7 Sonnet).
+
+
+ { + return { + ...(apiConfiguration?.openAiCustomModelInfo || openAiModelInfoSaneDefaults), + supportsPromptCache: checked, + } + })}> + Prompt Caching + + +
+
+ Is this model capable of caching prompts? +
+
+
+ {apiConfiguration?.openAiCustomModelInfo?.supportsPromptCache && ( + <> +
+ { + const value = apiConfiguration?.openAiCustomModelInfo?.cacheReadsPrice + + if (!value && value !== 0) { + return "var(--vscode-input-border)" + } + + return value >= 0 + ? "var(--vscode-charts-green)" + : "var(--vscode-errorForeground)" + })(), + }} + onChange={handleInputChange("openAiCustomModelInfo", (e) => { + const value = (e.target as HTMLInputElement).value + const parsed = parseFloat(value) + + return { + ...(apiConfiguration?.openAiCustomModelInfo ?? + openAiModelInfoSaneDefaults), + cacheReadsPrice: isNaN(parsed) ? 0 : parsed, + } + })} + placeholder="e.g. 0.0001" + className="w-full"> +
+ Cache Reads Price + +
+
+
+
+ { + const value = apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice + + if (!value && value !== 0) { + return "var(--vscode-input-border)" + } + + return value >= 0 + ? "var(--vscode-charts-green)" + : "var(--vscode-errorForeground)" + })(), + }} + onChange={handleInputChange("openAiCustomModelInfo", (e) => { + const value = (e.target as HTMLInputElement).value + const parsed = parseFloat(value) + + return { + ...(apiConfiguration?.openAiCustomModelInfo ?? + openAiModelInfoSaneDefaults), + cacheWritesPrice: isNaN(parsed) ? 0 : parsed, + } + })} + placeholder="e.g. 0.00005" + className="w-full"> +
+ Cache Writes Price + +
+
+
+ + )} +