Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thin-fans-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": patch
---

Add prompt caching to OpenAI-compatible custom model info
94 changes: 94 additions & 0 deletions webview-ui/src/components/settings/ApiOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,29 @@ const ApiOptions = ({
</div>
</div>

<div>
<div className="flex items-center gap-1">
<Checkbox
checked={apiConfiguration?.openAiCustomModelInfo?.supportsPromptCache ?? false}
onChange={handleInputChange("openAiCustomModelInfo", (checked) => {
return {
...(apiConfiguration?.openAiCustomModelInfo || openAiModelInfoSaneDefaults),
supportsPromptCache: checked,
}
})}>
<span className="font-medium">Prompt Caching</span>
</Checkbox>
<i
className="codicon codicon-info text-vscode-descriptionForeground"
title="Enable if the model supports prompt caching. This can improve performance and reduce costs."
style={{ fontSize: "12px" }}
/>
</div>
<div className="text-sm text-vscode-descriptionForeground [pt">
Is this model capable of caching prompts?
</div>
</div>

<div>
<VSCodeTextField
value={
Expand Down Expand Up @@ -933,6 +956,77 @@ const ApiOptions = ({
</VSCodeTextField>
</div>

{apiConfiguration?.openAiCustomModelInfo?.supportsPromptCache && (
<>
<div>
<VSCodeTextField
value={
apiConfiguration?.openAiCustomModelInfo?.cacheReadsPrice?.toString() ?? "0"
}
type="text"
className={cn("w-full", {
"border-vscode-input": !apiConfiguration?.openAiCustomModelInfo?.cacheReadsPrice && apiConfiguration?.openAiCustomModelInfo?.cacheReadsPrice !== 0,
"border-vscode-green": apiConfiguration?.openAiCustomModelInfo?.cacheReadsPrice >= 0,
"border-vscode-error": apiConfiguration?.openAiCustomModelInfo?.cacheReadsPrice < 0,
})}
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">
<div className="flex items-center gap-1">
<span className="font-medium">Cache Reads Price</span>
<i
className="codicon codicon-info text-vscode-descriptionForeground"
title="Cost per million tokens for reading from the cache. This is the price charged when a cached response is retrieved."
style={{ fontSize: "12px" }}
/>
</div>
</VSCodeTextField>
</div>
<div>
<VSCodeTextField
value={
apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice?.toString() ?? "0"
}
type="text"
className={cn("w-full", {
"border-vscode-input": !apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice && apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice !== 0,
"border-vscode-green": apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice >= 0,
"border-vscode-error": apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice < 0,
})}
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">
<div className="flex items-center gap-1">
<span className="font-medium">Cache Writes Price</span>
<i
className="codicon codicon-info text-vscode-descriptionForeground"
title="Cost per million tokens for writing to the cache. This is the price charged when a prompt is cached for the first time."
style={{ fontSize: "12px" }}
/>
</div>
</VSCodeTextField>
</div>
</>
)}

<Button
variant="secondary"
onClick={() =>
Expand Down
12 changes: 12 additions & 0 deletions webview-ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@
border-color: var(--border);
}

.border-vscode-input {
border-color: var(--vscode-input-border);
}

.border-vscode-green {
border-color: var(--vscode-charts-green);
}

.border-vscode-error {
border-color: var(--vscode-errorForeground);
}

/* Code Block Styles */
pre,
code {
Expand Down