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:
QuentinHsu
2026-07-20 18:21:24 +08:00
committed by GitHub
parent e13d4033e5
commit 4aa08f917e
4 changed files with 82 additions and 38 deletions
+13 -25
View File
@@ -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) {