Updated model validation and removed size not

supported error in relayImageHelper function
This commit is contained in:
ckt1031 2023-11-15 20:18:27 +08:00
parent cb36192c55
commit b59fbafbc3

View File

@ -46,8 +46,13 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
} }
// Model validation // Model validation
if imageRequest.Model != "" && imageRequest.Model != "dall-e-3" { if imageRequest.Model != "" {
imageModel = "dall-e-2" // Check if model is supported
if _, ok := common.DalleSizeRatios[imageRequest.Model]; !ok {
return errorWrapper(errors.New("model not supported"), "model_not_supported", http.StatusBadRequest)
}
imageModel = imageRequest.Model
} }
// Size validation // Size validation
@ -117,8 +122,6 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
sizeRatio *= 1.5 sizeRatio *= 1.5
} }
} }
} else {
return errorWrapper(errors.New("size not supported"), "size_not_supported", http.StatusBadRequest)
} }
quota := int(ratio*sizeRatio*1000) * imageRequest.N quota := int(ratio*sizeRatio*1000) * imageRequest.N