-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Set default to unsupported value for gpt-5 model series requests #2229
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
Merged
+4
−3
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
🧩 Analysis chain
Verify parameter omission strategy is correctly implemented.
There's an inconsistency in how unsupported parameters are being cleared:
Temperatureis set tonil(line 311)TopPis set to0(line 312)LogProbsis set tofalse(line 313)The comment on line 312 indicates the intent is to omit these parameters from the request using
omitempty. However, this only works correctly if:TopP = 0: The field must be a pointer type (*float64) foromitemptyto omit zero values. If it's a regularfloat64, setting it to0will serialize as"top_p": 0in JSON, not omit it. Consider usingnillikeTemperatureif it's a pointer.LogProbs = false: Similarly, if this is abool, setting tofalsewill serialize as"logprobs": falserather than omitting it, unless it's a pointer type (*bool).If the goal is to truly omit these parameters (as stated in the PR description and line 312 comment), ensure the field types support this approach or set them to
nilconsistently.Run the following script to verify the field types in the request struct:
Additionally, verify the OpenAI documentation to confirm gpt-5 unsupported parameters:
🏁 Script executed:
Length of output: 6459
🌐 Web query:
💡 Result:
Short answer — per the latest docs and dev reports, GPT‑5 / GPT‑5.1 no longer accept the old completion-style parameters; specifically they do NOT support:
Other parameters reported as unsupported or limited for the new/optimized models include: n, stream (or streaming true for some optimized variants), user, metadata, modalities/audio-related params, and similar legacy completion fields — check per-model notes because availability varies by model/variant. [1][3][4]
Sources:
[1] Compatibility/parameter notes (community doc) listing unsupported params including logit_bias, max_tokens, n, user, etc.
[2] Multiple GitHub issues and project reports describing GPT‑5 rejecting max_tokens and temperature (error: “Unsupported parameter …”).
[3] OpenAI/structured-model docs and model notes showing optimized models require max_completion_tokens and limit parameters (stream/temperature/top_p restrictions).
[4] Microsoft/Azure Q&A noting reasoning/verbosity parameters are only available for reasoning-enabled GPT‑5 deployments (standard GPT‑5 chat rejects them).
If you want, I can fetch and paste the exact error messages and links to the specific documentation pages (with direct citations).
Fix field types to properly omit unsupported parameters for GPT-5 models.
The verification confirms the original concern. The code attempts to omit unsupported parameters using
omitempty, but this approach is flawed for two fields:Field Type Analysis:
Temperatureis*float64— setting tonilcorrectly omits it ✓TopPisfloat64— setting to0will serialize as"top_p": 0and send to API ✗LogProbsisbool— setting tofalsewill serialize as"logprobs": falseand send to API ✗GPT-5 and GPT-5.1 do not support temperature, top_p, and logprobs, so these parameters must be properly omitted. Since
omitemptyonly works withnilvalues on pointer types,TopPandLogProbsfields should be changed to pointer types (*float64and*bool) indto/openai_request.go(lines 39 and 56), and the assignments inrelay/channel/openai/adaptor.goshould be updated to set them tonilinstead of0andfalse.🤖 Prompt for AI Agents
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.
Golang的零值和忽略并不等价,这里能不能生效感觉有疑问
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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 7513
@seefs001 你的质疑完全正确!当前的实现确实有问题。
在 Go 中,
omitempty标签的行为取决于字段类型:当前的字段类型:
Temperature *float64(指针类型) - 设置为nil✅ 会被省略TopP float64(非指针类型) - 设置为0❌ 会序列化为"top_p": 0LogProbs bool(非指针类型) - 设置为false❌ 会序列化为"logprobs": false问题:
omitempty对于非指针类型的零值(0, false)不会省略字段,仍然会发送到 API。这意味着当前代码会发送:{ "top_p": 0, "logprobs": false }而不是完全省略这些参数。
正确的解决方案:
需要修改
dto/openai_request.go中的字段定义为指针类型:然后在
relay/channel/openai/adaptor.go中设置为nil:这样才能确保这些参数真正不会被发送到 OpenAI API。
🧬 Code Graph Analysis Results
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.
那要不要把那几个全改指针类型,传nil进去
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.