Enable Gemini prompt caching by default (#3225)

This commit is contained in:
Chris Estreich 2025-05-06 09:56:57 -07:00 committed by GitHub
parent 4ce3e64027
commit b0757c2d05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 50 additions and 45 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Enable Gemini prompt caching by default

View file

@ -418,7 +418,7 @@ export const providerSettingsSchema = z.object({
// Generic
includeMaxTokens: z.boolean().optional(),
reasoningEffort: reasoningEffortsSchema.optional(),
promptCachingEnabled: z.boolean().optional(),
promptCachingDisabled: z.boolean().optional(),
diffEnabled: z.boolean().optional(),
fuzzyMatchThreshold: z.number().optional(),
modelTemperature: z.number().nullish(),
@ -507,7 +507,7 @@ const providerSettingsRecord: ProviderSettingsRecord = {
// Generic
includeMaxTokens: undefined,
reasoningEffort: undefined,
promptCachingEnabled: undefined,
promptCachingDisabled: undefined,
diffEnabled: undefined,
fuzzyMatchThreshold: undefined,
modelTemperature: undefined,

View file

@ -291,7 +291,7 @@ describe("Caching Logic", () => {
apiKey: "test-key",
apiModelId: "gemini-1.5-flash-latest", // Use a model that supports caching
geminiApiKey: "test-key",
promptCachingEnabled: true, // Enable caching for these tests
promptCachingDisabled: false,
})
handlerWithCache["client"] = {
@ -309,8 +309,8 @@ describe("Caching Logic", () => {
} as any
})
it("should not use cache if promptCachingEnabled is false", async () => {
handlerWithCache["options"].promptCachingEnabled = false
it("should not use cache if promptCachingDisabled is true", async () => {
handlerWithCache["options"].promptCachingDisabled = true
const stream = handlerWithCache.createMessage(systemPrompt, mockMessagesLong, cacheKey)
for await (const _ of stream) {

View file

@ -93,7 +93,7 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
// https://ai.google.dev/gemini-api/docs/tokens?lang=node
const isCacheAvailable =
info.supportsPromptCache &&
this.options.promptCachingEnabled &&
!this.options.promptCachingDisabled &&
cacheKey &&
contentsLength > 4 * CONTEXT_CACHE_TOKEN_MINIMUM

View file

@ -94,7 +94,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
openAiMessages = convertToR1Format([{ role: "user", content: systemPrompt }, ...messages])
}
const isCacheAvailable = promptCache.supported && (!promptCache.optional || this.options.promptCachingEnabled)
const isCacheAvailable = promptCache.supported && (!promptCache.optional || !this.options.promptCachingDisabled)
// https://openrouter.ai/docs/features/prompt-caching
if (isCacheAvailable) {

View file

@ -127,7 +127,7 @@ type ProviderSettings = {
modelMaxThinkingTokens?: number | undefined
includeMaxTokens?: boolean | undefined
reasoningEffort?: ("low" | "medium" | "high") | undefined
promptCachingEnabled?: boolean | undefined
promptCachingDisabled?: boolean | undefined
diffEnabled?: boolean | undefined
fuzzyMatchThreshold?: number | undefined
modelTemperature?: (number | null) | undefined

View file

@ -128,7 +128,7 @@ type ProviderSettings = {
modelMaxThinkingTokens?: number | undefined
includeMaxTokens?: boolean | undefined
reasoningEffort?: ("low" | "medium" | "high") | undefined
promptCachingEnabled?: boolean | undefined
promptCachingDisabled?: boolean | undefined
diffEnabled?: boolean | undefined
fuzzyMatchThreshold?: number | undefined
modelTemperature?: (number | null) | undefined

View file

@ -434,7 +434,7 @@ export const providerSettingsSchema = z.object({
// Generic
includeMaxTokens: z.boolean().optional(),
reasoningEffort: reasoningEffortsSchema.optional(),
promptCachingEnabled: z.boolean().optional(),
promptCachingDisabled: z.boolean().optional(),
diffEnabled: z.boolean().optional(),
fuzzyMatchThreshold: z.number().optional(),
modelTemperature: z.number().nullish(),
@ -524,7 +524,7 @@ const providerSettingsRecord: ProviderSettingsRecord = {
// Generic
includeMaxTokens: undefined,
reasoningEffort: undefined,
promptCachingEnabled: undefined,
promptCachingDisabled: undefined,
diffEnabled: undefined,
fuzzyMatchThreshold: undefined,
modelTemperature: undefined,

View file

@ -16,8 +16,8 @@ export const PromptCachingControl = ({ apiConfiguration, setApiConfigurationFiel
<>
<div>
<VSCodeCheckbox
checked={apiConfiguration.promptCachingEnabled}
onChange={(e: any) => setApiConfigurationField("promptCachingEnabled", e.target.checked)}>
checked={apiConfiguration.promptCachingDisabled}
onChange={(e: any) => setApiConfigurationField("promptCachingDisabled", e.target.checked)}>
<label className="block font-medium mb-1">{t("settings:promptCaching.label")}</label>
</VSCodeCheckbox>
<div className="text-sm text-vscode-descriptionForeground mt-1">

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Habilitar emmagatzematge en caché de prompts",
"description": "Quan està habilitat, Roo utilitzarà aquest model amb la memòria cau de prompts activada per reduir costos."
"label": "Desactivar la memòria cau de prompts",
"description": "Quan està marcat, Roo no utilitzarà la memòria cau de prompts per a aquest model."
},
"temperature": {
"useCustom": "Utilitzar temperatura personalitzada",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Prompt-Caching aktivieren",
"description": "Wenn aktiviert, wird Roo dieses Modell mit aktiviertem Prompt-Caching verwenden, um Kosten zu reduzieren."
"label": "Prompt-Caching deaktivieren",
"description": "Wenn aktiviert, wird Roo für dieses Modell kein Prompt-Caching verwenden."
},
"temperature": {
"useCustom": "Benutzerdefinierte Temperatur verwenden",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Enable prompt caching",
"description": "When enabled, Roo will use this model with prompt caching turned on in order to reduce costs."
"label": "Disable prompt caching",
"description": "When checked, Roo will not use prompt caching for this model."
},
"temperature": {
"useCustom": "Use custom temperature",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Habilitar caché de prompts",
"description": "Cuando está habilitado, Roo usará este modelo con el caché de prompts activado para reducir costos."
"label": "Desactivar caché de prompts",
"description": "Cuando está marcado, Roo no utilizará el caché de prompts para este modelo."
},
"temperature": {
"useCustom": "Usar temperatura personalizada",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Activer la mise en cache des prompts",
"description": "Lorsque cette option est activée, Roo utilisera ce modèle avec la mise en cache des prompts activée afin de réduire les coûts."
"label": "Désactiver la mise en cache des prompts",
"description": "Lorsque cette option est cochée, Roo n'utilisera pas la mise en cache des prompts pour ce modèle."
},
"temperature": {
"useCustom": "Utiliser une température personnalisée",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "प्रॉम्प्ट कैशिंग क्षम करें",
"description": "जब सक्षम किया जाता है, तो Roo लागत को कम करने के लिए प्रॉम्प्ट कैशिंग चालू के साथ इस मॉडल का उपयोग करेगा।"
"label": "प्रॉम्प्ट कैशिंग क्षम करें",
"description": "जब चेक किया जाता है, तो Roo इस मॉडल के लिए प्रॉम्प्ट कैशिंग का उपयोग नहीं करेगा।"
},
"temperature": {
"useCustom": "कस्टम तापमान का उपयोग करें",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Abilita cache dei prompt",
"description": "Quando abilitato, Roo utilizzerà questo modello con la cache dei prompt attivata per ridurre i costi."
"label": "Disattiva la cache dei prompt",
"description": "Quando selezionato, Roo non utilizzerà la cache dei prompt per questo modello."
},
"temperature": {
"useCustom": "Usa temperatura personalizzata",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "プロンプトキャッシングを有効化",
"description": "有効にすると、Rooはコスト削減のためにプロンプトキャッシングを有効にしてこのモデルを使用します。"
"label": "プロンプトキャッシュを無効化",
"description": "チェックすると、Rooはこのモデルに対してプロンプトキャッシュを使用しません。"
},
"temperature": {
"useCustom": "カスタム温度を使用",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "프롬프트 캐싱 활성화",
"description": "활성화하면 Roo는 비용 절감을 위해 프롬프트 캐싱을 켠 상태로 이 모델을 사용합니다."
"label": "프롬프트 캐싱 활성화",
"description": "체크하면 Roo가 이 모델에 대해 프롬프트 캐싱을 사용하지 않습니다."
},
"temperature": {
"useCustom": "사용자 정의 온도 사용",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Włącz buforowanie podpowiedzi",
"description": "Po włączeniu, Roo będzie używać tego modelu z włączonym buforowaniem promptów w celu zmniejszenia kosztów."
"label": "Wyłącz buforowanie promptów",
"description": "Po zaznaczeniu, Roo nie będzie używać buforowania promptów dla tego modelu."
},
"temperature": {
"useCustom": "Użyj niestandardowej temperatury",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Ativar cache de prompts",
"description": "Quando ativado, o Roo usará este modelo com o cache de prompts ativado para reduzir custos."
"label": "Desativar cache de prompts",
"description": "Quando marcado, o Roo não usará o cache de prompts para este modelo."
},
"temperature": {
"useCustom": "Usar temperatura personalizada",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Включить кэширование подсказок",
"description": "Если включено, Roo будет использовать эту модель с включенным кэшированием подсказок для снижения затрат."
"label": "Отключить кэширование промптов",
"description": "Если отмечено, Roo не будет использовать кэширование промптов для этой модели."
},
"temperature": {
"useCustom": "Использовать пользовательскую температуру",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Prompt önbelleğini etkinleştir",
"description": "Etkinleştirildiğinde, Roo maliyetleri azaltmak için prompt önbelleği açık olan bu modeli kullanacaktır."
"label": "Prompt önbelleğini devre dışı bırak",
"description": "İşaretlendiğinde, Roo bu model için prompt önbelleğini kullanmayacaktır."
},
"temperature": {
"useCustom": "Özel sıcaklık kullan",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "Bật bộ nhớ đệm prompt",
"description": "Khi được bật, Roo sẽ sử dụng mô hình này với bộ nhớ đệm prompt được bật để giảm chi phí."
"label": "Tắt bộ nhớ đệm prompt",
"description": "Khi được chọn, Roo sẽ không sử dụng bộ nhớ đệm prompt cho mô hình này."
},
"temperature": {
"useCustom": "Sử dụng nhiệt độ tùy chỉnh",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "用提示词缓存",
"description": "启用后 Roo 将使用提示词缓存功能以降低成本。"
"label": "用提示词缓存",
"description": "选中后Roo 将不会为此模型使用提示词缓存。"
},
"temperature": {
"useCustom": "使用自定义温度",

View file

@ -416,8 +416,8 @@
}
},
"promptCaching": {
"label": "啟用提示快取",
"description": "啟用後Roo 將使用提示快取功能以降低成本。"
"label": "停用提示詞快取",
"description": "勾選後Roo 將不會為此模型使用提示詞快取。"
},
"temperature": {
"useCustom": "使用自訂溫度",