From 05540713fde7ec211f0efefcd6721e48d6f1622e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 11 Apr 2025 16:02:35 -0700 Subject: [PATCH] test_supports_reasoning --- litellm/types/utils.py | 1 + litellm/utils.py | 2 ++ tests/litellm_utils_tests/test_utils.py | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 1bbec44b82..452e43c82b 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -101,6 +101,7 @@ class ProviderSpecificModelInfo(TypedDict, total=False): supports_native_streaming: Optional[bool] supports_parallel_function_calling: Optional[bool] supports_web_search: Optional[bool] + supports_reasoning: Optional[bool] class SearchContextCostPerQuery(TypedDict, total=False): diff --git a/litellm/utils.py b/litellm/utils.py index ab658bde77..b31b929b27 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4606,6 +4606,7 @@ def _get_model_info_helper( # noqa: PLR0915 "supports_native_streaming", None ), supports_web_search=_model_info.get("supports_web_search", False), + supports_reasoning=_model_info.get("supports_reasoning", False), search_context_cost_per_query=_model_info.get( "search_context_cost_per_query", None ), @@ -4678,6 +4679,7 @@ def get_model_info(model: str, custom_llm_provider: Optional[str] = None) -> Mod supports_audio_output: Optional[bool] supports_pdf_input: Optional[bool] supports_web_search: Optional[bool] + supports_reasoning: Optional[bool] Raises: Exception: If the model is not mapped yet. diff --git a/tests/litellm_utils_tests/test_utils.py b/tests/litellm_utils_tests/test_utils.py index 3088fa250f..0ffc6e1421 100644 --- a/tests/litellm_utils_tests/test_utils.py +++ b/tests/litellm_utils_tests/test_utils.py @@ -514,6 +514,26 @@ def test_supports_web_search(model, expected_bool): pytest.fail(f"Error occurred: {e}") +@pytest.mark.parametrize( + "model, expected_bool", + [ + ("openai/o3-mini", True), + ("o3-mini", True), + ("xai/grok-3-mini-beta", True), + ("xai/grok-3-mini-fast-beta", True), + ("xai/grok-2", False), + ("gpt-3.5-turbo", False), + ], +) +def test_supports_reasoning(model, expected_bool): + os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + litellm.model_cost = litellm.get_model_cost_map(url="") + try: + assert litellm.supports_reasoning(model=model) == expected_bool + except Exception as e: + pytest.fail(f"Error occurred: {e}") + + def test_get_max_token_unit_test(): """ More complete testing in `test_completion_cost.py`