-
-
Notifications
You must be signed in to change notification settings - Fork 944
fix: adjust default temperature for GPT-5 and o-series models #742
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,21 @@ | |
| run_command, | ||
| ) | ||
|
|
||
| FIXED_TEMP_MODELS = { | ||
| "gpt-5", | ||
| "gpt-5-mini", | ||
| "o1-mini", | ||
| "o1-preview", | ||
| "o2-mini", | ||
| "o3-mini", | ||
| "gpt-5-nano", | ||
| "gpt-5.1", | ||
| "gpt-5.2", | ||
| "gpt-5.2-pro", | ||
| "o1", | ||
| "o3", | ||
| } | ||
|
|
||
|
|
||
| def main( | ||
| prompt: str = typer.Argument( | ||
|
|
@@ -210,6 +225,8 @@ def main( | |
|
|
||
| if repl: | ||
| # Will be in infinite loop here until user exits with Ctrl+C. | ||
| if model in FIXED_TEMP_MODELS: | ||
| temperature = 1 | ||
|
Comment on lines
+228
to
+229
|
||
| ReplHandler(repl, role_class, md).handle( | ||
| init_prompt=prompt, | ||
| model=model, | ||
|
|
@@ -220,6 +237,8 @@ def main( | |
| ) | ||
|
|
||
| if chat: | ||
| if model in FIXED_TEMP_MODELS: | ||
| temperature = 1 | ||
|
||
| full_completion = ChatHandler(chat, role_class, md).handle( | ||
| prompt=prompt, | ||
| model=model, | ||
|
|
@@ -229,6 +248,8 @@ def main( | |
| functions=function_schemas, | ||
| ) | ||
| else: | ||
| if model in FIXED_TEMP_MODELS: | ||
| temperature = 1 | ||
|
||
| full_completion = DefaultHandler(role_class, md).handle( | ||
| prompt=prompt, | ||
| model=model, | ||
|
|
@@ -255,6 +276,8 @@ def main( | |
| full_completion = session.prompt("", default=full_completion) | ||
| continue | ||
| elif option == "d": | ||
| if model in FIXED_TEMP_MODELS: | ||
| temperature = 1 | ||
|
||
| DefaultHandler(DefaultRoles.DESCRIBE_SHELL.get_role(), md).handle( | ||
| full_completion, | ||
| model=model, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,13 +46,22 @@ def cmd_args(prompt="", **kwargs): | |||||||
|
|
||||||||
|
|
||||||||
| def comp_args(role, prompt, **kwargs): | ||||||||
| model = kwargs.get("model", cfg.get("DEFAULT_MODEL")) | ||||||||
|
|
||||||||
| # Mirror production logic: GPT-5 and o-series models require temperature 1.0, | ||||||||
| # while other models default to 0.0 in tests. | ||||||||
| if model.startswith("gpt-5") or model.startswith("o"): | ||||||||
|
||||||||
| if model.startswith("gpt-5") or model.startswith("o"): | |
| is_o_series = len(model) > 1 and model[0] == "o" and model[1].isdigit() | |
| if model.startswith("gpt-5") or is_o_series: |
Copilot
AI
Jan 21, 2026
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.
The test logic uses prefix matching with startswith(), while the production code in sgpt/app.py uses exact set membership matching. This creates an inconsistency where tests will pass for models like "gpt-5.3" or "o4-mini" (which aren't in the FIXED_TEMP_MODELS set), but the production code won't apply the temperature adjustment for them. The test helper should use the same FIXED_TEMP_MODELS set from sgpt/app.py to ensure tests accurately reflect production behavior.
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.
The FIXED_TEMP_MODELS set contains speculative future model names like "gpt-5.1", "gpt-5.2", "gpt-5.2-pro", "o2-mini", "gpt-5-nano", etc. that may not exist yet or may never exist. This approach requires the code to be updated whenever OpenAI releases new models. Consider using a prefix-based matching approach (e.g., checking if model starts with "gpt-5" or matches the pattern "o[0-9]") to automatically handle future models in these series without code changes.