MCPcopy
hub / github.com/QuantumNous/new-api / GetUserModels

Function GetUserModels

controller/user.go:577–602  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

575}
576
577func GetUserModels(c *gin.Context) {
578 id, err := strconv.Atoi(c.Param("id"))
579 if err != nil {
580 id = c.GetInt("id")
581 }
582 user, err := model.GetUserCache(id)
583 if err != nil {
584 common.ApiError(c, err)
585 return
586 }
587 groups := service.GetUserUsableGroups(user.Group)
588 var models []string
589 for group := range groups {
590 for _, g := range model.GetGroupEnabledModels(group) {
591 if !common.StringsContains(models, g) {
592 models = append(models, g)
593 }
594 }
595 }
596 c.JSON(http.StatusOK, gin.H{
597 "success": true,
598 "message": "",
599 "data": models,
600 })
601 return
602}
603
604func UpdateUser(c *gin.Context) {
605 var updatedUser model.User

Callers

nothing calls this directly

Calls 5

GetUserCacheFunction · 0.92
ApiErrorFunction · 0.92
GetUserUsableGroupsFunction · 0.92
GetGroupEnabledModelsFunction · 0.92
StringsContainsFunction · 0.92

Tested by

no test coverage detected