diff --git a/litellm/tests/test_utils.py b/litellm/tests/test_utils.py index 8f99bd665c9..491283eeda8 100644 --- a/litellm/tests/test_utils.py +++ b/litellm/tests/test_utils.py @@ -23,6 +23,7 @@ from litellm.utils import ( create_pretrained_tokenizer, create_tokenizer, get_max_tokens, + get_supported_openai_params, ) # Assuming your trim_messages, shorten_message_to_fit_limit, and get_token_count functions are all in a module named 'message_utils' @@ -386,3 +387,11 @@ def test_get_max_token_unit_test(): ) # Returns a number instead of throwing an Exception assert isinstance(max_tokens, int) + + +def test_get_supported_openai_params() -> None: + # Mapped provider + assert isinstance(get_supported_openai_params("gpt-4"), list) + + # Unmapped provider + assert get_supported_openai_params("nonexistent") is None diff --git a/litellm/utils.py b/litellm/utils.py index 290854271a9..05fba48ac3b 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -6227,7 +6227,7 @@ def get_first_chars_messages(kwargs: dict) -> str: def get_supported_openai_params( model: str, - custom_llm_provider: str, + custom_llm_provider: Optional[str] = None, request_type: Literal["chat_completion", "embeddings"] = "chat_completion", ) -> Optional[list]: """ @@ -6242,6 +6242,11 @@ def get_supported_openai_params( - List if custom_llm_provider is mapped - None if unmapped """ + if not custom_llm_provider: + try: + custom_llm_provider = litellm.get_llm_provider(model=model)[1] + except BadRequestError: + return None if custom_llm_provider == "bedrock": return litellm.AmazonConverseConfig().get_supported_openai_params(model=model) elif custom_llm_provider == "ollama":