Fix reasoning model support (gpt-5.2-pro) by making temperature conditional#472
Fix reasoning model support (gpt-5.2-pro) by making temperature conditional#472kanlanc wants to merge 2 commits intoAsyncFuncAI:mainfrom
Conversation
…tional Reasoning models like gpt-5.2-pro do not support the temperature parameter and return a 400 Bad Request when it is included. Previously, the OpenAI provider path always sent temperature from the model config, which broke any reasoning model used as a custom model. - Add gpt-5.2 and gpt-5.2-pro to generator.json (pro with empty config) - Make temperature/top_p conditional in websocket_wiki.py and simple_chat.py for the OpenAI provider, only including them when present in model config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @kanlanc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical compatibility issue with certain reasoning models, specifically Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug where reasoning models like gpt-5.2-pro would fail due to the temperature parameter being sent unconditionally. The changes in generator.json and the conditional logic added to simple_chat.py and websocket_wiki.py for the OpenAI provider are a good fix. I've included a couple of minor suggestions to improve code maintainability by refactoring how optional parameters are handled.
api/simple_chat.py
Outdated
| if "temperature" in model_config: | ||
| model_kwargs["temperature"] = model_config["temperature"] | ||
| if "top_p" in model_config: | ||
| model_kwargs["top_p"] = model_config["top_p"] |
There was a problem hiding this comment.
To improve maintainability and make it easier to add more optional parameters in the future, you could use a loop to iterate over the optional parameters and add them to model_kwargs if they exist in model_config. This avoids repeating the if ... in ... block for each parameter.
| if "temperature" in model_config: | |
| model_kwargs["temperature"] = model_config["temperature"] | |
| if "top_p" in model_config: | |
| model_kwargs["top_p"] = model_config["top_p"] | |
| for param in ["temperature", "top_p"]: | |
| if param in model_config: | |
| model_kwargs[param] = model_config[param] |
api/websocket_wiki.py
Outdated
| if "temperature" in model_config: | ||
| model_kwargs["temperature"] = model_config["temperature"] | ||
| if "top_p" in model_config: | ||
| model_kwargs["top_p"] = model_config["top_p"] |
There was a problem hiding this comment.
Similar to the other file, you can use a loop here to handle optional parameters. This will make the code more concise and easier to maintain if more optional parameters are added later.
| if "temperature" in model_config: | |
| model_kwargs["temperature"] = model_config["temperature"] | |
| if "top_p" in model_config: | |
| model_kwargs["top_p"] = model_config["top_p"] | |
| for param in ["temperature", "top_p"]: | |
| if param in model_config: | |
| model_kwargs[param] = model_config[param] |
gpt-5.2-pro only supports the Responses API (/v1/responses), not the Chat Completions API (/v1/chat/completions). Added a use_responses_api flag in generator.json and updated websocket_wiki.py and simple_chat.py to use client.responses.create() with streaming for flagged models. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Curious if this works with 5.3 codex... do you mind verifying it? |
Summary
gpt-5.2-prodo not support thetemperatureparameter and return a 400 Bad Request when it is includedgpt-5.2-proonly supports the Responses API (/v1/responses), not the Chat Completions API (/v1/chat/completions) — sending requests to chat completions returns a 404gpt-5.2andgpt-5.2-protogenerator.jsonwith ause_responses_apiflag for models that require the Responses APItemperature/top_pconditional inwebsocket_wiki.pyandsimple_chat.pyfor the OpenAI provider, only including them when present in model configclient.responses.create(stream=True)for flagged models, extracting text fromresponse.output_text.deltaeventsTest plan
gpt-5.2-proas a custom model with OpenAI provider — works end-to-endgpt-5.2still works (uses Chat Completions API with temperature: 1.0)🤖 Generated with Claude Code