mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 08:36:22 +00:00
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package ali
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/QuantumNous/new-api/common"
|
|
"github.com/QuantumNous/new-api/dto"
|
|
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func oaiFormEdit2WanxImageEdit(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (*AliImageRequest, error) {
|
|
var err error
|
|
var imageRequest AliImageRequest
|
|
imageRequest.Model = request.Model
|
|
imageRequest.ResponseFormat = request.ResponseFormat
|
|
wanInput := WanImageInput{
|
|
Prompt: request.Prompt,
|
|
}
|
|
|
|
if err := common.UnmarshalBodyReusable(c, &wanInput); err != nil {
|
|
return nil, err
|
|
}
|
|
if wanInput.Images, err = getImageBase64sFromForm(c, "image"); err != nil {
|
|
return nil, fmt.Errorf("get image base64s from form failed: %w", err)
|
|
}
|
|
//wanParams := WanImageParameters{
|
|
// N: int(request.N),
|
|
//}
|
|
imageRequest.Input = wanInput
|
|
imageRequest.Parameters = AliImageParameters{
|
|
N: int(request.N),
|
|
}
|
|
info.PriceData.AddOtherRatio("n", float64(imageRequest.Parameters.N))
|
|
|
|
return &imageRequest, nil
|
|
}
|
|
|
|
func isOldWanModel(modelName string) bool {
|
|
return strings.Contains(modelName, "wan") && !strings.Contains(modelName, "wan2.6")
|
|
}
|
|
|
|
func isWanModel(modelName string) bool {
|
|
return strings.Contains(modelName, "wan")
|
|
}
|