feat(llm): add prompt-cache observability and wiki cache-friendly prompts
Normalize provider-specific cache counters into TokenUsage, propagate call purpose and prefix fingerprints through context for logging and Langfuse, and restructure wiki page-modify prompts with warmup/singleflight to improve prefix cache hit rates during reduce batches.
This commit is contained in:
@@ -785,7 +785,8 @@ Output only the scores, no explanations or additional text.`,
|
||||
// Each score line is ~15 tokens, add buffer for safety
|
||||
maxTokens := len(batch)*20 + 100
|
||||
|
||||
response, err := t.chatModel.Chat(ctx, messages, &chat.ChatOptions{
|
||||
modelCtx := types.WithLLMCallMetadata(ctx, "knowledge_search_rerank", "")
|
||||
response, err := t.chatModel.Chat(modelCtx, messages, &chat.ChatOptions{
|
||||
Temperature: 0.1, // Low temperature for consistent scoring
|
||||
MaxTokens: maxTokens,
|
||||
})
|
||||
|
||||
@@ -384,7 +384,8 @@ Web page content:
|
||||
},
|
||||
}
|
||||
|
||||
response, err := t.chatModel.Chat(ctx, messages, &chat.ChatOptions{
|
||||
modelCtx := types.WithLLMCallMetadata(ctx, "web_fetch_summary", "")
|
||||
response, err := t.chatModel.Chat(modelCtx, messages, &chat.ChatOptions{
|
||||
Temperature: 0.3,
|
||||
MaxTokens: 1024,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user