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:
@@ -829,7 +829,8 @@ func (s *knowledgeService) getSummary(ctx context.Context,
|
||||
"language": types.LanguageNameFromContext(ctx),
|
||||
})
|
||||
thinking := false
|
||||
summary, err := summaryModel.Chat(ctx, []chat.Message{
|
||||
modelCtx := types.WithLLMCallMetadata(ctx, "document_summary", "")
|
||||
summary, err := summaryModel.Chat(modelCtx, []chat.Message{
|
||||
{
|
||||
Role: "system",
|
||||
Content: summaryPrompt,
|
||||
@@ -1928,7 +1929,8 @@ func (s *knowledgeService) generateQuestionsWithContext(ctx context.Context,
|
||||
prompt = types.AppendCustomPromptInstructions(prompt, customInstructions, "question_generation")
|
||||
|
||||
thinking := false
|
||||
response, err := chatModel.Chat(ctx, []chat.Message{
|
||||
modelCtx := types.WithLLMCallMetadata(ctx, "question_generation", "")
|
||||
response, err := chatModel.Chat(modelCtx, []chat.Message{
|
||||
{
|
||||
Role: "user",
|
||||
Content: prompt,
|
||||
|
||||
Reference in New Issue
Block a user