mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(logging): resolve cache_hit before hidden_params short-circuit in _response_cost_calculator
Cached responses carry response_cost in _hidden_params from the original call.
_response_cost_calculator was returning that pre-computed cost before checking
cache_hit, so cached responses were billed instead of returning 0.0.
Fix: move cache_hit resolution and early-return to top of the function.
Regression introduced in bdf01fa283 (fix mypy error).
This commit is contained in:
parent
8483477512
commit
ebd6d36cd9
1 changed files with 6 additions and 0 deletions
|
|
@ -1394,6 +1394,12 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
used for consistent cost calculation across response headers + logging integrations.
|
||||
"""
|
||||
|
||||
if cache_hit is None:
|
||||
cache_hit = self.model_call_details.get("cache_hit", False)
|
||||
|
||||
if cache_hit is True:
|
||||
return 0.0
|
||||
|
||||
if isinstance(result, BaseModel) and hasattr(result, "_hidden_params"):
|
||||
hidden_params = getattr(result, "_hidden_params", {})
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue