Skip to content

fix: /v1/responses/compact default billing - #2766

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/response-compact-price
Jan 29, 2026
Merged

fix: /v1/responses/compact default billing#2766
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/response-compact-price

Conversation

@seefs001

@seefs001 seefs001 commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

/v1/responses/compact 由默认免费调整为默认计费

Summary by CodeRabbit

  • Bug Fixes
    • Fixed model ratio handling for missing models with specific suffixes to use the default ratio instead of returning a zero value, ensuring more consistent behavior across model configurations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The GetModelRatio function in model_ratio.go was modified to remove an explicit zero-return for models with a trailing suffix not found in the ratio map, allowing execution to fall through to the default ratio logic instead.

Changes

Cohort / File(s) Summary
Model Ratio Logic
setting/ratio_setting/model_ratio.go
Commented out the early return for missing suffixed models; function now falls through to default ratio (37.5) instead of returning 0 with true existence flag

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A suffix stumbled, the shortcut was long,
So we let it cascade to defaults so strong,
No more zero tricks for the models we seek,
Just 37.5 for the meek. 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: /v1/responses/compact default billing' directly relates to the change, which modifies billing behavior for the /v1/responses/compact endpoint by removing a hardcoded 0 ratio return and allowing fallback to default ratio.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
setting/ratio_setting/model_ratio.go (1)

462-468: Remove commented-out code and fix semantic inconsistency in return values.

The fix correctly changes default billing for compact-suffix models from 0 to 37.5. However, there's a critical semantic issue:

  1. The commented-out line should be removed entirely.

  2. More importantly, the exists return value now returns operation_setting.SelfUseModeEnabled instead of true. This creates a breaking change in behavior:

    • Previously: Compact models not in the ratio map returned success=true (indicating a valid result)
    • Now: They return success=SelfUseModeEnabled, which defaults to false

    This breaks callers like relay/helper/price.go:71 that treat !success as an error condition. With the default SelfUseModeEnabled=false, all unfound compact models will now trigger the error "ratio or price not set, please start self-use mode"—even though a valid ratio (37.5) is being returned. This contradicts the intended fix.

The return statement should either:

  • Keep success=true to maintain the semantic contract that a valid ratio was found, or
  • Update all affected callers to handle the new semantics where success now means "SelfUseModeEnabled"
Suggested fix
 	if !ok {
 		if strings.HasSuffix(name, CompactModelSuffix) {
 			if wildcardRatio, ok := modelRatioMap[CompactWildcardModelKey]; ok {
 				return wildcardRatio, true, name
 			}
-			//return 0, true, name
 		}
-		return 37.5, operation_setting.SelfUseModeEnabled, name
+		return 37.5, true, name
 	}

@Calcium-Ion
Calcium-Ion merged commit 1e9b567 into QuantumNous:main Jan 29, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…t-price

fix: /v1/responses/compact default billing
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