新增 MiniMax H3 Highspeed/Lite 与 Seedance 2.5 Flash,兼容视频参数和旧工作流
This commit is contained in:
+107
-3
@@ -6,6 +6,7 @@ import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from inspect import signature
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, call, patch
|
||||
|
||||
import av
|
||||
@@ -18,11 +19,17 @@ PLUGIN_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
CUSTOM_NODES_DIR = os.path.dirname(PLUGIN_DIR)
|
||||
COMFY_ROOT = os.environ.get(
|
||||
"COMFYUI_ROOT",
|
||||
r"F:\ComfyUI_windows_portable\ComfyUI",
|
||||
str(Path(__file__).resolve().parents[3]),
|
||||
)
|
||||
sys.path.insert(0, COMFY_ROOT)
|
||||
sys.path.insert(0, CUSTOM_NODES_DIR)
|
||||
|
||||
# The portable CPU build must not attempt CUDA initialization during imports.
|
||||
from comfy.cli_args import args # noqa: E402
|
||||
|
||||
if torch.version.cuda is None:
|
||||
args.cpu = True
|
||||
|
||||
from comfyui_o1key.clients.minimax_h3_client import ( # noqa: E402
|
||||
FAILURE_STATUSES,
|
||||
MiniMaxH3Client,
|
||||
@@ -34,11 +41,14 @@ from comfyui_o1key.clients.minimax_h3_client import ( # noqa: E402
|
||||
from comfyui_o1key.clients.newapi_veo_client import NewAPIVeoClient # noqa: E402
|
||||
from comfyui_o1key.nodes.minimax_h3_video import ( # noqa: E402
|
||||
MAX_SEED,
|
||||
MODEL_HIGHSPEED_ID,
|
||||
MODEL_LITE_ID,
|
||||
MODEL_MAX_ID,
|
||||
MODE_FIRST,
|
||||
MODE_FIRST_LAST,
|
||||
MODE_LAST,
|
||||
MODE_REFERENCE,
|
||||
LEGACY_MODE_REFERENCE,
|
||||
MODE_TEXT,
|
||||
MiniMaxH3Video,
|
||||
_make_progress_callbacks,
|
||||
@@ -56,6 +66,81 @@ from comfyui_o1key.utils.video_task import POLL_DEADLINE_SECONDS # noqa: E402
|
||||
|
||||
|
||||
class MiniMaxH3PayloadTests(unittest.TestCase):
|
||||
def test_legacy_reference_mode_builds_the_same_multimodal_payload(self):
|
||||
parameters = dict(
|
||||
prompt="Follow the reference.", resolution="768P", duration=4,
|
||||
reference_image_urls=["https://cdn.example.com/image.png"],
|
||||
)
|
||||
self.assertEqual(
|
||||
build_request_body(mode=LEGACY_MODE_REFERENCE, **parameters),
|
||||
build_request_body(mode=MODE_REFERENCE, **parameters),
|
||||
)
|
||||
|
||||
def test_highspeed_and_lite_limits_and_reference_roles(self):
|
||||
for model in (MODEL_HIGHSPEED_ID, MODEL_LITE_ID):
|
||||
for resolution in ("480P", "768P"):
|
||||
for duration in (4, 15):
|
||||
with self.subTest(model=model, resolution=resolution, duration=duration):
|
||||
body = build_request_body(
|
||||
prompt="A red ball rolls slowly.", model=model,
|
||||
resolution=resolution, duration=duration,
|
||||
mode=MODE_TEXT, ratio="16:9", seed=42,
|
||||
)
|
||||
self.assertEqual(body["model"], model)
|
||||
self.assertEqual(body["seed"], 42)
|
||||
for resolution, duration in (("2K", 4), ("1080P", 4), ("480P", 3), ("480P", 16)):
|
||||
with self.subTest(model=model, resolution=resolution, duration=duration):
|
||||
with self.assertRaises(ValueError):
|
||||
build_request_body(
|
||||
prompt="x", model=model, resolution=resolution,
|
||||
duration=duration, mode=MODE_TEXT, ratio="16:9",
|
||||
)
|
||||
body = build_request_body(
|
||||
prompt="Follow the references.", model=model, resolution="480P",
|
||||
duration=4, mode=MODE_REFERENCE, ratio="9:16",
|
||||
reference_image_urls=["https://cdn.example.com/image.png"],
|
||||
reference_video_urls=["https://cdn.example.com/video.mp4"],
|
||||
reference_audio_urls=["https://cdn.example.com/audio.wav"],
|
||||
)
|
||||
self.assertEqual(body["ratio"], "9:16")
|
||||
self.assertEqual([item["role"] for item in body["content"][1:]],
|
||||
["reference_image", "reference_video", "reference_audio"])
|
||||
|
||||
def test_lite_reference_requires_explicit_fixed_ratio(self):
|
||||
for ratio in (None, "", "adaptive", "2:1"):
|
||||
with self.subTest(ratio=ratio), self.assertRaisesRegex(ValueError, "具体宽高比"):
|
||||
build_request_body(
|
||||
prompt="x", model=MODEL_LITE_ID, resolution="480P", duration=4,
|
||||
mode=MODE_REFERENCE, ratio=ratio,
|
||||
reference_image_urls=["https://cdn.example.com/image.png"],
|
||||
)
|
||||
body = build_request_body(
|
||||
prompt="x", model=MODEL_HIGHSPEED_ID, resolution="480P", duration=4,
|
||||
mode=MODE_REFERENCE,
|
||||
reference_image_urls=["https://cdn.example.com/image.png"],
|
||||
)
|
||||
self.assertEqual(body["ratio"], "adaptive")
|
||||
|
||||
def test_new_models_frame_modes_and_tail_requires_first_frame(self):
|
||||
for model in (MODEL_HIGHSPEED_ID, MODEL_LITE_ID):
|
||||
for mode, frames in (
|
||||
(MODE_FIRST, {"first_url": "https://cdn.example.com/first.png"}),
|
||||
(MODE_FIRST_LAST, {"first_url": "https://cdn.example.com/first.png",
|
||||
"last_url": "https://cdn.example.com/last.png"}),
|
||||
):
|
||||
with self.subTest(model=model, mode=mode):
|
||||
body = build_request_body(
|
||||
prompt="x", model=model, resolution="480P", duration=4,
|
||||
mode=mode, **frames,
|
||||
)
|
||||
self.assertEqual(body["ratio"], "adaptive")
|
||||
self.assertEqual(body["content"][1]["role"], "first_frame")
|
||||
with self.assertRaisesRegex(ValueError, "同时提供首帧"):
|
||||
build_request_body(
|
||||
prompt="x", model=model, resolution="480P", duration=4,
|
||||
mode=MODE_LAST, last_url="https://cdn.example.com/last.png",
|
||||
)
|
||||
|
||||
def test_text_to_video_payload(self):
|
||||
body = build_request_body(
|
||||
prompt="月球上的宇航员",
|
||||
@@ -378,10 +463,15 @@ class MiniMaxH3ClientTests(unittest.TestCase):
|
||||
schema.validate()
|
||||
self.assertIsNotNone(schema)
|
||||
self.assertEqual(
|
||||
[item.id for item in schema.inputs[-2:]],
|
||||
["模型", "seed"],
|
||||
[item.id for item in schema.inputs],
|
||||
["提示词", "模型", "生成模式", "分辨率", "时长", "seed"],
|
||||
)
|
||||
seed_input = schema.inputs[-1]
|
||||
self.assertEqual(schema.inputs[1].options,
|
||||
["MiniMax-H3", "MiniMax-H3-MAX", MODEL_HIGHSPEED_ID, MODEL_LITE_ID])
|
||||
mode_options = [option.key for option in schema.inputs[2].options]
|
||||
self.assertEqual(mode_options[0], "多模态生视频")
|
||||
self.assertNotIn(LEGACY_MODE_REFERENCE, mode_options)
|
||||
self.assertEqual(seed_input.default, 0)
|
||||
self.assertEqual(seed_input.min, 0)
|
||||
self.assertEqual(seed_input.max, MAX_SEED)
|
||||
@@ -411,6 +501,20 @@ class MiniMaxH3ClientTests(unittest.TestCase):
|
||||
|
||||
|
||||
class MiniMaxH3PollingTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_lite_invalid_ratio_is_rejected_before_upload_or_paid_request(self):
|
||||
with (
|
||||
patch("comfyui_o1key.nodes.minimax_h3_video.upload_image", new_callable=AsyncMock) as upload,
|
||||
patch("comfyui_o1key.nodes.minimax_h3_video.MiniMaxH3Client") as client,
|
||||
):
|
||||
with self.assertRaisesRegex(ValueError, "具体宽高比"):
|
||||
await MiniMaxH3Video.execute(
|
||||
提示词="x", 生成模式={"生成模式": LEGACY_MODE_REFERENCE, "宽高比": "adaptive",
|
||||
"参考图片": object()},
|
||||
分辨率="480P", 时长=4, 模型=MODEL_LITE_ID,
|
||||
)
|
||||
upload.assert_not_awaited()
|
||||
client.assert_not_called()
|
||||
|
||||
@staticmethod
|
||||
def _response(payload):
|
||||
response = AsyncMock()
|
||||
|
||||
@@ -3686,7 +3686,7 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
nodes: [{ type: "MiniMaxH3Video", widgets_values: legacyMiniMaxValues }],
|
||||
};
|
||||
migrationExtension.beforeConfigureGraph(legacyMiniMaxGraph);
|
||||
assert.deepEqual(legacyMiniMaxValues.slice(-2), ["MiniMax-H3", 0]);
|
||||
assert.deepEqual(legacyMiniMaxValues, ["prompt", "MiniMax-H3", "文生视频", "16:9", "2K", 5, 0]);
|
||||
assert.equal(legacyMiniMaxValues.length, 7);
|
||||
migrationExtension.beforeConfigureGraph(legacyMiniMaxGraph);
|
||||
assert.equal(legacyMiniMaxValues.length, 7);
|
||||
@@ -3697,7 +3697,48 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
migrationExtension.beforeConfigureGraph({
|
||||
nodes: [{ type: "MiniMaxH3Video", widgets_values: modelOnlyMiniMaxValues }],
|
||||
});
|
||||
assert.deepEqual(modelOnlyMiniMaxValues.slice(-2), ["MiniMax-H3-MAX", 0]);
|
||||
assert.deepEqual(modelOnlyMiniMaxValues, ["prompt", "MiniMax-H3-MAX", "文生视频", "16:9", "2K", 5, 0]);
|
||||
for (const model of ["MiniMax-H3", "MiniMax-H3-MAX", "MiniMax-H3-Highspeed", "MiniMax-H3-Lite"]) {
|
||||
// A current workflow must survive repeated migration without extra defaults.
|
||||
const values = ["prompt", "参考素材生视频", "16:9", "480P", 4, model, 42];
|
||||
const saved = [...values];
|
||||
const graph = { nodes: [{ type: "MiniMaxH3Video", widgets_values: values }] };
|
||||
migrationExtension.beforeConfigureGraph(graph);
|
||||
migrationExtension.beforeConfigureGraph(graph);
|
||||
const current = ["prompt", model, "多模态生视频", "16:9", "480P", 4, 42];
|
||||
assert.deepEqual(values, current);
|
||||
for (const control of ["fixed", "increment", "decrement", "randomize"]) {
|
||||
const withSeedControl = [...saved, control];
|
||||
const controlGraph = {
|
||||
nodes: [{ type: "MiniMaxH3Video", widgets_values: withSeedControl }],
|
||||
};
|
||||
migrationExtension.beforeConfigureGraph(controlGraph);
|
||||
migrationExtension.beforeConfigureGraph(controlGraph);
|
||||
assert.deepEqual(withSeedControl, [...current, control]);
|
||||
}
|
||||
const withoutSeed = saved.slice(0, -1);
|
||||
migrationExtension.beforeConfigureGraph({
|
||||
nodes: [{ type: "MiniMaxH3Video", widgets_values: withoutSeed }],
|
||||
});
|
||||
assert.deepEqual(withoutSeed, [...current.slice(0, -1), 0]);
|
||||
const nested = [...saved];
|
||||
const nestedGraph = { definitions: { subgraphs: [{ nodes: [
|
||||
{ type: "MiniMaxH3Video", widgets_values: nested },
|
||||
] }] } };
|
||||
migrationExtension.beforeConfigureGraph(nestedGraph);
|
||||
migrationExtension.beforeConfigureGraph(nestedGraph);
|
||||
assert.deepEqual(nested, current);
|
||||
|
||||
// Model-first workflows, including text mode, keep their selected mode and values.
|
||||
for (const mode of ["多模态生视频", "文生视频", "首帧图生视频", "首尾帧生视频"]) {
|
||||
const currentValues = ["prompt", model, mode, "768P", 8, 123, "randomize"];
|
||||
const expected = [...currentValues];
|
||||
const currentGraph = { nodes: [{ type: "MiniMaxH3Video", widgets_values: currentValues }] };
|
||||
migrationExtension.beforeConfigureGraph(currentGraph);
|
||||
migrationExtension.beforeConfigureGraph(currentGraph);
|
||||
assert.deepEqual(currentValues, expected);
|
||||
}
|
||||
}
|
||||
assert.equal(legacyValues[13], "auto");
|
||||
assert.equal(legacyValues[14], false);
|
||||
assert.equal(legacyValues[15], "整组素材→多个目标");
|
||||
@@ -4225,12 +4266,12 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
callback(nextValue) { callbacks.push([name, nextValue]); },
|
||||
});
|
||||
const model = widget("模型", "MiniMax-H3");
|
||||
const mode = widget("生成模式", "参考素材生视频");
|
||||
const mode = widget("生成模式", "多模态生视频");
|
||||
const resolution = widget("分辨率", "2K");
|
||||
const duration = widget("时长", 4);
|
||||
const node = {
|
||||
comfyClass: "MiniMaxH3Video",
|
||||
widgets: [mode, resolution, duration, model],
|
||||
widgets: [model, mode, resolution, duration],
|
||||
setDirtyCanvas() {},
|
||||
};
|
||||
|
||||
@@ -4243,11 +4284,72 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
assert.equal(duration.value, 5);
|
||||
assert.equal(mode.value, "文生视频");
|
||||
|
||||
mode.value = "参考素材生视频";
|
||||
mode.value = "多模态生视频";
|
||||
mode.callback(mode.value);
|
||||
assert.equal(mode.value, "文生视频");
|
||||
assert.ok(notices.length >= 1);
|
||||
assert.ok(callbacks.some(([name, value]) => name === "生成模式" && value === "文生视频"));
|
||||
|
||||
const ratio = widget("生成模式.宽高比", "adaptive");
|
||||
node.widgets.push(ratio);
|
||||
for (const nextModel of ["MiniMax-H3-Highspeed", "MiniMax-H3-Lite"]) {
|
||||
mode.value = "多模态生视频";
|
||||
resolution.value = "2K";
|
||||
duration.value = 4;
|
||||
ratio.value = "adaptive";
|
||||
model.value = nextModel;
|
||||
model.callback(nextModel);
|
||||
assert.deepEqual(Array.from(resolution.options.values), ["768P", "480P"]);
|
||||
assert.equal(resolution.value, "768P");
|
||||
assert.equal(duration.options.min, 4);
|
||||
assert.equal(duration.value, 4);
|
||||
assert.equal(mode.value, "多模态生视频");
|
||||
assert.equal(ratio.options.values.includes("adaptive"), nextModel !== "MiniMax-H3-Lite");
|
||||
assert.equal(ratio.value, nextModel === "MiniMax-H3-Lite" ? "16:9" : "adaptive");
|
||||
resolution.value = "480P";
|
||||
resolution.callback("480P");
|
||||
assert.equal(resolution.value, "480P");
|
||||
resolution.value = "1080P";
|
||||
resolution.callback("1080P");
|
||||
assert.equal(resolution.value, "768P");
|
||||
mode.value = "尾帧图生视频";
|
||||
mode.callback(mode.value);
|
||||
assert.equal(mode.value, "首尾帧生视频");
|
||||
}
|
||||
|
||||
mode.value = "多模态生视频";
|
||||
mode.callback(mode.value);
|
||||
ratio.value = "adaptive";
|
||||
ratio.callback(ratio.value);
|
||||
assert.equal(ratio.value, "16:9");
|
||||
assert.deepEqual(callbacks.at(-1), ["生成模式.宽高比", "16:9"]);
|
||||
ratio.value = "9:16";
|
||||
model.value = "MiniMax-H3-Highspeed";
|
||||
model.callback(model.value);
|
||||
assert.equal(ratio.value, "9:16");
|
||||
assert.equal(ratio.options.values.includes("adaptive"), true);
|
||||
|
||||
// Dynamic mode changes replace child widgets; guard the replacement too.
|
||||
const replacementRatio = widget("宽高比", "adaptive");
|
||||
node.widgets.pop();
|
||||
mode.childWidgets = [replacementRatio];
|
||||
model.value = "MiniMax-H3-Lite";
|
||||
model.callback(model.value);
|
||||
assert.equal(replacementRatio.value, "16:9");
|
||||
const callbackAfterGuard = model.callback;
|
||||
minimaxExtension.loadedGraphNode(node);
|
||||
minimaxExtension.nodeCreated(node);
|
||||
assert.equal(model.callback, callbackAfterGuard);
|
||||
replacementRatio.value = "adaptive";
|
||||
minimaxExtension.loadedGraphNode(node);
|
||||
assert.equal(replacementRatio.value, "16:9");
|
||||
|
||||
model.value = "MiniMax-H3";
|
||||
resolution.value = "480P";
|
||||
model.callback(model.value);
|
||||
assert.deepEqual(Array.from(resolution.options.values), ["2K", "768P"]);
|
||||
assert.equal(resolution.value, "768P");
|
||||
assert.equal(replacementRatio.options.values.includes("adaptive"), true);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -4323,11 +4425,25 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
modelWidget.callback(modelWidget.value);
|
||||
assert.equal(routeWidget.value, "国内");
|
||||
|
||||
modelWidget.value = "seedance 2.5 flash";
|
||||
routeWidget.value = "海外";
|
||||
resolutionWidget.value = "1080p";
|
||||
modelWidget.callback(modelWidget.value);
|
||||
assert.deepEqual(Array.from(resolutionWidget.options.values), ["480p", "720p"]);
|
||||
assert.deepEqual(Array.from(routeWidget.options.values), ["国内"]);
|
||||
assert.equal(routeWidget.value, "国内");
|
||||
assert.equal(resolutionWidget.value, "720p");
|
||||
assert.equal(durationWidget.options.values.at(-1), "30秒");
|
||||
routeWidget.value = "海外";
|
||||
routeWidget.callback("海外");
|
||||
assert.equal(routeWidget.value, "国内");
|
||||
|
||||
modelWidget.value = "seedance 2.0 fast";
|
||||
modelWidget.callback(modelWidget.value);
|
||||
assert.deepEqual(Array.from(resolutionWidget.options.values), ["480p", "720p"]);
|
||||
assert.equal(resolutionWidget.value, "720p");
|
||||
assert.equal(durationWidget.value, "15秒");
|
||||
assert.deepEqual(Array.from(routeWidget.options.values), ["海外", "国内"]);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -4506,6 +4622,13 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
);
|
||||
migrationExtension.beforeConfigureGraph({ nodes: [autoPassNode] });
|
||||
assert.equal(autoPassNode.widgets_values.length, 65);
|
||||
const flashNode = JSON.parse(JSON.stringify(autoPassNode));
|
||||
flashNode.widgets_values[1] = "seedance 2.5 flash";
|
||||
const flashValues = [...flashNode.widgets_values];
|
||||
const flashGraph = { definitions: { subgraphs: [{ nodes: [flashNode] }] } };
|
||||
migrationExtension.beforeConfigureGraph(flashGraph);
|
||||
migrationExtension.beforeConfigureGraph(flashGraph);
|
||||
assert.deepEqual(flashNode.widgets_values, flashValues);
|
||||
|
||||
const legacyFrameNode = {
|
||||
type: "SeedanceAutoPass",
|
||||
@@ -4793,6 +4916,14 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
node.inputs = [{name: "样片任务ID输入", link: null}];
|
||||
node.onConnectionsChange?.();
|
||||
assert.equal(taskId.hidden, false);
|
||||
|
||||
model.value = "seedance 2.5 flash";
|
||||
model.callback(model.value);
|
||||
assert.equal(draft.value, "关闭");
|
||||
assert.equal(draft.hidden, true);
|
||||
assert.equal(taskId.hidden, true);
|
||||
assert.deepEqual(Array.from(resolution.options.values), ["480p", "720p"]);
|
||||
assert.equal(duration.options.values.at(-1), "30秒");
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -192,6 +192,7 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(inputs["主模型"].options, [
|
||||
"seedance 2.5",
|
||||
"seedance 2.5 flash",
|
||||
"seedance 2.0",
|
||||
"seedance 2.0 fast",
|
||||
"seedance 2.0 mini",
|
||||
@@ -218,6 +219,44 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"dreamina-seedance-2-5-hc",
|
||||
)
|
||||
|
||||
def test_seedance_25_flash_route_limits_and_payload(self):
|
||||
model = "seedance 2.5 flash"
|
||||
self.assertEqual(_resolve_model_matrix(model, "国内"), "doubao-seedance-2-5-flash")
|
||||
with self.assertRaises(ValueError):
|
||||
_resolve_model_matrix(model, "海外")
|
||||
SeedanceAutoPass._validate_dynamic_parameters(
|
||||
model, "国内", "30秒", [object()] * 10, [object()] * 5, [object()] * 5,
|
||||
)
|
||||
for images, videos, audios in ((11, 0, 0), (0, 6, 0), (0, 0, 6)):
|
||||
with self.subTest(images=images, videos=videos, audios=audios), self.assertRaisesRegex(ValueError, "最多支持"):
|
||||
SeedanceAutoPass._validate_dynamic_parameters(
|
||||
model, "国内", "30秒", [object()] * images,
|
||||
[object()] * videos, [object()] * audios,
|
||||
)
|
||||
for mode in ("text", "first_frame", "first_last_frame", "multimodal", "edit", "extend"):
|
||||
normalized = SeedanceAutoPass._normalize_generation_parameters(
|
||||
mode, model, "国内", "test prompt", "720p", "16:9", "30秒", True, False,
|
||||
)
|
||||
self.assertEqual(normalized["actual_model"], "doubao-seedance-2-5-flash")
|
||||
if mode in ("first_frame", "first_last_frame", "edit", "extend"):
|
||||
self.assertEqual(normalized["aspect_ratio"], "auto")
|
||||
self.assertEqual(normalized["duration"], -1 if mode == "edit" else 30)
|
||||
with self.assertRaisesRegex(ValueError, "分辨率仅支持"):
|
||||
SeedanceAutoPass._normalize_generation_parameters(
|
||||
"text", model, "国内", "x", "1080p", "16:9", "4秒", False, False,
|
||||
)
|
||||
self.assertEqual(SeedanceAutoPass._validate_mode_inputs(
|
||||
"多模态", model, "prompt", [], [], [object()],
|
||||
), "multimodal")
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"doubao-seedance-2-5-flash", "test prompt", "720p", "auto", 30,
|
||||
True, False, [], ["https://cdn.example.com/video.mp4"], [],
|
||||
generation_mode="extend", output_format="mov",
|
||||
)
|
||||
self.assertEqual(body["model"], "doubao-seedance-2-5-flash")
|
||||
self.assertEqual(body["omni_reference_task_type"], "extend")
|
||||
self.assertEqual(body["output_format"], "mov")
|
||||
|
||||
def test_seedance_25_accepts_its_maximum_dynamic_parameters(self):
|
||||
SeedanceAutoPass._validate_dynamic_parameters(
|
||||
"seedance 2.5",
|
||||
@@ -522,6 +561,33 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
|
||||
|
||||
class SeedanceAutoPassExecuteTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_flash_execution_and_invalid_options_stop_before_upload(self):
|
||||
parameters = {
|
||||
"提示词": "test prompt", "生成模式": {"生成模式": "多模态"},
|
||||
"主模型": "seedance 2.5 flash", "模型线路": "国内",
|
||||
"分辨率": "720p", "宽高比": "16:9", "时长": "30秒",
|
||||
"生成音频": "关闭", "seed": 0,
|
||||
}
|
||||
with (
|
||||
patch.object(SeedanceAutoPass, "_upload_assets", AsyncMock(return_value=([], [], []))) as upload,
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", AsyncMock(return_value=("result.mp4", None))) as submit,
|
||||
patch.object(InputImpl, "VideoFromFile", return_value=object()),
|
||||
patch("comfyui_o1key.nodes.seedance_autopass.get_base_url_by_route", return_value="https://api.example.com"),
|
||||
):
|
||||
await SeedanceAutoPass.execute(**parameters)
|
||||
body = submit.await_args.args[0]
|
||||
self.assertEqual(body["model"], "doubao-seedance-2-5-flash")
|
||||
self.assertEqual(body["duration"], 30)
|
||||
self.assertNotIn("draft", body)
|
||||
upload.reset_mock()
|
||||
submit.reset_mock()
|
||||
for overrides in ({"分辨率": "1080p"}, {"模型线路": "海外"},
|
||||
{"时长": "31秒"}, {"样片模式": "生成样片"}):
|
||||
with self.subTest(overrides=overrides), self.assertRaises(ValueError):
|
||||
await SeedanceAutoPass.execute(**(parameters | overrides))
|
||||
upload.assert_not_awaited()
|
||||
submit.assert_not_awaited()
|
||||
|
||||
async def test_automatic_frame_mode_rejects_last_frame_without_first_frame(self):
|
||||
with self.assertRaisesRegex(ValueError, "必须提供首帧图片"):
|
||||
await SeedanceAutoPass.execute(**{
|
||||
|
||||
Reference in New Issue
Block a user