Skip to content

feat: sync gpt-5 model ratio and support new reasoning effort - #1525

Merged
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
HynoR:chore/gpt5
Aug 8, 2025
Merged

feat: sync gpt-5 model ratio and support new reasoning effort#1525
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
HynoR:chore/gpt5

Conversation

@HynoR

@HynoR HynoR commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

支持 GPT-5 模型补全倍率: 8
新增 minimal reasoning effort (仅 gpt5 系列可用)

官方文档:

Minimal reasoning effort 最小推理工作量
The reasoning.effort parameter controls how many reasoning tokens the model generates before producing a response. Earlier reasoning models like o3 supported only low, medium, and high: low favored speed and fewer tokens, while high favored more thorough reasoning.
reasoning.effort 参数控制模型在生成响应之前生成多少推理令牌。像 o3 这样的早期推理模型仅支持 low 、 medium 和 high : low 倾向于速度和更少的令牌,而 high 倾向于更彻底的推理。

The new minimal setting produces very few reasoning tokens for cases where you need the fastest possible time-to-first-token. We often see better performance when the model can produce a few tokens when needed versus none. The default is medium.
新的 minimal 设置在您需要最快的首次令牌时间的情况下,会生成非常少的推理令牌。我们经常发现,当模型可以在需要时生成少量令牌而不是不生成时,性能会更好。默认值为 medium 。

The minimal setting performs especially well in coding and instruction following scenarios, adhering closely to given directions. However, it may require prompting to act more proactively. To improve the model's reasoning quality, even at minimal effort, encourage it to “think” or outline its steps before answering.
minimal 设置在编码和指令遵循场景中表现尤为出色,能严格遵循给定的方向。然而,它可能需要提示才能更主动地行动。为了提高模型的推理质量,即使付出最小的努力,也可以鼓励它在回答前“思考”或概述其步骤。

Summary by CodeRabbit

  • New Features
    • Improved handling of model names with reasoning effort suffixes, ensuring consistent processing and display.
    • Added support for detecting "gpt-5" model names and applying a specific ratio setting automatically.

@coderabbitai

coderabbitai Bot commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A helper function was introduced to centralize the parsing of reasoning effort suffixes from model names in the OpenAI adaptor, replacing repetitive logic in two conversion methods. Additionally, a new conditional branch was added to handle "gpt-5" model prefixes in the model ratio setting, assigning them a fixed ratio value.

Changes

Cohort / File(s) Change Summary
OpenAI Adaptor Reasoning Effort Parsing
relay/channel/openai/adaptor.go
Added parseReasoningEffortFromModelSuffix to extract reasoning effort suffixes; refactored two methods to use this helper, removing manual suffix checks and trimming logic.
Model Ratio Setting for GPT-5
setting/ratio_setting/model_ratio.go
Added a branch in getHardcodedCompletionModelRatio to detect "gpt-5" model prefixes and assign a fixed ratio of 8.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Adaptor
    participant Helper

    Client->>Adaptor: ConvertOpenAIRequest(modelName)
    Adaptor->>Helper: parseReasoningEffortFromModelSuffix(modelName)
    Helper-->>Adaptor: (reasoningEffort, trimmedModelName)
    Adaptor-->>Client: ConvertedRequest with ReasoningEffort and updated model name
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A helper hops in, suffixes to trim,
No more scattered checks, code’s neat and prim.
GPT-5’s ratio now set with care,
Centralized logic, less to repair.
With every refactor, the code grows bright—
A rabbit’s delight in the soft morning light! 🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0fb54f and 4912b1e.

📒 Files selected for processing (2)
  • relay/channel/openai/adaptor.go (3 hunks)
  • setting/ratio_setting/model_ratio.go (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: 9Ninety
PR: QuantumNous/new-api#1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
Learnt from: neotf
PR: QuantumNous/new-api#1511
File: setting/ratio_setting/model_ratio.go:118-123
Timestamp: 2025-08-05T17:14:17.246Z
Learning: Claude models handle "-thinking" variants differently from Gemini models. For Claude models, only the base model (without "-thinking") gets an entry in defaultModelRatio map. The "-thinking" variants rely on the Claude relay handler stripping the suffix using strings.TrimSuffix(textRequest.Model, "-thinking") before looking up the ratio, so they automatically use the base model's ratio.
📚 Learning: 2025-06-21T03:37:41.726Z
Learnt from: 9Ninety
PR: QuantumNous/new-api#1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.

Applied to files:

  • relay/channel/openai/adaptor.go
  • setting/ratio_setting/model_ratio.go
📚 Learning: 2025-08-05T17:14:17.246Z
Learnt from: neotf
PR: QuantumNous/new-api#1511
File: setting/ratio_setting/model_ratio.go:118-123
Timestamp: 2025-08-05T17:14:17.246Z
Learning: Claude models handle "-thinking" variants differently from Gemini models. For Claude models, only the base model (without "-thinking") gets an entry in defaultModelRatio map. The "-thinking" variants rely on the Claude relay handler stripping the suffix using strings.TrimSuffix(textRequest.Model, "-thinking") before looking up the ratio, so they automatically use the base model's ratio.

Applied to files:

  • relay/channel/openai/adaptor.go
  • setting/ratio_setting/model_ratio.go
🔇 Additional comments (4)
relay/channel/openai/adaptor.go (3)

38-51: LGTM! Well-designed helper function.

The function correctly centralizes reasoning effort parsing logic, eliminating code duplication. The implementation properly handles all effort levels including the new "minimal" effort for GPT-5 models.


215-222: LGTM! Clean integration of the helper function.

The refactor properly replaces the previous manual suffix checking logic while maintaining the same functional behavior. The conditional check ensures ReasoningEffort is only set when an effort suffix is found.


439-444: LGTM! Consistent usage of the helper function.

The integration correctly uses the helper function and appropriately sets the reasoning effort on the Reasoning.Effort field for the responses API, maintaining consistency with the existing behavior.

setting/ratio_setting/model_ratio.go (1)

452-455: LGTM! Correctly implements GPT-5 completion ratio support.

The new conditional branch properly handles GPT-5 models with the specified completion ratio of 8, consistent with the PR objectives. The placement within the existing conditional chain is appropriate and follows the established pattern.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Calcium-Ion
Calcium-Ion merged commit 7797552 into QuantumNous:alpha Aug 8, 2025
3 checks passed
@HynoR
HynoR deleted the chore/gpt5 branch August 12, 2025 03:04
@GeorgeWang20

Copy link
Copy Markdown

请问可以支持gpt-oss模型嘛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants