fix: ali image model cannot be found and the error with the incorrect return format.

This commit is contained in:
mlkt
2024-05-26 02:52:22 +08:00
parent e9981fff36
commit 076ec68989
3 changed files with 8 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common/ctxkey"
"github.com/songquanpeng/one-api/common/helper"
"github.com/songquanpeng/one-api/common/logger"
"github.com/songquanpeng/one-api/relay/adaptor/openai"
@@ -19,7 +20,11 @@ import (
func ImageHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage) {
apiKey := c.Request.Header.Get("Authorization")
apiKey = strings.TrimPrefix(apiKey, "Bearer ")
responseFormat := c.GetString("response_format")
var responseFormat string
if req, exists := c.Get(ctxkey.ConvertedRequest); exists {
responseFormat = req.(*ImageRequest).ResponseFormat
}
var aliTaskResponse TaskResponse
responseBody, err := io.ReadAll(resp.Body)