Some checks failed
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (amd64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (arm64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Create multi-arch manifests (Docker Hub) (push) Has been cancelled
Release (Linux, macOS, Windows) / Linux Release (push) Has been cancelled
Release (Linux, macOS, Windows) / macOS Release (push) Has been cancelled
Release (Linux, macOS, Windows) / Windows Release (push) Has been cancelled
- wan2.6系列生图与编辑,适配多图生成计费 - wan2.5系列生图与编辑 - z-image-turbo生图,适配prompt_extend计费
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")
|
|
}
|