fix: improve cost tracking accuracy for modern models
- Added support for reasoning tokens in cost calculations. - Fixed DeepSeek cache-write token mapping (PromptCacheMissTokens). - Improved CalculateCost debug logging to trace all pricing variables.
This commit is contained in:
@@ -378,9 +378,9 @@ func (s *Server) logRequest(start time.Time, clientID, provider, model string, u
|
||||
}
|
||||
|
||||
// Calculate cost using registry
|
||||
entry.Cost = utils.CalculateCost(s.registry, model, entry.PromptTokens, entry.CompletionTokens, entry.CacheReadTokens, entry.CacheWriteTokens)
|
||||
fmt.Printf("[DEBUG] Request logged: model=%s, prompt=%d, completion=%d, cache_read=%d, cost=%f\n",
|
||||
model, entry.PromptTokens, entry.CompletionTokens, entry.CacheReadTokens, entry.Cost)
|
||||
entry.Cost = utils.CalculateCost(s.registry, model, entry.PromptTokens, entry.CompletionTokens, entry.ReasoningTokens, entry.CacheReadTokens, entry.CacheWriteTokens)
|
||||
fmt.Printf("[DEBUG] Request logged: model=%s, prompt=%d, completion=%d, reasoning=%d, cache_read=%d, cost=%f\n",
|
||||
model, entry.PromptTokens, entry.CompletionTokens, entry.ReasoningTokens, entry.CacheReadTokens, entry.Cost)
|
||||
}
|
||||
|
||||
s.logger.LogRequest(entry)
|
||||
|
||||
Reference in New Issue
Block a user