Skip to content

Commit 8433ca1

Browse files
ampagentIsaac Miller
andauthored
Make reasoning capability tests independent of model catalogs
Amp-Thread-ID: https://ampcode.com/threads/T-01a0bf8d-a1dd-7603-906c-ea06c46ff7f7 Co-authored-by: Isaac Miller <isaac@cmpnd.ai>
1 parent 5575303 commit 8433ca1

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎tests/adapters/test_chat_adapter.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,8 @@ def get_weather(city: str) -> str:
26462646
)
26472647

26482648

2649-
def test_chat_adapter_native_reasoning():
2649+
@mock.patch("litellm.supports_reasoning", return_value=True)
2650+
def test_chat_adapter_native_reasoning(_supports_reasoning):
26502651
class MySignature(dspy.Signature):
26512652
question: str = dspy.InputField()
26522653
reasoning: dspy.Reasoning = dspy.OutputField()

‎tests/adapters/test_json_adapter.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,8 @@ def get_weather(city: str) -> str:
15701570
assert call_kwargs["response_format"] == {"type": "json_object"}
15711571

15721572

1573-
def test_json_adapter_native_reasoning():
1573+
@mock.patch("litellm.supports_reasoning", return_value=True)
1574+
def test_json_adapter_native_reasoning(_supports_reasoning):
15741575
class MySignature(dspy.Signature):
15751576
question: str = dspy.InputField()
15761577
reasoning: dspy.Reasoning = dspy.OutputField()

‎tests/clients/test_lm.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,12 @@ def test_reasoning_model_token_parameter():
406406
assert lm.kwargs["max_tokens"] == 1000
407407

408408

409-
def test_lm_supports_reasoning_with_litellm_capability_api():
410-
lm = dspy.LM("anthropic/claude-3-7-sonnet-20250219")
411-
assert lm.supports_reasoning is True
409+
@pytest.mark.parametrize("supported", [True, False])
410+
def test_lm_supports_reasoning_with_litellm_capability_api(supported):
411+
lm = dspy.LM("anthropic/claude-3-7-sonnet-20250219", engine="litellm")
412+
with mock.patch("litellm.supports_reasoning", return_value=supported) as supports_reasoning:
413+
assert lm.supports_reasoning is supported
414+
supports_reasoning.assert_called_once_with(lm.model)
412415

413416

414417
@pytest.mark.parametrize("model_name", ["openai/o1", "openai/gpt-5-nano", "openai/gpt-5-mini"])

0 commit comments

Comments
 (0)