MCPcopy
hub / github.com/mudler/LocalAI / UpdateModelAllowlist

Function UpdateModelAllowlist

core/http/auth/permissions.go:203–210  ·  view source on GitHub ↗

UpdateModelAllowlist updates the model allowlist for a user.

(db *gorm.DB, userID string, allowlist ModelAllowlist)

Source from the content-addressed store, hash-verified

201
202// UpdateModelAllowlist updates the model allowlist for a user.
203func UpdateModelAllowlist(db *gorm.DB, userID string, allowlist ModelAllowlist) error {
204 perm, err := GetUserPermissions(db, userID)
205 if err != nil {
206 return err
207 }
208 perm.AllowedModels = allowlist
209 return db.Save(perm).Error
210}
211
212// IsModelAllowed returns true if the user is allowed to use the given model.
213// Admins always have access. If the allowlist is not enabled, all models are allowed.

Callers 1

RegisterAuthRoutesFunction · 0.92

Calls 2

GetUserPermissionsFunction · 0.85
SaveMethod · 0.80

Tested by

no test coverage detected