mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Enable Gemini prompt caching by default (#3225)
This commit is contained in:
parent
4ce3e64027
commit
b0757c2d05
25 changed files with 50 additions and 45 deletions
5
.changeset/three-rings-approve.md
Normal file
5
.changeset/three-rings-approve.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"roo-cline": patch
|
||||
---
|
||||
|
||||
Enable Gemini prompt caching by default
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
2
src/exports/roo-code.d.ts
vendored
2
src/exports/roo-code.d.ts
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@
|
|||
}
|
||||
},
|
||||
"promptCaching": {
|
||||
"label": "प्रॉम्प्ट कैशिंग सक्षम करें",
|
||||
"description": "जब सक्षम किया जाता है, तो Roo लागत को कम करने के लिए प्रॉम्प्ट कैशिंग चालू के साथ इस मॉडल का उपयोग करेगा।"
|
||||
"label": "प्रॉम्प्ट कैशिंग अक्षम करें",
|
||||
"description": "जब चेक किया जाता है, तो Roo इस मॉडल के लिए प्रॉम्प्ट कैशिंग का उपयोग नहीं करेगा।"
|
||||
},
|
||||
"temperature": {
|
||||
"useCustom": "कस्टम तापमान का उपयोग करें",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@
|
|||
}
|
||||
},
|
||||
"promptCaching": {
|
||||
"label": "プロンプトキャッシングを有効化",
|
||||
"description": "有効にすると、Rooはコスト削減のためにプロンプトキャッシングを有効にしてこのモデルを使用します。"
|
||||
"label": "プロンプトキャッシュを無効化",
|
||||
"description": "チェックすると、Rooはこのモデルに対してプロンプトキャッシュを使用しません。"
|
||||
},
|
||||
"temperature": {
|
||||
"useCustom": "カスタム温度を使用",
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@
|
|||
}
|
||||
},
|
||||
"promptCaching": {
|
||||
"label": "프롬프트 캐싱 활성화",
|
||||
"description": "활성화하면 Roo는 비용 절감을 위해 프롬프트 캐싱을 켠 상태로 이 모델을 사용합니다."
|
||||
"label": "프롬프트 캐싱 비활성화",
|
||||
"description": "체크하면 Roo가 이 모델에 대해 프롬프트 캐싱을 사용하지 않습니다."
|
||||
},
|
||||
"temperature": {
|
||||
"useCustom": "사용자 정의 온도 사용",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@
|
|||
}
|
||||
},
|
||||
"promptCaching": {
|
||||
"label": "Включить кэширование подсказок",
|
||||
"description": "Если включено, Roo будет использовать эту модель с включенным кэшированием подсказок для снижения затрат."
|
||||
"label": "Отключить кэширование промптов",
|
||||
"description": "Если отмечено, Roo не будет использовать кэширование промптов для этой модели."
|
||||
},
|
||||
"temperature": {
|
||||
"useCustom": "Использовать пользовательскую температуру",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@
|
|||
}
|
||||
},
|
||||
"promptCaching": {
|
||||
"label": "启用提示词缓存",
|
||||
"description": "启用后 Roo 将使用提示词缓存功能以降低成本。"
|
||||
"label": "禁用提示词缓存",
|
||||
"description": "选中后,Roo 将不会为此模型使用提示词缓存。"
|
||||
},
|
||||
"temperature": {
|
||||
"useCustom": "使用自定义温度",
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@
|
|||
}
|
||||
},
|
||||
"promptCaching": {
|
||||
"label": "啟用提示快取",
|
||||
"description": "啟用後,Roo 將使用提示快取功能以降低成本。"
|
||||
"label": "停用提示詞快取",
|
||||
"description": "勾選後,Roo 將不會為此模型使用提示詞快取。"
|
||||
},
|
||||
"temperature": {
|
||||
"useCustom": "使用自訂溫度",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue