feat(qwen): support qwen image sync image model config - #2717
Conversation
WalkthroughRefactored image model synchronization logic from the Ali adapter into a centralized Qwen settings module. The adapter now calls a shared utility function instead of maintaining local model lists, promoting code reusability and reducing duplication. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 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
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@setting/model_setting/qwen.go`:
- Around line 42-49: IsSyncImageModel does a case-sensitive substring check;
change it to perform a case-insensitive comparison by normalizing the input
model to lowercase before checking against qwenSettings.SyncImageModels (which
are lowercase). In practice, update the loop in IsSyncImageModel to compare
strings.Contains(strings.ToLower(model), m) (or otherwise lowercase the model
once before the loop) so mixed-case upstream model names match the config
values.
🧹 Nitpick comments (1)
relay/channel/ali/adaptor.go (1)
27-33: Remove the commented-out syncModels block to avoid confusion.
Stale commented code can drift and mislead future readers.🧹 Proposed cleanup
-/* - var syncModels = []string{ - "z-image", - "qwen-image", - "wan2.6", - } -*/
| // IsSyncImageModel | ||
| func IsSyncImageModel(model string) bool { | ||
| for _, m := range qwenSettings.SyncImageModels { | ||
| if strings.Contains(model, m) { | ||
| return true | ||
| } | ||
| } | ||
| return false |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find where IsSyncImageModel is called and check for model name normalization patterns
rg -n --type=go 'IsSyncImageModel\(' -A 2 -B 2Repository: QuantumNous/new-api
Length of output: 639
🏁 Script executed:
#!/bin/bash
# Check for existing ToLower patterns with model-related variables
rg -n --type=go 'strings\.ToLower\([^)]*model' -iRepository: QuantumNous/new-api
Length of output: 1035
🏁 Script executed:
#!/bin/bash
# Look for model name normalization patterns
rg -n --type=go 'OriginModelName|UpstreamModelName|model.*ToLower|ToLower.*model' -iRepository: QuantumNous/new-api
Length of output: 26805
🏁 Script executed:
#!/bin/bash
# Check the qwen.go file to understand the SyncImageModels data
cat -n setting/model_setting/qwen.go | head -60Repository: QuantumNous/new-api
Length of output: 1373
Use case-insensitive matching for model name comparison. The IsSyncImageModel function uses strings.Contains, which is case-sensitive. Since the codebase consistently normalizes model names to lowercase for comparisons (e.g., relay/channel/ali/adaptor.go:36, relay/channel/openai/relay-openai.go:127), and the config values are all lowercase, this function should follow the same pattern to handle mixed-case inputs from upstream sources or user config.
Suggested fix
func IsSyncImageModel(model string) bool {
+ model = strings.ToLower(model)
for _, m := range qwenSettings.SyncImageModels {
- if strings.Contains(model, m) {
+ if strings.Contains(model, strings.ToLower(m)) {
return true
}
}
return false
}📝 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.
| // IsSyncImageModel | |
| func IsSyncImageModel(model string) bool { | |
| for _, m := range qwenSettings.SyncImageModels { | |
| if strings.Contains(model, m) { | |
| return true | |
| } | |
| } | |
| return false | |
| // IsSyncImageModel | |
| func IsSyncImageModel(model string) bool { | |
| model = strings.ToLower(model) | |
| for _, m := range qwenSettings.SyncImageModels { | |
| if strings.Contains(model, strings.ToLower(m)) { | |
| return true | |
| } | |
| } | |
| return false | |
| } |
🤖 Prompt for AI Agents
In `@setting/model_setting/qwen.go` around lines 42 - 49, IsSyncImageModel does a
case-sensitive substring check; change it to perform a case-insensitive
comparison by normalizing the input model to lowercase before checking against
qwenSettings.SyncImageModels (which are lowercase). In practice, update the loop
in IsSyncImageModel to compare strings.Contains(strings.ToLower(model), m) (or
otherwise lowercase the model once before the loop) so mixed-case upstream model
names match the config values.
feat(qwen): support qwen image sync image model config
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.