Added validation for prompt length in

relayImageHelper function
This commit is contained in:
ckt1031
2023-11-15 20:16:50 +08:00
parent 29fbd12870
commit cb36192c55
2 changed files with 10 additions and 1 deletions

View File

@@ -65,6 +65,11 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
return errorWrapper(errors.New("invalud value of n"), "number_of_generated_images_not_within_range", http.StatusBadRequest)
}
// Check prompt length
if len(imageRequest.Prompt) > common.DalleImagePromptLengthLimitations[imageModel] {
return errorWrapper(errors.New("prompt is too long"), "prompt_too_long", http.StatusBadRequest)
}
// map model name
modelMapping := c.GetString("model_mapping")
isModelMapped := false