Skip to content

Commit

Permalink
fix: fix max_tokens check
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Dec 20, 2023
1 parent 97030e2 commit 67c64e7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controller/relay-text.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
if err != nil {
return errorWrapper(err, "bind_request_body_failed", http.StatusBadRequest)
}
if textRequest.MaxTokens < 0 || textRequest.MaxTokens > math.MaxInt32/2 {
return errorWrapper(errors.New("max_tokens is invalid"), "invalid_max_tokens", http.StatusBadRequest)
}
if relayMode == RelayModeModerations && textRequest.Model == "" {
textRequest.Model = "text-moderation-latest"
}
Expand Down

0 comments on commit 67c64e7

Please sign in to comment.