mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-14 14:30:26 +00:00
feat: support /v1/moderations now (close #117)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"one-api/common"
|
||||
"one-api/model"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ModelRequest struct {
|
||||
@@ -64,6 +65,11 @@ func Distribute() func(c *gin.Context) {
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/v1/moderations") {
|
||||
if modelRequest.Model == "" {
|
||||
modelRequest.Model = "text-moderation-stable"
|
||||
}
|
||||
}
|
||||
userId := c.GetInt("id")
|
||||
userGroup, _ := model.GetUserGroup(userId)
|
||||
channel, err = model.GetRandomSatisfiedChannel(userGroup, modelRequest.Model)
|
||||
|
Reference in New Issue
Block a user