Skip to content

feat(qwen): support qwen image sync image model config - #2717

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
xyfacai:feat/qwen-config
Jan 22, 2026
Merged

feat(qwen): support qwen image sync image model config#2717
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
xyfacai:feat/qwen-config

Conversation

@xyfacai

@xyfacai xyfacai commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Refactored model configuration handling for improved code organization and maintainability.
    • Added configurable settings for image model synchronization to support model customization.

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

@coderabbitai

coderabbitai Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Refactored 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

Cohort / File(s) Summary
Ali Adapter Refactoring
relay/channel/ali/adaptor.go
Replaced inline isSyncImageModel logic with call to model_setting.IsSyncImageModel(). Added import for setting/model_setting package. Removed local syncModels iteration.
New Qwen Settings Module
setting/model_setting/qwen.go
New file introducing QwenSettings struct with SyncImageModels field. Exports GetQwenSettings() accessor and IsSyncImageModel() utility function. Registers settings with global configuration manager.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Configuration hops from here to there,
A model's image sync now shared with care,
Qwen settings spring forth, tidy and bright,
While Ali adaptor delegates right,
Code reuse blooms—what a delight! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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 accurately reflects the main change: adding Qwen model image sync configuration support through a new model_setting package with QwenSettings.

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

@xyfacai
xyfacai requested review from Calcium-Ion and seefs001 and removed request for Calcium-Ion January 22, 2026 09:49

@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

🤖 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",
-	}
-*/

Comment on lines +42 to +49
// IsSyncImageModel
func IsSyncImageModel(model string) bool {
for _, m := range qwenSettings.SyncImageModels {
if strings.Contains(model, m) {
return true
}
}
return false

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.

⚠️ Potential issue | 🟡 Minor

🧩 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 2

Repository: 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' -i

Repository: 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' -i

Repository: 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 -60

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

Suggested change
// 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.

@Calcium-Ion
Calcium-Ion merged commit d841481 into QuantumNous:main Jan 22, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
feat(qwen): support qwen image sync image model config
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