feat(openai/azure): enable temperature when reasoning_effort=none for…#2829
Open
henry-fung wants to merge 10 commits into
Open
feat(openai/azure): enable temperature when reasoning_effort=none for…#2829henry-fung wants to merge 10 commits into
henry-fung wants to merge 10 commits into
Conversation
… gpt-5.1/5.2/5.4 Starting from GPT-5.2 (and confirmed also for GPT-5.1), when reasoning_effort is set to "none", temperature and top_p become valid parameters. With any other reasoning effort value, passing these parameters causes a 400 API error. Changes: - OpenAI provider: add temperature parameter to gpt-5.1/5.2/5.4 YAML definitions - OpenAI llm.py (_build_responses_api_params): strip temperature/top_p/logprobs when reasoning_effort is active (non-"none") - OpenAI llm.py (_chat_generate): same stripping for standard Chat Completions path - Azure OpenAI constants.py: add temperature ParameterRule to gpt-5.1/5.2/5.4 entries - Azure OpenAI llm.py (_chat_generate_with_responses): restructure reasoning vs temperature/top_p as mutually exclusive — reasoning active → set reasoning param only; reasoning=none or absent → pass temperature/top_p, skip reasoning param Tested against Azure OpenAI (dscgpt.openai.azure.com) with all three deployments: - reasoning=none + temperature=0.7 → success - reasoning=low + temperature=0.7 → expected 400 error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for the reasoning_effort parameter in Azure OpenAI and OpenAI models, specifically targeting GPT-5 variants. It includes logic to conditionally include or strip parameters like temperature, top_p, and logprobs based on whether reasoning is active, as these are mutually exclusive in the underlying APIs. Review feedback highlights the need for consistent top_p parameter rules across model definitions and suggests ensuring logprobs is consistently stripped in the standard chat generation path when reasoning is enabled.
… text-embedding-3-* models Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add top_p to gpt-5.1 parameter rules (openai yaml and azure constants) - Strip logprobs when reasoning_effort is active in _chat_generate path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Starting from GPT-5.2 (confirmed also for GPT-5.1), when
reasoning_effortisset to
"none",temperatureandtop_pbecome valid parameters. Passing themwith any other reasoning effort value causes a
400API error. This PR implementsthe conditional logic for gpt-5.1, gpt-5.2, and gpt-5.4 in both the OpenAI
and Azure OpenAI providers.
OpenAI provider
gpt-5.1.yaml,gpt-5.2.yaml,gpt-5.4.yaml: addtemperaturetoparameter_rulesllm.py(_build_responses_api_params): striptemperature/top_p/logprobswhen reasoning is active (non-
"none")llm.py(_chat_generate): same stripping for the standard Chat Completions pathAzure OpenAI provider
constants.py: addtemperatureParameterRuletogpt-5.1,gpt-5.2,gpt-5.4entriesllm.py(_chat_generate_with_responses): restructure reasoning vstemperature/top_p as mutually exclusive — reasoning active → set
reasoning: {effort}only; reasoning="none"or absent → passtemperature/top_p, skip reasoning param
Related Issues or Context
Implements the parameter constraints documented by OpenAI:
Verified via direct API testing that GPT-5.1 follows the same rules.
This PR contains Changes to Non-Plugin
This PR contains Changes to Non-LLM Models Plugin
This PR contains Changes to LLM Models Plugin
gpt-5.1/5.2/5.4 —
reasoning_effortvstemperaturebehavior:none(default)low/medium/highVersion Control
models/openai/manifest.yaml:0.3.4→0.3.5models/azure_openai/manifest.yaml:0.0.49→0.0.50Dify Plugin SDK Version
dify_plugin>=0.3.0,<0.6.0is in requirements.txtEnvironment Verification
Local Deployment Environment
SaaS Environment