fix: add prefixes to image models to solve the problem of duplicate models (#1469)
* Add prefixes to image models to solve the problem of duplicate models * Fix the issue that response_format is not set, causing the b64_json parameter to be ignored.
This commit is contained in:
parent
3be28da57b
commit
332c8db0b3
@ -49,3 +49,8 @@ var ImagePromptLengthLimitations = map[string]int{
|
|||||||
"wanx-v1": 4000,
|
"wanx-v1": 4000,
|
||||||
"cogview-3": 833,
|
"cogview-3": 833,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ImageOriginModelName = map[string]string{
|
||||||
|
"ali-stable-diffusion-xl": "stable-diffusion-xl",
|
||||||
|
"ali-stable-diffusion-v1.5": "stable-diffusion-v1.5",
|
||||||
|
}
|
||||||
|
@ -55,6 +55,11 @@ func RelayImageHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
|
|||||||
return openai.ErrorWrapper(err, "get_image_cost_ratio_failed", http.StatusInternalServerError)
|
return openai.ErrorWrapper(err, "get_image_cost_ratio_failed", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imageModel := imageRequest.Model
|
||||||
|
// Convert the original image model
|
||||||
|
imageRequest.Model, _ = getMappedModelName(imageRequest.Model, billingratio.ImageOriginModelName)
|
||||||
|
c.Set("response_format", imageRequest.ResponseFormat)
|
||||||
|
|
||||||
var requestBody io.Reader
|
var requestBody io.Reader
|
||||||
if isModelMapped || meta.ChannelType == channeltype.Azure { // make Azure channel request body
|
if isModelMapped || meta.ChannelType == channeltype.Azure { // make Azure channel request body
|
||||||
jsonStr, err := json.Marshal(imageRequest)
|
jsonStr, err := json.Marshal(imageRequest)
|
||||||
@ -89,7 +94,7 @@ func RelayImageHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
|
|||||||
requestBody = bytes.NewBuffer(jsonStr)
|
requestBody = bytes.NewBuffer(jsonStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
modelRatio := billingratio.GetModelRatio(imageRequest.Model)
|
modelRatio := billingratio.GetModelRatio(imageModel)
|
||||||
groupRatio := billingratio.GetGroupRatio(meta.Group)
|
groupRatio := billingratio.GetGroupRatio(meta.Group)
|
||||||
ratio := modelRatio * groupRatio
|
ratio := modelRatio * groupRatio
|
||||||
userQuota, err := model.CacheGetUserQuota(ctx, meta.UserId)
|
userQuota, err := model.CacheGetUserQuota(ctx, meta.UserId)
|
||||||
|
Loading…
Reference in New Issue
Block a user