|
|
@@ -7,6 +7,7 @@ import (
|
|
|
"net/http"
|
|
|
"strings"
|
|
|
|
|
|
+ "github.com/QuantumNous/new-api/common"
|
|
|
"github.com/QuantumNous/new-api/dto"
|
|
|
"github.com/QuantumNous/new-api/relay/channel"
|
|
|
"github.com/QuantumNous/new-api/relay/channel/claude"
|
|
|
@@ -18,12 +19,16 @@ import (
|
|
|
"github.com/QuantumNous/new-api/types"
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
+ "github.com/samber/lo"
|
|
|
)
|
|
|
|
|
|
type Adaptor struct {
|
|
|
IsSyncImageModel bool
|
|
|
}
|
|
|
|
|
|
+const aliAnthropicMessagesModelsEnv = "ALI_ANTHROPIC_MESSAGES_MODELS"
|
|
|
+const defaultAliAnthropicMessagesModels = "qwen,deepseek-v4,kimi,glm,minimax-m"
|
|
|
+
|
|
|
/*
|
|
|
var syncModels = []string{
|
|
|
"z-image",
|
|
|
@@ -32,8 +37,22 @@ type Adaptor struct {
|
|
|
}
|
|
|
*/
|
|
|
func supportsAliAnthropicMessages(modelName string) bool {
|
|
|
- // Only models with the "qwen" designation can use the Claude-compatible interface; others require conversion.
|
|
|
- return strings.Contains(strings.ToLower(modelName), "qwen")
|
|
|
+ normalizedModelName := strings.ToLower(strings.TrimSpace(modelName))
|
|
|
+ if normalizedModelName == "" {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return lo.SomeBy(aliAnthropicMessagesModelPatterns(), func(pattern string) bool {
|
|
|
+ return strings.Contains(normalizedModelName, pattern)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func aliAnthropicMessagesModelPatterns() []string {
|
|
|
+ configuredModels := common.GetEnvOrDefaultString(aliAnthropicMessagesModelsEnv, defaultAliAnthropicMessagesModels)
|
|
|
+ return lo.FilterMap(strings.Split(configuredModels, ","), func(item string, _ int) (string, bool) {
|
|
|
+ pattern := strings.ToLower(strings.TrimSpace(item))
|
|
|
+ return pattern, pattern != ""
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
var syncModels = []string{
|