forked from phoenix/litellm-mirror
use safe get_internal_user_object
This commit is contained in:
parent
8900255bc7
commit
e34d9c51c9
1 changed files with 25 additions and 11 deletions
|
@ -747,9 +747,18 @@ class _PROXY_MaxParallelRequestsHandler(CustomLogger):
|
|||
user_id: str,
|
||||
user_api_key_dict: UserAPIKeyAuth,
|
||||
) -> Optional[dict]:
|
||||
"""
|
||||
Helper to get the 'Internal User Object'
|
||||
|
||||
It uses the `get_user_object` function from `litellm.proxy.auth.auth_checks`
|
||||
|
||||
We need this because the UserApiKeyAuth object does not contain the rpm/tpm limits for a User AND there could be a perf impact by additionally reading the UserTable.
|
||||
"""
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.proxy.auth.auth_checks import get_user_object
|
||||
from litellm.proxy.proxy_server import prisma_client
|
||||
|
||||
try:
|
||||
_user_id_rate_limits = await get_user_object(
|
||||
user_id=user_id,
|
||||
prisma_client=prisma_client,
|
||||
|
@ -763,3 +772,8 @@ class _PROXY_MaxParallelRequestsHandler(CustomLogger):
|
|||
return None
|
||||
|
||||
return _user_id_rate_limits.model_dump()
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.exception(
|
||||
"Parallel Request Limiter: Error getting user object", str(e)
|
||||
)
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue