Skip to content

feat: vertex budget control in model name - #1271

Merged
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
RedwindA:feat/vertex-budgetControl
Jun 20, 2025
Merged

Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
RedwindA:feat/vertex-budgetControl

Conversation

@RedwindA

@RedwindA RedwindA commented Jun 20, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of model names with new "-thinking-" suffixes to ensure correct processing when using the "thinking adapter."

@coderabbitai

coderabbitai Bot commented Jun 20, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The update refines the logic in the GetRequestURL method within the Adaptor struct to better handle model name normalization for the "thinking adapter" scenario. It now detects and removes a new "-thinking-" suffix pattern from model names, in addition to the previously handled "-thinking" and "-nothinking" suffixes.

Changes

File(s) Change Summary
relay/channel/vertex/adaptor.go Enhanced model name normalization in GetRequestURL to handle "-thinking-" suffixes.

Poem

A suffix here, a budget there,
The model names need extra care!
With thinking trimmed and budgets gone,
The adapter logic marches on.
Hopping forward, neat and spry,
CodeRabbit keeps the models dry! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
relay/channel/vertex/adaptor.go (1)

86-86: Use consistent comment language throughout the codebase.

The comment is written in Chinese while the rest of the codebase uses English comments. Consider using English for consistency.

-			// 新增逻辑:处理 -thinking-<budget> 格式
+			// Handle -thinking-<budget> format for budget control
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 03468e0 and 9344cab.

📒 Files selected for processing (1)
  • relay/channel/vertex/adaptor.go (1 hunks)
🔇 Additional comments (1)
relay/channel/vertex/adaptor.go (1)

87-94: Logic implementation looks correct for budget control feature.

The new logic successfully implements the budget control feature by:

  1. Detecting the "-thinking-" pattern using strings.Contains
  2. Extracting the base model name by splitting and taking the first part
  3. Maintaining backward compatibility with existing "-thinking" and "-nothinking" suffix handling

This approach correctly handles the new naming convention while preserving existing functionality.

Comment on lines +87 to 94
if strings.Contains(info.UpstreamModelName, "-thinking-") {
parts := strings.Split(info.UpstreamModelName, "-thinking-")
info.UpstreamModelName = parts[0]
} else if strings.HasSuffix(info.UpstreamModelName, "-thinking") { // 旧的适配
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-thinking")
} else if strings.HasSuffix(info.OriginModelName, "-nothinking") {
} else if strings.HasSuffix(info.UpstreamModelName, "-nothinking") {
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-nothinking")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider edge case handling for model names starting with "-thinking-".

The logic correctly handles the new "-thinking-" pattern, but there's a potential edge case: if a model name starts with "-thinking-" (e.g., "-thinking-100"), parts[0] would be an empty string, which could cause issues downstream.

Consider adding validation to ensure the extracted model name is not empty:

 			if strings.Contains(info.UpstreamModelName, "-thinking-") {
 				parts := strings.Split(info.UpstreamModelName, "-thinking-")
-				info.UpstreamModelName = parts[0]
+				if parts[0] != "" {
+					info.UpstreamModelName = parts[0]
+				}
 			} else if strings.HasSuffix(info.UpstreamModelName, "-thinking") {
 				info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-thinking")
 			} else if strings.HasSuffix(info.UpstreamModelName, "-nothinking") {
 				info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-nothinking")
 			}

Alternatively, you could use a more robust approach by checking if the substring "-thinking-" is not at the beginning:

-			if strings.Contains(info.UpstreamModelName, "-thinking-") {
+			if strings.Contains(info.UpstreamModelName, "-thinking-") && !strings.HasPrefix(info.UpstreamModelName, "-thinking-") {
 				parts := strings.Split(info.UpstreamModelName, "-thinking-")
 				info.UpstreamModelName = parts[0]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if strings.Contains(info.UpstreamModelName, "-thinking-") {
parts := strings.Split(info.UpstreamModelName, "-thinking-")
info.UpstreamModelName = parts[0]
} else if strings.HasSuffix(info.UpstreamModelName, "-thinking") { // 旧的适配
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-thinking")
} else if strings.HasSuffix(info.OriginModelName, "-nothinking") {
} else if strings.HasSuffix(info.UpstreamModelName, "-nothinking") {
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-nothinking")
}
if strings.Contains(info.UpstreamModelName, "-thinking-") {
parts := strings.Split(info.UpstreamModelName, "-thinking-")
if parts[0] != "" {
info.UpstreamModelName = parts[0]
}
} else if strings.HasSuffix(info.UpstreamModelName, "-thinking") { // 旧的适配
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-thinking")
} else if strings.HasSuffix(info.UpstreamModelName, "-nothinking") {
info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-nothinking")
}
🤖 Prompt for AI Agents
In relay/channel/vertex/adaptor.go around lines 87 to 94, the current code
splits the model name on "-thinking-" and assigns the first part to
info.UpstreamModelName, but if the model name starts with "-thinking-", this
results in an empty string which can cause issues. To fix this, add a check
after splitting to ensure parts[0] is not empty before assigning it; if it is
empty, handle this case appropriately, such as skipping the assignment or
logging an error. Alternatively, modify the condition to only split if
"-thinking-" is found and is not at the start of the string.

@Calcium-Ion
Calcium-Ion merged commit 8b209d8 into QuantumNous:alpha Jun 20, 2025
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
…ontrol

feat: vertex budget control in model name
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
…ontrol

feat: vertex budget control in model name
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
…ontrol

feat: vertex budget control in model name
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.

2 participants