From c4e7c45c3a4850c85df0cf46a2be416b4626c8dc Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Tue, 5 Mar 2024 19:09:19 -0800 Subject: [PATCH] (fix) update team_id --- litellm/proxy/proxy_server.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index edb5c6970..409cf63d5 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -1241,17 +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 - - if existing_spend_obj is None: - spend_per_model = {} - else: - spend_per_model = existing_spend_obj.model_spend or {} - + 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")