mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-16 16:17:26 +00:00
fix: make LITELLM_CLIENT_SPECIFIC_PARAMS a tuple to prevent TypeError
tuple + list raises TypeError in get_openai_client_cache_key. Also add test coverage for get_openai_client_cache_key to catch type mismatches.
This commit is contained in:
@@ -168,12 +168,12 @@ class BaseOpenAILLM:
|
||||
f"is_async={client_initialization_params.get('is_async')}",
|
||||
]
|
||||
|
||||
LITELLM_CLIENT_SPECIFIC_PARAMS = [
|
||||
LITELLM_CLIENT_SPECIFIC_PARAMS = (
|
||||
"timeout",
|
||||
"max_retries",
|
||||
"organization",
|
||||
"api_base",
|
||||
]
|
||||
)
|
||||
openai_client_fields = (
|
||||
BaseOpenAILLM.get_openai_client_initialization_param_fields(
|
||||
client_type=client_type
|
||||
|
||||
@@ -164,3 +164,14 @@ def test_get_openai_client_initialization_param_fields(client_type):
|
||||
assert isinstance(result, tuple)
|
||||
assert len(result) > 0
|
||||
assert "self" not in result
|
||||
|
||||
|
||||
@pytest.mark.parametrize("client_type", ["openai", "azure"])
|
||||
def test_get_openai_client_cache_key(client_type):
|
||||
"""Verify get_openai_client_cache_key doesn't raise on tuple + tuple concatenation."""
|
||||
key = BaseOpenAILLM.get_openai_client_cache_key(
|
||||
client_initialization_params={"api_key": "sk-test"},
|
||||
client_type=client_type,
|
||||
)
|
||||
assert isinstance(key, str)
|
||||
assert "api_key=sk-test" in key
|
||||
|
||||
Reference in New Issue
Block a user