From 813bed35c21bb818fa57327ec647734902c31b1e Mon Sep 17 00:00:00 2001 From: oss-agent-shin <279349115+oss-agent-shin@users.noreply.github.com> Date: Fri, 22 May 2026 04:37:43 +0000 Subject: [PATCH] quiet unmapped model helper checks Co-authored-by: ishaan-berri --- .../get_llm_provider_logic.py | 5 +++- .../get_supported_openai_params.py | 4 ++- litellm/utils.py | 20 +++++++++++---- .../test_unmapped_model_helpers.py | 25 +++++++++++++++++++ 4 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 tests/test_litellm/test_unmapped_model_helpers.py diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index ba6d438f16c..131d2abbf96 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -140,6 +140,7 @@ def get_llm_provider( # noqa: PLR0915 api_base: Optional[str] = None, api_key: Optional[str] = None, litellm_params: Optional[LiteLLM_Params] = None, + suppress_debug_info: bool = False, ) -> Tuple[str, str, Optional[str], Optional[str]]: """ Returns the provider for a given model name - e.g. 'azure/chatgpt-v-2' -> 'azure' @@ -148,6 +149,8 @@ def get_llm_provider( # noqa: PLR0915 Raises Error - if unable to map model to a provider + suppress_debug_info: avoid printing provider-list guidance before raising. + Return model, custom_llm_provider, dynamic_api_key, api_base """ try: @@ -499,7 +502,7 @@ def get_llm_provider( # noqa: PLR0915 elif model.startswith("sap/"): custom_llm_provider = "sap" if not custom_llm_provider: - if litellm.suppress_debug_info is False: + if litellm.suppress_debug_info is False and suppress_debug_info is False: print() # noqa print( # noqa "\033[1;31mProvider List: https://docs.litellm.ai/docs/providers\033[0m" # noqa diff --git a/litellm/litellm_core_utils/get_supported_openai_params.py b/litellm/litellm_core_utils/get_supported_openai_params.py index 9d8bd7523db..f9f2b6688ca 100644 --- a/litellm/litellm_core_utils/get_supported_openai_params.py +++ b/litellm/litellm_core_utils/get_supported_openai_params.py @@ -26,7 +26,9 @@ def get_supported_openai_params( # noqa: PLR0915 """ if not custom_llm_provider: try: - custom_llm_provider = litellm.get_llm_provider(model=model)[1] + custom_llm_provider = litellm.get_llm_provider( + model=model, suppress_debug_info=True + )[1] except BadRequestError: return None diff --git a/litellm/utils.py b/litellm/utils.py index 2487d39bd0d..1a9d2bc9583 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2464,7 +2464,9 @@ def supports_native_streaming(model: str, custom_llm_provider: Optional[str]) -> """ try: model, custom_llm_provider, _, _ = litellm.get_llm_provider( - model=model, custom_llm_provider=custom_llm_provider + model=model, + custom_llm_provider=custom_llm_provider, + suppress_debug_info=True, ) model_info = _get_model_info_helper( @@ -2500,7 +2502,9 @@ def supports_response_schema( try: get_llm_provider = getattr(sys.modules[__name__], "get_llm_provider") model, custom_llm_provider, _, _ = get_llm_provider( - model=model, custom_llm_provider=custom_llm_provider + model=model, + custom_llm_provider=custom_llm_provider, + suppress_debug_info=True, ) except Exception as e: verbose_logger.debug( @@ -2603,7 +2607,9 @@ def _supports_factory(model: str, custom_llm_provider: Optional[str], key: str) """ try: model, custom_llm_provider, _, _ = litellm.get_llm_provider( - model=model, custom_llm_provider=custom_llm_provider + model=model, + custom_llm_provider=custom_llm_provider, + suppress_debug_info=True, ) model_info = _get_model_info_helper( @@ -2661,7 +2667,9 @@ def _is_explicitly_disabled_factory( """ try: model, custom_llm_provider, _, _ = litellm.get_llm_provider( - model=model, custom_llm_provider=custom_llm_provider + model=model, + custom_llm_provider=custom_llm_provider, + suppress_debug_info=True, ) model_info = _get_model_info_helper( model=model, custom_llm_provider=custom_llm_provider @@ -2806,7 +2814,9 @@ def get_supported_regions( """ try: model, custom_llm_provider, _, _ = litellm.get_llm_provider( - model=model, custom_llm_provider=custom_llm_provider + model=model, + custom_llm_provider=custom_llm_provider, + suppress_debug_info=True, ) model_info = _get_model_info_helper( diff --git a/tests/test_litellm/test_unmapped_model_helpers.py b/tests/test_litellm/test_unmapped_model_helpers.py new file mode 100644 index 00000000000..a7f15d9b724 --- /dev/null +++ b/tests/test_litellm/test_unmapped_model_helpers.py @@ -0,0 +1,25 @@ +from typing import Any, Callable + +import pytest + +import litellm + + +@pytest.mark.parametrize( + ("helper", "expected"), + [ + (litellm.get_supported_openai_params, None), + (litellm.supports_function_calling, False), + (litellm.supports_reasoning, False), + (litellm.supports_response_schema, False), + ], +) +def test_should_keep_quiet_for_unmapped_model_helpers( + capsys: pytest.CaptureFixture[str], + helper: Callable[..., Any], + expected: Any, +) -> None: + assert helper(model="hhh") is expected + + captured = capsys.readouterr() + assert captured.out == ""