mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-11 06:30:21 +00:00
feat: support Wan2.7 i2v media mapping (#4984)
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
This commit is contained in:
@@ -139,6 +139,9 @@ func ValidateMultipartDirect(c *gin.Context, info *RelayInfo) *dto.TaskError {
|
||||
}
|
||||
if req.InputReference != "" {
|
||||
req.Images = []string{req.InputReference}
|
||||
} else if len(req.Images) == 0 && strings.TrimSpace(req.Image) != "" {
|
||||
// 兼容单图上传
|
||||
req.Images = []string{strings.TrimSpace(req.Image)}
|
||||
}
|
||||
|
||||
if strings.TrimSpace(req.Model) == "" {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/QuantumNous/new-api/constant"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestValidateMultipartDirectNormalizesImageField(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
body := strings.NewReader(`{"model":"wan2.7-i2v","prompt":"animate","image":" https://example.com/first.png "}`)
|
||||
request := httptest.NewRequest(http.MethodPost, "/v1/video/generations", body)
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
recorder := httptest.NewRecorder()
|
||||
context, _ := gin.CreateTestContext(recorder)
|
||||
context.Request = request
|
||||
info := &RelayInfo{
|
||||
TaskRelayInfo: &TaskRelayInfo{},
|
||||
}
|
||||
|
||||
taskErr := ValidateMultipartDirect(context, info)
|
||||
|
||||
require.Nil(t, taskErr)
|
||||
storedReq, err := GetTaskRequest(context)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"https://example.com/first.png"}, storedReq.Images)
|
||||
require.Equal(t, constant.TaskActionGenerate, info.Action)
|
||||
}
|
||||
Reference in New Issue
Block a user