feat: support openai images edits api

This commit is contained in:
Laisky.Cai
2024-04-25 03:02:20 +00:00
parent 84a6817314
commit 425059f5c6
12 changed files with 59 additions and 32 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"github.com/Laisky/errors/v2"
"github.com/Laisky/one-api/common/ctxkey"
@@ -57,7 +58,8 @@ func RelayImageHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
}
var requestBody io.Reader
if isModelMapped || meta.ChannelType == channeltype.Azure { // make Azure channel request body
if strings.ToLower(c.GetString(ctxkey.ContentType)) == "application/json" &&
isModelMapped || meta.ChannelType == channeltype.Azure { // make Azure channel request body
jsonStr, err := json.Marshal(imageRequest)
if err != nil {
return openai.ErrorWrapper(err, "marshal_image_request_failed", http.StatusInternalServerError)