-
Notifications
You must be signed in to change notification settings - Fork 2k
Skip unsupported stop parameter for reasoning models #1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The CI error is unrelated: |
src/smolagents/models.py
Outdated
@@ -307,7 +307,9 @@ def _prepare_completion_kwargs( | |||
|
|||
# Handle specific parameters | |||
if stop_sequences is not None: | |||
completion_kwargs["stop"] = stop_sequences | |||
# Not supported with reasoning models openai/o3 and openai/o4-mini | |||
if self.model_id.split("/")[-1] not in ["o3", "o4-mini"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the API, indeed these models don't seem to have any argument for stop sequences, really strange IMO not to propose this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... thanks guys!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albertvillanova @aymeric-roucher
actually I think the fix above is not working if people specify model versions a la o4-mini-2025-04-16
if self.model_id.split("/")[-1] not in ["o3", "o4-mini"]: | |
# Handle specific parameters | |
if stop_sequences is not None: | |
# Not supported with reasoning models openai/o3 and openai/o4-mini | |
if ("o3" in self.model_id.split("/")[-1] and "o3-mini" not in self.model_id.split("/")[-1]) or "o4-mini" in self.model_id.split("/")[-1]: | |
completion_kwargs.pop("stop", None) | |
else: | |
completion_kwargs["stop"] = stop_sequences |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. For reference: https://platform.openai.com/docs/api-reference/chat/create#chat-create-stop
stop: string / array / null, Optional, Defaults to null
Not supported with latest reasoning models
o3
ando4-mini
.Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
src/smolagents/models.py
Outdated
@@ -307,7 +307,9 @@ def _prepare_completion_kwargs( | |||
|
|||
# Handle specific parameters | |||
if stop_sequences is not None: | |||
completion_kwargs["stop"] = stop_sequences | |||
# Not supported with reasoning models openai/o3 and openai/o4-mini | |||
if self.model_id.split("/")[-1] not in ["o3", "o4-mini"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albertvillanova @aymeric-roucher
actually I think the fix above is not working if people specify model versions a la o4-mini-2025-04-16
if self.model_id.split("/")[-1] not in ["o3", "o4-mini"]: | |
# Handle specific parameters | |
if stop_sequences is not None: | |
# Not supported with reasoning models openai/o3 and openai/o4-mini | |
if ("o3" in self.model_id.split("/")[-1] and "o3-mini" not in self.model_id.split("/")[-1]) or "o4-mini" in self.model_id.split("/")[-1]: | |
completion_kwargs.pop("stop", None) | |
else: | |
completion_kwargs["stop"] = stop_sequences |
Good catch, @benediktstroebl! We should handle model snapshots (versions) as well. |
Skip unsupported stop parameter for reasoning models: o3 and o4-mini
Fix #1210.