fix: completion ratio config prioritized over hard code - #3140
fix: completion ratio config prioritized over hard code#3140feitianbubu wants to merge 1 commit into
Conversation
WalkthroughThe GetCompletionRatio function is refactored to check the completionRatioMap before evaluating hardcoded ratios, ensuring explicitly configured values take precedence over hardcoded defaults. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
setting/ratio_setting/model_ratio.go (2)
448-452: Dead code: theif containcheck is unnecessary.Both branches return
hardCodedRatio, making the conditional pointless.♻️ Suggested simplification
- hardCodedRatio, contain := getHardcodedCompletionModelRatio(name) - if contain { - return hardCodedRatio - } - return hardCodedRatio + hardCodedRatio, _ := getHardcodedCompletionModelRatio(name) + return hardCodedRatio🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@setting/ratio_setting/model_ratio.go` around lines 448 - 452, The code in model_ratio.go calls getHardcodedCompletionModelRatio(name) and then checks contain but returns hardCodedRatio in both branches; remove the redundant conditional and simplify by returning hardCodedRatio directly after the call to getHardcodedCompletionModelRatio(name), eliminating the unused boolean contain and the needless if statement.
440-447: Consider removing the redundant "/" check.The check at lines 440-444 is now redundant. The new unconditional map lookup at lines 445-447 will find the ratio regardless of whether the name contains "/".
♻️ Suggested simplification
- if strings.Contains(name, "/") { - if ratio, ok := completionRatioMap.Get(name); ok { - return ratio - } - } if ratio, ok := completionRatioMap.Get(name); ok { return ratio }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@setting/ratio_setting/model_ratio.go` around lines 440 - 447, The existing double lookup around completionRatioMap is redundant: remove the conditional block that checks if strings.Contains(name, "/") and its inner completionRatioMap.Get(name) branch, and keep a single unconditional lookup using completionRatioMap.Get(name) (referencing the name variable and completionRatioMap.Get) to return the ratio if present; ensure no other logic depended on the removed strings.Contains(name, "/") branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@setting/ratio_setting/model_ratio.go`:
- Around line 448-452: The code in model_ratio.go calls
getHardcodedCompletionModelRatio(name) and then checks contain but returns
hardCodedRatio in both branches; remove the redundant conditional and simplify
by returning hardCodedRatio directly after the call to
getHardcodedCompletionModelRatio(name), eliminating the unused boolean contain
and the needless if statement.
- Around line 440-447: The existing double lookup around completionRatioMap is
redundant: remove the conditional block that checks if strings.Contains(name,
"/") and its inner completionRatioMap.Get(name) branch, and keep a single
unconditional lookup using completionRatioMap.Get(name) (referencing the name
variable and completionRatioMap.Get) to return the ratio if present; ensure no
other logic depended on the removed strings.Contains(name, "/") branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fb0bedbf-acec-4c9d-97b6-438d832fcd67
📒 Files selected for processing (1)
setting/ratio_setting/model_ratio.go
修复gpt-5.4倍率被硬编码为8的问题
支持手动设置倍率优于硬编码
Summary by CodeRabbit