mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix(auth_utils.py): check if team level model-specific rpm limit set
This commit is contained in:
parent
91f420160f
commit
117d5963d0
1 changed files with 15 additions and 2 deletions
|
|
@ -417,6 +417,12 @@ def bytes_to_mb(bytes_value: int):
|
|||
def get_key_model_rpm_limit(
|
||||
user_api_key_dict: UserAPIKeyAuth,
|
||||
) -> Optional[Dict[str, int]]:
|
||||
"""
|
||||
Get the model rpm limit for a given api key
|
||||
- check key metadata
|
||||
- check key model max budget
|
||||
- check team metadata
|
||||
"""
|
||||
if user_api_key_dict.metadata:
|
||||
if "model_rpm_limit" in user_api_key_dict.metadata:
|
||||
return user_api_key_dict.metadata["model_rpm_limit"]
|
||||
|
|
@ -426,7 +432,9 @@ def get_key_model_rpm_limit(
|
|||
if "rpm_limit" in budget and budget["rpm_limit"] is not None:
|
||||
model_rpm_limit[model] = budget["rpm_limit"]
|
||||
return model_rpm_limit
|
||||
|
||||
elif user_api_key_dict.team_metadata:
|
||||
if "model_rpm_limit" in user_api_key_dict.team_metadata:
|
||||
return user_api_key_dict.team_metadata["model_rpm_limit"]
|
||||
return None
|
||||
|
||||
|
||||
|
|
@ -473,6 +481,7 @@ def _has_user_setup_sso():
|
|||
|
||||
return sso_setup
|
||||
|
||||
|
||||
def get_customer_user_header_from_mapping(user_id_mapping) -> Optional[str]:
|
||||
"""Return the header_name mapped to CUSTOMER role, if any (dict-based)."""
|
||||
if not user_id_mapping:
|
||||
|
|
@ -522,7 +531,11 @@ def get_end_user_id_from_request_body(
|
|||
for header_name, header_value in request_headers.items():
|
||||
if header_name.lower() == custom_header_name_to_check.lower():
|
||||
user_id_from_header = header_value
|
||||
user_id_str = str(user_id_from_header) if user_id_from_header is not None else ""
|
||||
user_id_str = (
|
||||
str(user_id_from_header)
|
||||
if user_id_from_header is not None
|
||||
else ""
|
||||
)
|
||||
if user_id_str.strip():
|
||||
return user_id_str
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue