quiet unmapped model helper checks

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
This commit is contained in:
oss-agent-shin 2026-05-22 04:37:43 +00:00
parent d04373f4ce
commit 813bed35c2
No known key found for this signature in database
4 changed files with 47 additions and 7 deletions

View file

@ -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

View file

@ -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

View file

@ -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(

View file

@ -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 == ""