Changesets · Branches · Tags · Compare
| Changeset | cb8ecd666f0f20deb3c81b4a763e7b4a15f2c748f8283b55216d7fe04ea01d66 |
|---|---|
| Author | ferenci84 <ferenci84@gmail.com> · 2025-09-22 13:38 +02:00 |
| Committer | ferenci84 <ferenci84@gmail.com> · 2025-09-22 13:38 +02:00 |
| Parents | 26d9a21964a3 |
1 file changed
modified core/llm/llms/OpenRouter.ts +11 −6
| @@ -22,9 +22,7 @@ | ||
| 22 | 22 | private isAnthropicModel(model?: string): boolean { |
| 23 | 23 | if (!model) return false; |
| 24 | 24 | const modelLower = model.toLowerCase(); |
| 25 | - return ( | |
| 26 | - modelLower.includes("claude") || modelLower.includes("anthropic/claude") | |
| 27 | - ); | |
| 25 | + return modelLower.includes("claude"); | |
| 28 | 26 | } |
| 29 | 27 | |
| 30 | 28 | /** |
| @@ -69,12 +67,19 @@ | ||
| 69 | 67 | body = super.modifyChatBody(body); |
| 70 | 68 | |
| 71 | 69 | // Check if we should apply Anthropic caching |
| 72 | - if (!this.isAnthropicModel(body.model) || !this.cacheBehavior) { | |
| 70 | + if ( | |
| 71 | + !this.isAnthropicModel(body.model) || | |
| 72 | + (!this.cacheBehavior && !this.completionOptions.promptCaching) | |
| 73 | + ) { | |
| 73 | 74 | return body; |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | - const shouldCacheConversation = this.cacheBehavior.cacheConversation; | |
| 77 | - const shouldCacheSystemMessage = this.cacheBehavior.cacheSystemMessage; | |
| 77 | + const shouldCacheConversation = | |
| 78 | + this.cacheBehavior?.cacheConversation || | |
| 79 | + this.completionOptions.promptCaching; | |
| 80 | + const shouldCacheSystemMessage = | |
| 81 | + this.cacheBehavior?.cacheSystemMessage || | |
| 82 | + this.completionOptions.promptCaching; | |
| 78 | 83 | |
| 79 | 84 | if (!shouldCacheConversation && !shouldCacheSystemMessage) { |
| 80 | 85 | return body; |