Skip to content

Commit 67c64e7

Browse files
committed
fix: fix max_tokens check
1 parent 97030e2 commit 67c64e7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

controller/relay-text.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
5858
if err != nil {
5959
return errorWrapper(err, "bind_request_body_failed", http.StatusBadRequest)
6060
}
61+
if textRequest.MaxTokens < 0 || textRequest.MaxTokens > math.MaxInt32/2 {
62+
return errorWrapper(errors.New("max_tokens is invalid"), "invalid_max_tokens", http.StatusBadRequest)
63+
}
6164
if relayMode == RelayModeModerations && textRequest.Model == "" {
6265
textRequest.Model = "text-moderation-latest"
6366
}

0 commit comments

Comments
 (0)