Merge commit 'af543ab8ecb6827cbbc151c2cff181cdc3286274'

This commit is contained in:
Laisky.Cai
2024-04-08 01:13:00 +00:00
49 changed files with 1024 additions and 335 deletions

View File

@@ -119,7 +119,7 @@ func TokenAuth() func(c *gin.Context) {
return
}
requestModel, err := getRequestModel(c)
if err != nil && !strings.HasPrefix(c.Request.URL.Path, "/v1/models") {
if err != nil && shouldCheckModel(c) {
abortWithMessage(c, http.StatusBadRequest, err.Error())
return
}
@@ -145,3 +145,19 @@ func TokenAuth() func(c *gin.Context) {
c.Next()
}
}
func shouldCheckModel(c *gin.Context) bool {
if strings.HasPrefix(c.Request.URL.Path, "/v1/completions") {
return true
}
if strings.HasPrefix(c.Request.URL.Path, "/v1/chat/completions") {
return true
}
if strings.HasPrefix(c.Request.URL.Path, "/v1/images") {
return true
}
if strings.HasPrefix(c.Request.URL.Path, "/v1/audio") {
return true
}
return false
}