mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 02:42:29 +00:00
feat(qwen): support qwen image sync image model config
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/QuantumNous/new-api/relay/channel/openai"
|
"github.com/QuantumNous/new-api/relay/channel/openai"
|
||||||
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
||||||
"github.com/QuantumNous/new-api/relay/constant"
|
"github.com/QuantumNous/new-api/relay/constant"
|
||||||
|
"github.com/QuantumNous/new-api/setting/model_setting"
|
||||||
"github.com/QuantumNous/new-api/service"
|
"github.com/QuantumNous/new-api/service"
|
||||||
"github.com/QuantumNous/new-api/types"
|
"github.com/QuantumNous/new-api/types"
|
||||||
|
|
||||||
@@ -23,6 +24,13 @@ type Adaptor struct {
|
|||||||
IsSyncImageModel bool
|
IsSyncImageModel bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var syncModels = []string{
|
||||||
|
"z-image",
|
||||||
|
"qwen-image",
|
||||||
|
"wan2.6",
|
||||||
|
}
|
||||||
|
*/
|
||||||
func supportsAliAnthropicMessages(modelName string) bool {
|
func supportsAliAnthropicMessages(modelName string) bool {
|
||||||
// Only models with the "qwen" designation can use the Claude-compatible interface; others require conversion.
|
// Only models with the "qwen" designation can use the Claude-compatible interface; others require conversion.
|
||||||
return strings.Contains(strings.ToLower(modelName), "qwen")
|
return strings.Contains(strings.ToLower(modelName), "qwen")
|
||||||
@@ -35,12 +43,7 @@ var syncModels = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isSyncImageModel(modelName string) bool {
|
func isSyncImageModel(modelName string) bool {
|
||||||
for _, m := range syncModels {
|
return model_setting.IsSyncImageModel(modelName)
|
||||||
if strings.Contains(modelName, m) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dto.GeminiChatRequest) (any, error) {
|
func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dto.GeminiChatRequest) (any, error) {
|
||||||
|
|||||||
50
setting/model_setting/qwen.go
Normal file
50
setting/model_setting/qwen.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package model_setting
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/QuantumNous/new-api/setting/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// QwenSettings defines Qwen model configuration. 注意bool要以enabled结尾才可以生效编辑
|
||||||
|
type QwenSettings struct {
|
||||||
|
SyncImageModels []string `json:"sync_image_models"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认配置
|
||||||
|
var defaultQwenSettings = QwenSettings{
|
||||||
|
SyncImageModels: []string{
|
||||||
|
"z-image",
|
||||||
|
"qwen-image",
|
||||||
|
"wan2.6",
|
||||||
|
"qwen-image-edit",
|
||||||
|
"qwen-image-edit-max",
|
||||||
|
"qwen-image-edit-max-2026-01-16",
|
||||||
|
"qwen-image-edit-plus",
|
||||||
|
"qwen-image-edit-plus-2025-12-15",
|
||||||
|
"qwen-image-edit-plus-2025-10-30",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全局实例
|
||||||
|
var qwenSettings = defaultQwenSettings
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// 注册到全局配置管理器
|
||||||
|
config.GlobalConfig.Register("qwen", &qwenSettings)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetQwenSettings
|
||||||
|
func GetQwenSettings() *QwenSettings {
|
||||||
|
return &qwenSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSyncImageModel
|
||||||
|
func IsSyncImageModel(model string) bool {
|
||||||
|
for _, m := range qwenSettings.SyncImageModels {
|
||||||
|
if strings.Contains(model, m) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user