test_supports_reasoning

This commit is contained in:
Ishaan Jaff 2025-04-11 16:02:35 -07:00
parent fd9c4d5e67
commit 05540713fd
3 changed files with 23 additions and 0 deletions

View file

@ -101,6 +101,7 @@ class ProviderSpecificModelInfo(TypedDict, total=False):
supports_native_streaming: Optional[bool] supports_native_streaming: Optional[bool]
supports_parallel_function_calling: Optional[bool] supports_parallel_function_calling: Optional[bool]
supports_web_search: Optional[bool] supports_web_search: Optional[bool]
supports_reasoning: Optional[bool]
class SearchContextCostPerQuery(TypedDict, total=False): class SearchContextCostPerQuery(TypedDict, total=False):

View file

@ -4606,6 +4606,7 @@ def _get_model_info_helper( # noqa: PLR0915
"supports_native_streaming", None "supports_native_streaming", None
), ),
supports_web_search=_model_info.get("supports_web_search", False), 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=_model_info.get(
"search_context_cost_per_query", None "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_audio_output: Optional[bool]
supports_pdf_input: Optional[bool] supports_pdf_input: Optional[bool]
supports_web_search: Optional[bool] supports_web_search: Optional[bool]
supports_reasoning: Optional[bool]
Raises: Raises:
Exception: If the model is not mapped yet. Exception: If the model is not mapped yet.

View file

@ -514,6 +514,26 @@ def test_supports_web_search(model, expected_bool):
pytest.fail(f"Error occurred: {e}") 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(): def test_get_max_token_unit_test():
""" """
More complete testing in `test_completion_cost.py` More complete testing in `test_completion_cost.py`