mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user