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:
+13
-25
@@ -647,38 +647,26 @@ func GetUserModels(c *gin.Context) {
|
||||
}
|
||||
groups := service.GetUserUsableGroups(user.Group)
|
||||
group := c.Query("group")
|
||||
if group != "" {
|
||||
if _, ok := groups[group]; !ok {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": "",
|
||||
"data": []string{},
|
||||
})
|
||||
return
|
||||
var groupsToQuery []string
|
||||
switch {
|
||||
case group == "":
|
||||
for g := range groups {
|
||||
groupsToQuery = append(groupsToQuery, g)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": "",
|
||||
"data": model.GetGroupEnabledModels(group),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var models []string
|
||||
for group := range groups {
|
||||
for _, g := range model.GetGroupEnabledModels(group) {
|
||||
if !common.StringsContains(models, g) {
|
||||
models = append(models, g)
|
||||
}
|
||||
case group == "auto":
|
||||
if _, ok := groups[group]; ok {
|
||||
groupsToQuery = service.GetUserAutoGroup(user.Group)
|
||||
}
|
||||
default:
|
||||
if _, ok := groups[group]; ok {
|
||||
groupsToQuery = []string{group}
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": "",
|
||||
"data": models,
|
||||
"data": service.GetGroupsEnabledModels(groupsToQuery),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateUser(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user