chore: fix remaining linting issues in caching code

- Use max() built-in instead of if statement (modernize)
- Remove unused buildAnthropicCacheOptions function
- Remove unused anthropic import
This commit is contained in:
Ed Zynda
2026-03-29 14:32:28 +03:00
parent 6a599d86af
commit bca08476de
2 changed files with 1 additions and 15 deletions
+1 -4
View File
@@ -45,10 +45,7 @@ func applyCacheControlToMessages(messages []fantasy.Message) []fantasy.Message {
}
// Apply cache control to the last 2 messages
startIdx := len(result) - 2
if startIdx < 0 {
startIdx = 0
}
startIdx := max(len(result)-2, 0)
for i := startIdx; i < len(result); i++ {
// Only apply if not already set (avoid double-setting system message)
if i != lastSystemIdx {
-11
View File
@@ -7,7 +7,6 @@ import (
"os"
"charm.land/fantasy"
"charm.land/fantasy/providers/anthropic"
"charm.land/fantasy/providers/openai"
)
@@ -44,16 +43,6 @@ func buildCacheProviderOptions(modelInfo *ModelInfo, config *ProviderConfig) fan
}
}
// buildAnthropicCacheOptions enables ephemeral caching for Anthropic models.
// Used for message-level caching to avoid provider-level type conflicts.
func buildAnthropicCacheOptions() fantasy.ProviderOptions {
return anthropic.NewProviderCacheControlOptions(&anthropic.ProviderCacheControlOptions{
CacheControl: anthropic.CacheControl{
Type: "ephemeral",
},
})
}
// buildOpenAICacheOptions enables prompt caching for OpenAI models.
// Uses a deterministic cache key based on system prompt and model ID.
func buildOpenAICacheOptions(config *ProviderConfig, modelID string) fantasy.ProviderOptions {