(fix) issue with storing model max budget

This commit is contained in:
ishaan-jaff 2024-02-16 18:18:35 -08:00
parent e76a3c5ce5
commit 62d0c54cfb
2 changed files with 6 additions and 1 deletions

View file

@ -421,6 +421,8 @@ class LiteLLM_UserTable(LiteLLMBase):
user_id: str
max_budget: Optional[float]
spend: float = 0.0
model_max_budget: Optional[Dict] = {}
model_spend: Optional[Dict] = {}
user_email: Optional[str]
models: list = []

View file

@ -940,6 +940,7 @@ async def update_database(
# track cost per model, for the given user
spend_per_model = existing_spend_obj.model_spend or {}
current_model = kwargs.get("model")
if current_model is not None and spend_per_model is not None:
if spend_per_model.get(current_model) is None:
spend_per_model[current_model] = response_cost
@ -953,7 +954,9 @@ async def update_database(
key=id, value=existing_spend_obj.json()
)
verbose_proxy_logger.debug(f"new cost: {existing_spend_obj.spend}")
verbose_proxy_logger.debug(
f"user - new cost: {existing_spend_obj.spend}, user_id: {id}"
)
data_list.append(existing_spend_obj)
# Update the cost column for the given user id