fix(llms): narrow _is_reasoning_model to not match gpt-5.x variants (#4746)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
282feaebf2
commit
15feaa8ac4
@@ -285,6 +285,49 @@ def test_store_sent_when_explicitly_false(mock_openai_client):
|
||||
assert call_kwargs["store"] is False
|
||||
|
||||
|
||||
def test_gpt5_mini_not_classified_as_reasoning(mock_openai_client):
|
||||
"""Test that gpt-5.4-mini is NOT treated as a reasoning model.
|
||||
|
||||
gpt-5.4-mini supports temperature and other standard params.
|
||||
The previous substring match on "gpt-5" incorrectly stripped these.
|
||||
Regression test for https://github.com/mem0ai/mem0/issues/4738
|
||||
"""
|
||||
config = OpenAIConfig(model="gpt-5.4-mini", temperature=0.1)
|
||||
llm = OpenAILLM(config)
|
||||
messages = [{"role": "user", "content": "Hello"}]
|
||||
|
||||
mock_response = Mock()
|
||||
mock_response.choices = [Mock(message=Mock(content="Response"))]
|
||||
mock_openai_client.chat.completions.create.return_value = mock_response
|
||||
|
||||
llm.generate_response(messages)
|
||||
|
||||
call_kwargs = mock_openai_client.chat.completions.create.call_args
|
||||
# gpt-5.4-mini should pass through temperature, not strip it
|
||||
assert call_kwargs[1].get("temperature") == 0.1
|
||||
|
||||
|
||||
def test_is_reasoning_model_classification(mock_openai_client):
|
||||
"""Test _is_reasoning_model correctly classifies known models."""
|
||||
config = OpenAIConfig(model="gpt-4.1")
|
||||
llm = OpenAILLM(config)
|
||||
|
||||
# Reasoning models — should return True
|
||||
assert llm._is_reasoning_model("o1") is True
|
||||
assert llm._is_reasoning_model("o3-mini") is True
|
||||
assert llm._is_reasoning_model("o3") is True
|
||||
assert llm._is_reasoning_model("gpt-5") is True
|
||||
assert llm._is_reasoning_model("o1-preview") is True
|
||||
assert llm._is_reasoning_model("o1-2024-12-17") is True
|
||||
assert llm._is_reasoning_model("openai/o3-mini") is True
|
||||
|
||||
# Non-reasoning models — should return False
|
||||
assert llm._is_reasoning_model("gpt-5.4-mini") is False
|
||||
assert llm._is_reasoning_model("gpt-5.4") is False
|
||||
assert llm._is_reasoning_model("gpt-4.1") is False
|
||||
assert llm._is_reasoning_model("gpt-4.1-nano-2025-04-14") is False
|
||||
|
||||
|
||||
def test_callback_with_tools(mock_openai_client):
|
||||
mock_callback = Mock()
|
||||
config = OpenAIConfig(model="gpt-4.1-nano-2025-04-14", response_callback=mock_callback)
|
||||
|
||||
Reference in New Issue
Block a user