feat: support /v1/moderations now (close #117)

This commit is contained in:
JustSong
2023-06-11 09:37:36 +08:00
parent e398e0756b
commit 4339f45f74
5 changed files with 39 additions and 3 deletions

View File

@@ -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)