fix(proxy_server.py): track cost for global proxy

This commit is contained in:
Krrish Dholakia 2024-01-24 16:06:10 -08:00
parent ba24037baf
commit 574208f005
3 changed files with 44 additions and 22 deletions

View file

@ -1090,7 +1090,12 @@ class Logging:
else: # streaming chunks + image gen.
self.model_call_details["response_cost"] = None
if litellm.max_budget and self.stream:
if (
litellm.max_budget
and self.stream
and result is not None
and "content" in result
):
time_diff = (end_time - start_time).total_seconds()
float_diff = float(time_diff)
litellm._current_cost += litellm.completion_cost(