Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dspy/clients/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
model_family = model.split("/")[-1].lower() if "/" in model else model.lower()

# Recognize OpenAI reasoning models (o1, o3, o4, gpt-5 family)
model_pattern = re.match(r"^(?:o[1345]|gpt-5)(?:-(?:mini|nano))?", model_family)
model_pattern = re.match(r"^(?:o[1345](?:-(?:mini|nano))?(?:-\d{4}-\d{2}-\d{2})?|gpt-5(?:-(?:mini|nano|pro))?)$", model_family)

if model_pattern:
if (temperature and temperature != 1.0) or (max_tokens and max_tokens < 16000):
Expand Down
3 changes: 3 additions & 0 deletions tests/clients/test_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ def test_reasoning_model_token_parameter():
("openai/gpt-5", True),
("openai/gpt-5-mini", True),
("openai/gpt-5-nano", True),
("openai/gpt-5-pro", True),
("openai/gpt-5-chat", False),
("azure/gpt-5-chat", False),
("openai/gpt-4", False),
("anthropic/claude-2", False),
]
Expand Down