From 59d23d1d8450c29f8a563ab7e107ea1b8e9accc5 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 22 Jan 2025 17:42:05 -0800 Subject: [PATCH] test(test_user_api_key_auth.py): add unit test to ensure end user id as str works --- litellm/litellm_core_utils/logging_utils.py | 2 +- litellm/proxy/_new_secret_config.yaml | 3 +++ tests/proxy_unit_tests/test_user_api_key_auth.py | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/logging_utils.py b/litellm/litellm_core_utils/logging_utils.py index 41a91f98881..6782435af62 100644 --- a/litellm/litellm_core_utils/logging_utils.py +++ b/litellm/litellm_core_utils/logging_utils.py @@ -110,7 +110,7 @@ def _set_duration_in_model_call_details( if logging_obj and hasattr(logging_obj, "model_call_details"): logging_obj.model_call_details["llm_api_duration_ms"] = duration_ms else: - verbose_logger.warning( + verbose_logger.debug( "`logging_obj` not found - unable to track `llm_api_duration_ms" ) except Exception as e: diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml index 1722a4d796b..da62ca3a426 100644 --- a/litellm/proxy/_new_secret_config.yaml +++ b/litellm/proxy/_new_secret_config.yaml @@ -10,3 +10,6 @@ model_list: api_base: http://0.0.0.0:8090 timeout: 2 num_retries: 0 + - model_name: gemini-1.5-flash + litellm_params: + model: gemini/gemini-1.5-flash diff --git a/tests/proxy_unit_tests/test_user_api_key_auth.py b/tests/proxy_unit_tests/test_user_api_key_auth.py index 9940299622e..a428a29c634 100644 --- a/tests/proxy_unit_tests/test_user_api_key_auth.py +++ b/tests/proxy_unit_tests/test_user_api_key_auth.py @@ -862,3 +862,18 @@ async def test_jwt_user_api_key_auth_builder_enforce_rbac(enforce_rbac, monkeypa await _jwt_auth_user_api_key_auth_builder(**args) else: await _jwt_auth_user_api_key_auth_builder(**args) + + +def test_user_api_key_auth_end_user_str(): + from litellm.proxy.auth.user_api_key_auth import UserAPIKeyAuth + + user_api_key_args = { + "api_key": "sk-1234", + "parent_otel_span": None, + "user_role": LitellmUserRoles.PROXY_ADMIN, + "end_user_id": "1", + "user_id": "default_user_id", + } + + user_api_key_auth = UserAPIKeyAuth(**user_api_key_args) + assert user_api_key_auth.end_user_id == "1"