fix(playground): resolve auto group model listing (#6163)
* fix(playground): resolve auto group model listing - merge and deduplicate available models in configured auto group order. - reuse special usable group rules and add model filtering regression coverage. * refactor: extract GetGroupsEnabledModels to dedupe group model expansion
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/QuantumNous/new-api/model"
|
||||
"github.com/QuantumNous/new-api/setting"
|
||||
"github.com/QuantumNous/new-api/setting/ratio_setting"
|
||||
)
|
||||
@@ -53,6 +54,21 @@ func GetUserAutoGroup(userGroup string) []string {
|
||||
return autoGroups
|
||||
}
|
||||
|
||||
// GetGroupsEnabledModels 按 groups 顺序获取各分组启用的模型并去重
|
||||
func GetGroupsEnabledModels(groups []string) []string {
|
||||
seen := make(map[string]struct{})
|
||||
models := make([]string, 0)
|
||||
for _, group := range groups {
|
||||
for _, modelName := range model.GetGroupEnabledModels(group) {
|
||||
if _, ok := seen[modelName]; !ok {
|
||||
seen[modelName] = struct{}{}
|
||||
models = append(models, modelName)
|
||||
}
|
||||
}
|
||||
}
|
||||
return models
|
||||
}
|
||||
|
||||
// GetUserGroupRatio 获取用户使用某个分组的倍率
|
||||
// userGroup 用户分组
|
||||
// group 需要获取倍率的分组
|
||||
|
||||
Reference in New Issue
Block a user