Merge pull request #2345 from BerriAI/litellm_fix_update_team_db

(fix) Update Team DB
This commit is contained in:
Ishaan Jaff
2024-03-05 20:37:58 -08:00
committed by GitHub
+6 -2
View File
@@ -1241,12 +1241,16 @@ async def update_database(
f"_update_team_db: existing spend: {existing_spend_obj}"
)
if existing_spend_obj is None:
existing_spend = 0
# the team does not exist in the db - return
verbose_proxy_logger.debug(
"team_id does not exist in db, not tracking spend for team"
)
return
else:
existing_spend = existing_spend_obj.spend
# Calculate the new cost by adding the existing cost and response_cost
new_spend = existing_spend + response_cost
spend_per_model = getattr(existing_spend_obj, "model_spend", {})
# track cost per model, for the given team
spend_per_model = existing_spend_obj.model_spend or {}
current_model = kwargs.get("model")