mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
(fix) issue with storing model max budget
This commit is contained in:
parent
e76a3c5ce5
commit
62d0c54cfb
2 changed files with 6 additions and 1 deletions
|
@ -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 = []
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue