forked from phoenix/litellm-mirror
refactor(proxy_server.py): fix merge error
This commit is contained in:
parent
9e138b9e4e
commit
184e78772b
1 changed files with 53 additions and 44 deletions
|
@ -474,7 +474,6 @@ async def user_api_key_auth(
|
|||
key=valid_token.user_id, table_name="user"
|
||||
)
|
||||
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
f"user_id_information: {user_id_information}"
|
||||
)
|
||||
|
@ -884,12 +883,15 @@ async def update_database(
|
|||
"""
|
||||
user_ids = [user_id, litellm_proxy_budget_name]
|
||||
data_list = []
|
||||
try:
|
||||
for id in user_ids:
|
||||
if id is None:
|
||||
continue
|
||||
if prisma_client is not None:
|
||||
existing_spend_obj = await prisma_client.get_data(user_id=id)
|
||||
elif custom_db_client is not None and id != litellm_proxy_budget_name:
|
||||
elif (
|
||||
custom_db_client is not None and id != litellm_proxy_budget_name
|
||||
):
|
||||
existing_spend_obj = await custom_db_client.get_data(
|
||||
key=id, table_name="user"
|
||||
)
|
||||
|
@ -903,7 +905,10 @@ async def update_database(
|
|||
if litellm.max_user_budget is not None:
|
||||
max_user_budget = litellm.max_user_budget
|
||||
existing_spend_obj = LiteLLM_UserTable(
|
||||
user_id=id, spend=0, max_budget=max_user_budget, user_email=None
|
||||
user_id=id,
|
||||
spend=0,
|
||||
max_budget=max_user_budget,
|
||||
user_email=None,
|
||||
)
|
||||
if existing_spend_obj is None:
|
||||
existing_spend = 0
|
||||
|
@ -922,13 +927,17 @@ 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"new cost: {existing_spend_obj.spend}"
|
||||
)
|
||||
data_list.append(existing_spend_obj)
|
||||
|
||||
# Update the cost column for the given user id
|
||||
if prisma_client is not None:
|
||||
await prisma_client.update_data(
|
||||
data_list=data_list, query_type="update_many", table_name="user"
|
||||
data_list=data_list,
|
||||
query_type="update_many",
|
||||
table_name="user",
|
||||
)
|
||||
elif custom_db_client is not None and user_id is not None:
|
||||
new_spend = data_list[0].spend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue