feat: sync deployed v1.0.0-rc.38-custom.67
This commit is contained in:
1 parent
d09216bbde
commit
8e6ed0317b
154 files changed
+39540
-20509
No files matched your search
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
"github.com/QuantumNous/new-api/constant"
|
||||
"github.com/QuantumNous/new-api/model"
|
||||
"github.com/QuantumNous/new-api/service"
|
||||
"github.com/QuantumNous/new-api/setting"
|
||||
@@ -29,7 +30,7 @@ func setTokenRoutingPolicy(c *gin.Context, token *model.Token, policy *model.Tok
|
||||
token.RoutingPolicy = string(body)
|
||||
token.CrossGroupRetry = true
|
||||
token.AutoGroups = ""
|
||||
if policy.Mode == "inherit" {
|
||||
if policy.Mode == "inherit" || policy.Mode == "smart" {
|
||||
token.Group = "auto"
|
||||
} else if policy.Mode == "user" {
|
||||
token.Group = ""
|
||||
@@ -57,10 +58,8 @@ func PreviewTokenRouting(c *gin.Context) {
|
||||
common.ApiError(c, err)
|
||||
return
|
||||
}
|
||||
inherited := service.GetUserAutoGroup(group)
|
||||
if request.Policy.Mode == "user" {
|
||||
inherited = []string{group}
|
||||
}
|
||||
entries := request.Policy.Resolve(request.Model, inherited, func(candidate string) bool { return service.IsUserSelectableGroup(group, candidate) })
|
||||
common.SetContextKey(c, constant.ContextKeyUserGroup, group)
|
||||
c.Set(model.TokenRoutingContextKey, &request.Policy)
|
||||
entries := service.ResolveRequestPool(c, request.Model)
|
||||
common.ApiSuccess(c, entries)
|
||||
}
|
||||
Reference in new issue
Block a user