Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 1m40s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 42m16s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package ali
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/QuantumNous/new-api/common"
|
|
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
|
"github.com/QuantumNous/new-api/relaykit/dto"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/samber/lo"
|
|
)
|
|
|
|
func oaiFormEdit2WanxImageEdit(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (*AliImageRequest, error) {
|
|
count, err := request.ImageCount(true)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
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)
|
|
}
|
|
imageRequest.Input = wanInput
|
|
imageRequest.Parameters = AliImageParameters{
|
|
N: common.GetPointer(uint(count)),
|
|
}
|
|
if request.BillingParameters != nil {
|
|
imageRequest.Parameters.PromptExtend = request.BillingParameters.PromptExtend
|
|
}
|
|
|
|
return &imageRequest, nil
|
|
}
|
|
|
|
func isOldWanModel(modelName string) bool {
|
|
return strings.Contains(modelName, "wan") &&
|
|
!lo.SomeBy([]string{"wan2.6", "wan2.7"}, func(v string) bool { return strings.Contains(modelName, v) })
|
|
}
|
|
|
|
func isWanModel(modelName string) bool {
|
|
return strings.Contains(modelName, "wan")
|
|
}
|