forked from phoenix/litellm-mirror
fix - user_id_information
This commit is contained in:
parent
c43a4dff7f
commit
36916852ad
1 changed files with 15 additions and 4 deletions
|
@ -1062,11 +1062,18 @@ async def user_api_key_auth(
|
||||||
|
|
||||||
# Check 4. Token Spend is under budget
|
# Check 4. Token Spend is under budget
|
||||||
if valid_token.spend is not None and valid_token.max_budget is not None:
|
if valid_token.spend is not None and valid_token.max_budget is not None:
|
||||||
# collect information for alerting
|
|
||||||
|
|
||||||
if isinstance(user_id_information, list):
|
####################################
|
||||||
user_id_information = user_id_information[0]
|
# collect information for alerting #
|
||||||
user_email = user_id_information.get("user_email", None)
|
####################################
|
||||||
|
|
||||||
|
user_email = None
|
||||||
|
# Check if the token has any user id information
|
||||||
|
if user_id_information is not None:
|
||||||
|
if isinstance(user_id_information, list):
|
||||||
|
user_id_information = user_id_information[0]
|
||||||
|
user_email = user_id_information.get("user_email", None)
|
||||||
|
|
||||||
call_info = CallInfo(
|
call_info = CallInfo(
|
||||||
token=valid_token.token,
|
token=valid_token.token,
|
||||||
spend=valid_token.spend,
|
spend=valid_token.spend,
|
||||||
|
@ -1083,6 +1090,10 @@ async def user_api_key_auth(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# collect information for alerting #
|
||||||
|
####################################
|
||||||
|
|
||||||
if valid_token.spend >= valid_token.max_budget:
|
if valid_token.spend >= valid_token.max_budget:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"ExceededTokenBudget: Current spend for token: {valid_token.spend}; Max Budget for Token: {valid_token.max_budget}"
|
f"ExceededTokenBudget: Current spend for token: {valid_token.spend}; Max Budget for Token: {valid_token.max_budget}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue