Publish Seedance 2.5 draft mode and video updates
- Add the 样片模式 flow: 480p draft generation, a linkable draft task ID, and pre-flight verification before the 1080p final request. - Allow reference images and audio in video edit/extend requests, matching the provider's 2.5 contract. - Move 主模型 and 样片模式 ahead of 生成模式, default 主模型 to seedance 2.5, and migrate saved widget values. - Refresh the video panel, asset API response logs, and LLM node handling; cover the new behavior with offline tests.
This commit is contained in:
@@ -7,20 +7,26 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class ChatPanelModelTests(unittest.TestCase):
|
||||
def test_gpt_6_astra_is_the_frontend_and_proxy_default(self):
|
||||
def test_chat_model_list_uses_current_gpt_model_names(self):
|
||||
frontend = (ROOT / "web" / "js" / "chatPanel.js").read_text(encoding="utf-8")
|
||||
backend = (ROOT / "__init__.py").read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn('const DEFAULT_MODEL = "gpt-6-sol";', frontend)
|
||||
self.assertIn('const DEFAULT_MODEL = "claude-opus-5-5";', frontend)
|
||||
self.assertIn("let currentModel = DEFAULT_MODEL;", frontend)
|
||||
models = re.search(r"const MODELS = \[(.*?)\];", frontend, re.DOTALL)
|
||||
self.assertIsNotNone(models)
|
||||
self.assertEqual(models.group(1).strip().splitlines()[0].strip(), "DEFAULT_MODEL,")
|
||||
model_list = models.group(1).strip()
|
||||
self.assertEqual(model_list.splitlines()[0].strip(), "DEFAULT_MODEL,")
|
||||
self.assertIn('"gemini-4-argon"', model_list)
|
||||
self.assertIn('"gpt-6.1-sol"', model_list)
|
||||
self.assertNotIn('"gpt-6-sol"', model_list)
|
||||
self.assertNotIn('"gpt-5.5"', model_list)
|
||||
|
||||
self.assertIn('data.get("model", "gpt-6-sol")', backend)
|
||||
self.assertIn('data.get("model", "claude-opus-5-5")', backend)
|
||||
self.assertIn('if model in ("claude-fable-5", "claude-opus-5-5"):', backend)
|
||||
self.assertRegex(
|
||||
backend,
|
||||
r'elif model in \([^\n]*"gpt-6-sol"[^\n]*\):\n\s+body\["reasoning_effort"\] = reasoning',
|
||||
r'elif model in \([^\n]*"gpt-6\.1-sol"[^\n]*\):\n\s+body\["reasoning_effort"\] = reasoning',
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3877,9 +3877,9 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
};
|
||||
dynamicExtension.nodeCreated(node);
|
||||
|
||||
assert.deepEqual(Array.from(resolutionWidget.options.values), ["480p", "720p", "1080p", "4k"]);
|
||||
assert.deepEqual(Array.from(resolutionWidget.options.values), ["480p", "720p", "1080p"]);
|
||||
assert.equal(routeWidget.value, "海外");
|
||||
assert.equal(resolutionWidget.value, "4k");
|
||||
assert.equal(resolutionWidget.value, "720p");
|
||||
assert.equal(durationWidget.options.values.at(-1), "30秒");
|
||||
|
||||
routeWidget.value = "国内";
|
||||
@@ -3917,8 +3917,8 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
};
|
||||
guardExtension.nodeCreated(node);
|
||||
|
||||
assert.deepEqual(Array.from(resolutionWidget.options.values), ["720p", "1080p", "4k", "480p"]);
|
||||
assert.equal(resolutionWidget.value, "4k");
|
||||
assert.deepEqual(Array.from(resolutionWidget.options.values), ["720p", "1080p", "480p"]);
|
||||
assert.equal(resolutionWidget.value, "720p");
|
||||
assert.equal(durationWidget.options.values.at(-1), "30秒");
|
||||
|
||||
modelWidget.value = "seedance 2.0 fast";
|
||||
@@ -4062,12 +4062,13 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
assert.deepEqual(
|
||||
Array.from(autoPassNode.widgets_values),
|
||||
[
|
||||
"提示词", "多模态", "seedance 2.5", "国内",
|
||||
"提示词", "seedance 2.5", "关闭", "多模态", "国内",
|
||||
"720p", "智能", "5秒", "关闭", "关闭", ...Array(50).fill(""), "关闭", 0, "关闭",
|
||||
"mp4", "",
|
||||
],
|
||||
);
|
||||
migrationExtension.beforeConfigureGraph({ nodes: [autoPassNode] });
|
||||
assert.equal(autoPassNode.widgets_values.length, 62);
|
||||
assert.equal(autoPassNode.widgets_values.length, 65);
|
||||
|
||||
const legacyFrameNode = {
|
||||
type: "SeedanceAutoPass",
|
||||
@@ -4084,8 +4085,9 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
assert.deepEqual(
|
||||
Array.from(legacyFrameNode.widgets_values),
|
||||
[
|
||||
"提示词", "首尾帧", "seedance 2.0", "海外",
|
||||
"提示词", "seedance 2.0", "关闭", "首尾帧", "海外",
|
||||
"720p", "16:9", "5秒", "关闭", "关闭", ...Array(50).fill(""), "打开", 9, "打开",
|
||||
"mp4", "",
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
@@ -4093,7 +4095,7 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
["联网搜索", "首帧图片"],
|
||||
);
|
||||
migrationExtension.beforeConfigureGraph({ nodes: [legacyFrameNode] });
|
||||
assert.equal(legacyFrameNode.widgets_values.length, 62);
|
||||
assert.equal(legacyFrameNode.widgets_values.length, 65);
|
||||
|
||||
const legacyIdNode = {
|
||||
type: "SeedanceAutoPass",
|
||||
@@ -4104,13 +4106,33 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
],
|
||||
};
|
||||
migrationExtension.beforeConfigureGraph({nodes: [legacyIdNode]});
|
||||
assert.equal(legacyIdNode.widgets_values.length, 62);
|
||||
assert.equal(legacyIdNode.widgets_values[8], "打开");
|
||||
assert.deepEqual(legacyIdNode.widgets_values.slice(9, 12), ["image-1", "image-2", "asset://image-3"]);
|
||||
assert.deepEqual(legacyIdNode.widgets_values.slice(39, 41), ["video-1", "video-2"]);
|
||||
assert.equal(legacyIdNode.widgets_values[49], "audio-1");
|
||||
assert.deepEqual(legacyIdNode.widgets_values.slice(59), ["打开", 42, "打开"]);
|
||||
assert.equal(legacyIdNode.widgets_values.length, 65);
|
||||
assert.equal(legacyIdNode.widgets_values[9], "打开");
|
||||
assert.deepEqual(legacyIdNode.widgets_values.slice(10, 13), ["image-1", "image-2", "asset://image-3"]);
|
||||
assert.deepEqual(legacyIdNode.widgets_values.slice(40, 42), ["video-1", "video-2"]);
|
||||
assert.equal(legacyIdNode.widgets_values[50], "audio-1");
|
||||
assert.deepEqual(legacyIdNode.widgets_values.slice(60), ["打开", 42, "打开", "mp4", ""]);
|
||||
assert.deepEqual(legacyIdNode.inputs.map(input => input.name), ["图片素材ID1", "视频素材ID1", "素材创建模式"]);
|
||||
|
||||
const currentLayoutNode = {
|
||||
type: "SeedanceAutoPass",
|
||||
inputs: [],
|
||||
widgets_values: [
|
||||
"提示词", "视频编辑", "seedance 2.5", "国内", "480p", "智能", "自动", "关闭",
|
||||
"自动创建", ...Array(50).fill(""), "关闭", 0, "关闭", "mp4", "生成样片", "cgt-20260101120000",
|
||||
],
|
||||
};
|
||||
migrationExtension.beforeConfigureGraph({nodes: [currentLayoutNode]});
|
||||
assert.deepEqual(
|
||||
Array.from(currentLayoutNode.widgets_values),
|
||||
[
|
||||
"提示词", "seedance 2.5", "生成样片", "视频编辑", "国内", "480p", "智能", "自动", "关闭",
|
||||
"自动创建", ...Array(50).fill(""), "关闭", 0, "关闭", "mp4", "cgt-20260101120000",
|
||||
],
|
||||
);
|
||||
const migratedCurrent = [...currentLayoutNode.widgets_values];
|
||||
migrationExtension.beforeConfigureGraph({nodes: [currentLayoutNode]});
|
||||
assert.deepEqual(currentLayoutNode.widgets_values, migratedCurrent);
|
||||
const migratedIds = [...legacyIdNode.widgets_values];
|
||||
migrationExtension.beforeConfigureGraph({nodes: [legacyIdNode]});
|
||||
assert.deepEqual(legacyIdNode.widgets_values, migratedIds);
|
||||
@@ -4254,13 +4276,14 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
setSize(value) {this.size = value;}, setDirtyCanvas() {},
|
||||
};
|
||||
extension.nodeCreated(node);
|
||||
for (const widget of [search, lastFrame]) {
|
||||
for (const widget of [search]) {
|
||||
assert.equal(widget.hidden, true);
|
||||
assert.equal(widget.options.hidden, true);
|
||||
assert.deepEqual(Array.from(widget.computeSize()), [0, -4]);
|
||||
assert.equal(widget.value, "打开", "hiding must preserve saved workflow values");
|
||||
}
|
||||
assert.deepEqual(Array.from(node.size), [360, 148]);
|
||||
assert.notEqual(lastFrame.hidden, true, "the last-frame output stays configurable");
|
||||
assert.deepEqual(Array.from(node.size), [360, 172]);
|
||||
assert.equal(assetMode.hidden, false);
|
||||
assert.notEqual(seed.hidden, true);
|
||||
assert.equal(seed.value, 42);
|
||||
@@ -4272,7 +4295,8 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
extension.loadedGraphNode(node);
|
||||
assetMode.value = "打开";
|
||||
assetMode.callback(assetMode.value);
|
||||
assert.ok(search.hidden && lastFrame.hidden);
|
||||
assert.ok(search.hidden);
|
||||
assert.notEqual(lastFrame.hidden, true);
|
||||
assert.deepEqual(node.widgets, widgets);
|
||||
assert.deepEqual(node.widgets.map(widget => widget.value), ["打开", "打开", 42, "打开"]);
|
||||
const otherWidgets = [{name: "联网搜索", value: "关闭", options: {}}, {name: "返回末帧图片", value: "关闭", options: {}}];
|
||||
@@ -4280,10 +4304,64 @@ assert.match(migrationSource, /原生 seed 参数/);
|
||||
assert.ok(otherWidgets.every(widget => !widget.hidden), "hide only the single all-in-one node");
|
||||
}
|
||||
|
||||
console.log("o1key image generator frontend tests passed");
|
||||
{
|
||||
let extension;
|
||||
vm.runInNewContext(seedanceAutoPassDynamicSource.replace(/^import .*;\s*$/gm, ""), {
|
||||
app: {registerExtension(value) {extension = value;}}, console,
|
||||
});
|
||||
const makeWidget = (name, value, values = []) => ({name, value, options: {values}, callback() {}});
|
||||
const model = makeWidget("主模型", "seedance 2.5", ["seedance 2.0", "seedance 2.5"]);
|
||||
const route = makeWidget("模型线路", "国内", ["海外", "国内"]);
|
||||
const resolution = makeWidget("分辨率", "1080p", ["480p", "720p", "1080p"]);
|
||||
const duration = makeWidget("时长", "5秒", ["自动", "5秒"]);
|
||||
const draft = makeWidget("样片模式", "关闭", ["关闭", "生成样片", "按样片生成"]);
|
||||
const taskId = {name: "样片任务ID", value: "", options: {}};
|
||||
const node = {
|
||||
comfyClass: "SeedanceAutoPass",
|
||||
widgets: [model, route, resolution, duration, draft, taskId],
|
||||
size: [360, 600],
|
||||
computeSize() { return [360, 600]; },
|
||||
setSize(size) { this.size = size; },
|
||||
setDirtyCanvas() {},
|
||||
inputs: [],
|
||||
comfyDynamic: {autogrow: {}},
|
||||
addInput() {},
|
||||
removeInput() {},
|
||||
};
|
||||
extension.nodeCreated(node);
|
||||
assert.equal(taskId.hidden, true, "sample task id stays hidden until needed");
|
||||
assert.equal(draft.hidden, false);
|
||||
|
||||
draft.value = "生成样片";
|
||||
draft.callback("生成样片");
|
||||
assert.equal(resolution.value, "480p");
|
||||
assert.deepEqual(Array.from(resolution.options.values), ["480p"]);
|
||||
|
||||
model.value = "seedance 2.0";
|
||||
model.callback("seedance 2.0");
|
||||
assert.equal(draft.value, "关闭");
|
||||
assert.equal(draft.hidden, true);
|
||||
assert.ok(resolution.options.values.includes("1080p"));
|
||||
|
||||
model.value = "seedance 2.5";
|
||||
model.callback("seedance 2.5");
|
||||
assert.equal(draft.hidden, false);
|
||||
draft.value = "按样片生成";
|
||||
draft.callback("按样片生成");
|
||||
assert.equal(taskId.hidden, false);
|
||||
|
||||
node.inputs = [{name: "样片任务ID输入", link: 7}];
|
||||
node.onConnectionsChange?.();
|
||||
assert.equal(taskId.hidden, true, "linked draft task id hides the manual field");
|
||||
node.inputs = [{name: "样片任务ID输入", link: null}];
|
||||
node.onConnectionsChange?.();
|
||||
assert.equal(taskId.hidden, false);
|
||||
}
|
||||
|
||||
console.log("o1key image generator frontend tests passed");
|
||||
const nanoThinkingSource = fs.readFileSync(new URL("../web/js/nanoBananaThinkingLevel.js", import.meta.url), "utf8");
|
||||
|
||||
|
||||
{
|
||||
let thinkingExtension;
|
||||
vm.runInNewContext(nanoThinkingSource.replace(/^import .*;\s*$/gm, ""), {
|
||||
|
||||
@@ -43,6 +43,7 @@ from comfyui_o1key.utils.o1key_video_catalog import ( # noqa: E402
|
||||
normalize_seedance_parameters,
|
||||
public_video_capabilities,
|
||||
resolve_seedance_model,
|
||||
validate_seedance_reference_durations,
|
||||
)
|
||||
|
||||
|
||||
@@ -86,17 +87,24 @@ class CatalogTests(unittest.TestCase):
|
||||
normalize_seedance_parameters(payload(model="seedance-2.0-fast", resolution="1080p"))
|
||||
with self.assertRaises(ValueError):
|
||||
normalize_seedance_parameters(payload(model="seedance-2.0", duration="16"))
|
||||
result = normalize_seedance_parameters(payload(model="seedance-2.5", duration="30", resolution="4k"))
|
||||
result = normalize_seedance_parameters(payload(model="seedance-2.5", duration="30", resolution="1080p"))
|
||||
self.assertEqual(result["duration"], 30)
|
||||
with self.assertRaisesRegex(ValueError, "分辨率仅支持"):
|
||||
normalize_seedance_parameters(payload(model="seedance-2.5", resolution="4k"))
|
||||
self.assertEqual(
|
||||
normalize_seedance_parameters(payload(duration="auto"))["duration"],
|
||||
-1,
|
||||
)
|
||||
|
||||
def test_asset_creation_mode_defaults_and_options(self):
|
||||
normalized = normalize_seedance_parameters({
|
||||
key: value for key, value in payload().items()
|
||||
if key != "asset_creation_mode"
|
||||
})
|
||||
self.assertEqual(normalized["asset_creation_mode"], "auto")
|
||||
self.assertEqual(normalized["asset_creation_mode"], "direct")
|
||||
modes = public_video_capabilities()["providers"][0]["asset_creation_modes"]
|
||||
self.assertEqual(modes, [
|
||||
{"value": "direct", "label": "直接上传"},
|
||||
{"value": "auto", "label": "自动创建"},
|
||||
{"value": "manual", "label": "手动"},
|
||||
])
|
||||
@@ -178,6 +186,126 @@ class PayloadAndBodyTests(unittest.TestCase):
|
||||
self.assertNotIn("web_search", body)
|
||||
self.assertNotIn("online_search", body)
|
||||
|
||||
def test_reference_durations_apply_per_item_and_total_limits(self):
|
||||
self.assertEqual(validate_seedance_reference_durations("seedance-2.0", [10, 5], [15]), None)
|
||||
with self.assertRaisesRegex(ValueError, "总时长"):
|
||||
validate_seedance_reference_durations("seedance-2.0", [10, 10], [])
|
||||
with self.assertRaisesRegex(ValueError, "时长必须在"):
|
||||
validate_seedance_reference_durations("seedance-2.0", [16], [])
|
||||
validate_seedance_reference_durations("seedance-2.5", [20, 10], [30])
|
||||
|
||||
def test_seed_is_never_part_of_the_request(self):
|
||||
job = JOBS.normalize_video_job_payload(payload(seed=2**63))
|
||||
self.assertNotIn("seed", job)
|
||||
body = JOBS.build_seedance_video_body(job, {
|
||||
"first_frame": None,
|
||||
"last_frame": None,
|
||||
"reference_images": [],
|
||||
"reference_videos": [],
|
||||
"reference_audios": [],
|
||||
})
|
||||
self.assertNotIn("seed", body)
|
||||
|
||||
def test_reference_only_body_keeps_text_item_and_adaptive_ratio(self):
|
||||
job = JOBS.normalize_video_job_payload(payload(
|
||||
generation_mode="multimodal",
|
||||
asset_creation_mode="manual",
|
||||
prompt="",
|
||||
aspect_ratio="auto",
|
||||
assets={"images": ["image-1"]},
|
||||
))
|
||||
body = JOBS.build_seedance_video_body(job, {
|
||||
"first_frame": None,
|
||||
"last_frame": None,
|
||||
"reference_images": [],
|
||||
"reference_videos": [],
|
||||
"reference_audios": [],
|
||||
})
|
||||
self.assertEqual(body["content"][0]["type"], "text")
|
||||
self.assertTrue(body["content"][0]["text"])
|
||||
self.assertEqual(body["ratio"], "adaptive")
|
||||
self.assertEqual(
|
||||
[item.get("role") for item in body["content"] if item["type"] == "image_url"],
|
||||
["reference_image"],
|
||||
)
|
||||
|
||||
def test_edit_and_extend_modes_use_reference_video(self):
|
||||
clip = {"name": "clip.mp4", "type": "input"}
|
||||
edit = JOBS.normalize_video_job_payload(payload(
|
||||
model="seedance-2.5",
|
||||
generation_mode="edit",
|
||||
media={"reference_videos": [clip]},
|
||||
duration="10",
|
||||
aspect_ratio="16:9",
|
||||
))
|
||||
self.assertEqual(edit["duration"], -1)
|
||||
self.assertEqual(edit["aspect_ratio"], "auto")
|
||||
edit_body = JOBS.build_seedance_video_body(edit, {
|
||||
"first_frame": None,
|
||||
"last_frame": None,
|
||||
"reference_images": [],
|
||||
"reference_videos": ["https://example.invalid/clip.mp4"],
|
||||
"reference_audios": [],
|
||||
})
|
||||
self.assertEqual(edit_body["omni_reference_task_type"], "edit")
|
||||
self.assertEqual(edit_body["ratio"], "adaptive")
|
||||
self.assertEqual(
|
||||
[item["video_url"]["url"] for item in edit_body["content"] if item["type"] == "video_url"],
|
||||
["https://example.invalid/clip.mp4"],
|
||||
)
|
||||
|
||||
extend = JOBS.normalize_video_job_payload(payload(
|
||||
model="seedance-2.5",
|
||||
generation_mode="extend",
|
||||
media={"reference_videos": [clip]},
|
||||
duration="20",
|
||||
))
|
||||
self.assertEqual(extend["duration"], 20)
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "2.5"):
|
||||
JOBS.normalize_video_job_payload(payload(
|
||||
model="seedance-2.0",
|
||||
generation_mode="edit",
|
||||
media={"reference_videos": [clip]},
|
||||
))
|
||||
|
||||
def test_edit_and_extend_accept_reference_images(self):
|
||||
clip = {"name": "clip.mp4", "type": "input"}
|
||||
image = {"name": "person.png", "type": "input"}
|
||||
for mode in ("edit", "extend"):
|
||||
with self.subTest(mode=mode):
|
||||
job = JOBS.normalize_video_job_payload(payload(
|
||||
model="seedance-2.5",
|
||||
generation_mode=mode,
|
||||
prompt="把 @video1 里的男子替换为 @image1 的女子",
|
||||
media={
|
||||
"reference_images": [image],
|
||||
"reference_videos": [clip],
|
||||
},
|
||||
))
|
||||
body = JOBS.build_seedance_video_body(job, {
|
||||
"first_frame": None,
|
||||
"last_frame": None,
|
||||
"reference_images": ["https://example.invalid/person.png"],
|
||||
"reference_videos": ["https://example.invalid/clip.mp4"],
|
||||
"reference_audios": [],
|
||||
})
|
||||
self.assertEqual(body["omni_reference_task_type"], mode)
|
||||
self.assertEqual(body["ratio"], "adaptive")
|
||||
self.assertEqual(
|
||||
[item.get("role") for item in body["content"] if item["type"] != "text"],
|
||||
["reference_image", "reference_video"],
|
||||
)
|
||||
|
||||
def test_edit_mode_still_requires_one_reference_video(self):
|
||||
image = {"name": "person.png", "type": "input"}
|
||||
with self.assertRaisesRegex(ValueError, "必须且只能提供一段参考视频"):
|
||||
JOBS.normalize_video_job_payload(payload(
|
||||
model="seedance-2.5",
|
||||
generation_mode="edit",
|
||||
media={"reference_images": [image]},
|
||||
))
|
||||
|
||||
def test_multimodal_manual_asset_ids_respect_model_limits(self):
|
||||
with self.assertRaisesRegex(ValueError, "最多支持 9"):
|
||||
JOBS.normalize_video_job_payload(payload(
|
||||
@@ -492,5 +620,29 @@ class ParallelManagerTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertTrue(all(manager.status(item["batch_id"])["state"] == "completed" for item in submitted))
|
||||
|
||||
|
||||
class AssetPreparationTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_direct_mode_uploads_without_creating_assets(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
path = os.path.join(root, "first.png")
|
||||
Image.new("RGB", (300, 300)).save(path)
|
||||
job = {
|
||||
"route": "domestic",
|
||||
"asset_creation_mode": "direct",
|
||||
"assets": {},
|
||||
"snapshot_media": {"first_frame": path},
|
||||
}
|
||||
with (
|
||||
patch.object(JOBS, "upload_image", AsyncMock(return_value="https://cdn.example/first.png")) as upload,
|
||||
patch.object(JOBS, "SeedanceAssetService") as service,
|
||||
patch.object(JOBS, "get_base_url_by_route", return_value="https://api.example.com"),
|
||||
):
|
||||
prepared = await JOBS._prepare_seedance_media(job, lambda **kwargs: None)
|
||||
|
||||
upload.assert_awaited_once()
|
||||
service.assert_not_called()
|
||||
self.assertEqual(prepared["first_frame"], "https://cdn.example/first.png")
|
||||
self.assertEqual(job["resolved_assets"], {"images": [], "videos": [], "audios": []})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -40,9 +40,12 @@ assert.match(source, /value: "manual", label: "手动"/);
|
||||
assert.match(source, /makeField\("素材创建", assetCreation\)/);
|
||||
assert.match(source, /assetCreationField\.style\.display = isSeedance \? "grid" : "none"/);
|
||||
assert.match(source, /assetCreation\._trigger\.disabled = !assetModeAvailable/);
|
||||
assert.match(source, /imageIdField\.style\.display = manualAssets \? "grid" : "none"/);
|
||||
assert.match(source, /videoIdField\.style\.display = manualAssets && activeMode === "multimodal"/);
|
||||
assert.match(source, /asset_creation_mode: manualAssets \? "manual" : "auto"/);
|
||||
assert.match(source, /imageIdField\.style\.display = manualAssets && activeModeResolved === "multimodal" \? "grid" : "none"/);
|
||||
assert.match(source, /videoIdField\.style\.display = manualAssets && showsVideo \? "grid" : "none"/);
|
||||
assert.match(source, /asset_creation_mode: manualAssets \? "manual" : \(assetCreation\.value === "auto" \? "auto" : "direct"\)/);
|
||||
assert.match(source, /\{ value: "edit", label: "视频编辑"/);
|
||||
assert.match(source, /\{ value: "extend", label: "视频延长"/);
|
||||
assert.match(source, /\{ value: "direct", label: "直接上传"/);
|
||||
assert.match(source, /assets: manualAssets \? manualRequestAssets : \{\}/);
|
||||
assert.match(source, /function requestForRetry\(node\)/);
|
||||
assert.match(source, /request\.asset_creation_mode !== "auto"/);
|
||||
@@ -116,8 +119,8 @@ assert.doesNotMatch(multimodalSource, /添加\$\{source\.shortTitle\}/);
|
||||
assert.doesNotMatch(multimodalSource, /sourceInput|source\.input/);
|
||||
assert.match(source, /\.o1vg-multimodal-assets \.o1vg-add\{min-width:58px;height:29px;gap:4px;padding:0 10px;[^}]*font-size:11px;font-weight:600/);
|
||||
assert.match(source, /mediaHost\.append\(firstSection, lastSection, multimodalSection\)/);
|
||||
assert.match(source, /multimodalSection\.style\.display = !manualAssets && activeMode === "multimodal" \? "flex" : "none"/);
|
||||
assert.match(source, /automaticHeights = \{ text: 679, first_frame: 824, first_last_frame: 964, multimodal: 824 \}/);
|
||||
assert.match(source, /multimodalSection\.style\.display = !manualAssets && showsVideo \? "flex" : "none"/);
|
||||
assert.match(source, /automaticHeights = \{ text: 679, first_frame: 824, first_last_frame: 964, multimodal: 824, edit: 824, extend: 824 \}/);
|
||||
assert.match(source, /widget\(node, "generation_mode"\)\?\.value \|\| "multimodal"/);
|
||||
assert.match(source, /const restore = \(\) =>/);
|
||||
assert.match(source, /mode\.value = value\("generation_mode", "multimodal"\)/);
|
||||
|
||||
@@ -50,12 +50,15 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
self.assertIn("生成模式", inputs)
|
||||
self.assertEqual(
|
||||
[input_def.id for input_def in schema.inputs[:3]],
|
||||
["提示词", "生成模式", "主模型"],
|
||||
["提示词", "主模型", "样片模式"],
|
||||
)
|
||||
|
||||
mode_input = inputs["生成模式"]
|
||||
self.assertEqual(mode_input.io_type, "COMBO")
|
||||
self.assertEqual(mode_input.options, ["多模态", "首尾帧"])
|
||||
self.assertEqual(
|
||||
mode_input.options,
|
||||
["多模态", "首尾帧", "视频编辑", "视频延长"],
|
||||
)
|
||||
self.assertEqual(mode_input.default, "多模态")
|
||||
|
||||
expected = {
|
||||
@@ -78,11 +81,21 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
)
|
||||
self.assertTrue(inputs["首帧图片"].optional)
|
||||
self.assertTrue(inputs["尾帧图片"].optional)
|
||||
self.assertTrue(inputs["样片任务ID输入"].optional)
|
||||
self.assertTrue(inputs["样片任务ID输入"].force_input)
|
||||
self.assertEqual(
|
||||
inputs["样片任务ID输入"].display_name,
|
||||
"样片任务ID(连线)",
|
||||
)
|
||||
self.assertNotIn("自动创建素材", inputs)
|
||||
self.assertNotIn("素材创建", inputs)
|
||||
self.assertEqual(
|
||||
[input_def.id for input_def in schema.inputs[-3:]],
|
||||
["联网搜索", "seed", "返回末帧图片"],
|
||||
["返回末帧图片", "输出格式", "样片任务ID"],
|
||||
)
|
||||
self.assertEqual(
|
||||
[input_def.id for input_def in schema.inputs[-5:-1]],
|
||||
["联网搜索", "seed", "返回末帧图片", "输出格式"],
|
||||
)
|
||||
for prefix, maximum in (("图片素材ID", 30), ("视频素材ID", 10), ("音频素材ID", 10)):
|
||||
self.assertNotIn(prefix, inputs)
|
||||
@@ -92,12 +105,12 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
for former_advanced_name in ("联网搜索", "seed", "返回末帧图片"):
|
||||
self.assertFalse(inputs[former_advanced_name].advanced)
|
||||
self.assertEqual(inputs["素材创建模式"].io_type, "COMBO")
|
||||
self.assertEqual(inputs["素材创建模式"].options, ["关闭", "打开"])
|
||||
self.assertEqual(inputs["素材创建模式"].options, ["关闭", "自动创建", "手动"])
|
||||
self.assertEqual(inputs["素材创建模式"].default, "关闭")
|
||||
self.assertEqual(inputs["返回末帧图片"].default, "关闭")
|
||||
self.assertEqual(
|
||||
[output.display_name for output in schema.outputs],
|
||||
["视频", "末帧图片"],
|
||||
["视频", "末帧图片", "样片任务ID"],
|
||||
)
|
||||
|
||||
self.assertEqual(schema.display_name, "Seedance 全能生成视频")
|
||||
@@ -127,10 +140,12 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
for inputs, expected in [
|
||||
({}, "关闭"),
|
||||
({"素材创建模式": "关闭"}, "关闭"),
|
||||
({"素材创建模式": "打开"}, "打开"),
|
||||
({"素材创建": "自动创建"}, "关闭"),
|
||||
({"素材创建": "手动"}, "打开"),
|
||||
({"素材创建": {"素材创建": "手动"}}, "打开"),
|
||||
({"素材创建模式": "自动创建"}, "自动创建"),
|
||||
({"素材创建模式": "手动"}, "手动"),
|
||||
({"素材创建模式": "打开"}, "手动"),
|
||||
({"素材创建": "自动创建"}, "自动创建"),
|
||||
({"素材创建": "手动"}, "手动"),
|
||||
({"素材创建": {"素材创建": "手动"}}, "手动"),
|
||||
]:
|
||||
self.assertEqual(SeedanceAutoPass._asset_creation_inputs(inputs)[0], expected)
|
||||
|
||||
@@ -165,15 +180,23 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
|
||||
def test_v3_async_execution_adapter_is_active(self):
|
||||
self.assertEqual(SeedanceAutoPass.FUNCTION, "EXECUTE_NORMALIZED_ASYNC")
|
||||
self.assertEqual(SeedanceAutoPass.RETURN_TYPES, ["VIDEO", "IMAGE"])
|
||||
self.assertEqual(SeedanceAutoPass.RETURN_NAMES, ["视频", "末帧图片"])
|
||||
self.assertEqual(SeedanceAutoPass.RETURN_TYPES, ["VIDEO", "IMAGE", "STRING"])
|
||||
self.assertEqual(
|
||||
SeedanceAutoPass.RETURN_NAMES,
|
||||
["视频", "末帧图片", "样片任务ID"],
|
||||
)
|
||||
|
||||
def test_model_defaults_and_seedance_25_capabilities_are_exposed(self):
|
||||
schema = SeedanceAutoPass.GET_SCHEMA()
|
||||
inputs = {input_def.id: input_def for input_def in schema.inputs}
|
||||
|
||||
self.assertIn("seedance 2.5", inputs["主模型"].options)
|
||||
self.assertEqual(inputs["主模型"].default, "seedance 2.0")
|
||||
self.assertEqual(inputs["主模型"].options, [
|
||||
"seedance 2.5",
|
||||
"seedance 2.0",
|
||||
"seedance 2.0 fast",
|
||||
"seedance 2.0 mini",
|
||||
])
|
||||
self.assertEqual(inputs["主模型"].default, "seedance 2.5")
|
||||
self.assertEqual(inputs["模型线路"].default, "国内")
|
||||
self.assertEqual(inputs["模型线路"].options, ["海外", "国内"])
|
||||
self.assertEqual(inputs["分辨率"].default, "720p")
|
||||
@@ -253,8 +276,15 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
|
||||
def test_mode_validation_matches_seedance_20_and_25_rules(self):
|
||||
audio = object()
|
||||
SeedanceAutoPass._validate_mode_inputs(
|
||||
"多模态参考生视频", "seedance 2.5", "", [], [], [audio]
|
||||
with self.assertRaisesRegex(ValueError, "仅有参考音频时必须填写提示词"):
|
||||
SeedanceAutoPass._validate_mode_inputs(
|
||||
"多模态参考生视频", "seedance 2.5", "", [], [], [audio]
|
||||
)
|
||||
self.assertEqual(
|
||||
SeedanceAutoPass._validate_mode_inputs(
|
||||
"多模态参考生视频", "seedance 2.5", "prompt", [], [], [audio]
|
||||
),
|
||||
"multimodal",
|
||||
)
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "不可单独输入参考音频"):
|
||||
@@ -275,6 +305,38 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"图生视频-首尾帧", "seedance 2.5", "", [object()], [], []
|
||||
)
|
||||
|
||||
def test_edit_mode_accepts_reference_images(self):
|
||||
self.assertEqual(
|
||||
SeedanceAutoPass._validate_mode_inputs(
|
||||
"视频编辑",
|
||||
"seedance 2.5",
|
||||
"把 @video1 中的男子替换为 @image1 中的女子",
|
||||
[object()],
|
||||
[object()],
|
||||
[],
|
||||
),
|
||||
"edit",
|
||||
)
|
||||
with self.assertRaisesRegex(ValueError, "必须且只能提供一段参考视频"):
|
||||
SeedanceAutoPass._validate_mode_inputs(
|
||||
"视频编辑", "seedance 2.5", "替换", [object()], [], []
|
||||
)
|
||||
|
||||
def test_draft_final_body_reuses_only_the_task_id(self):
|
||||
body = SeedanceAutoPass._build_draft_final_body(
|
||||
"doubao-seedance-2-5-260628-max", " cgt-20260101120000-abc "
|
||||
)
|
||||
self.assertEqual(body, {
|
||||
"model": "doubao-seedance-2-5-260628-max",
|
||||
"content": [
|
||||
{"type": "draft_task", "draft_task": {"id": "cgt-20260101120000-abc"}},
|
||||
],
|
||||
})
|
||||
with self.assertRaisesRegex(ValueError, "必须填写样片任务ID"):
|
||||
SeedanceAutoPass._build_draft_final_body("model", "")
|
||||
with self.assertRaisesRegex(ValueError, "格式无效"):
|
||||
SeedanceAutoPass._build_draft_final_body("model", "bad id!")
|
||||
|
||||
def test_simplified_modes_resolve_to_provider_modes_from_connected_media(self):
|
||||
self.assertEqual(
|
||||
SeedanceAutoPass._validate_mode_inputs(
|
||||
@@ -310,7 +372,6 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"5秒",
|
||||
True,
|
||||
False,
|
||||
0,
|
||||
["https://example.com/first.png", "https://example.com/last.png"],
|
||||
[],
|
||||
[],
|
||||
@@ -321,11 +382,11 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
self.assertNotIn("prompt", body)
|
||||
self.assertNotIn("images", body)
|
||||
self.assertEqual(
|
||||
[item["role"] for item in body["content"]],
|
||||
[item["role"] for item in body["content"] if item["type"] != "text"],
|
||||
["first_frame", "last_frame"],
|
||||
)
|
||||
|
||||
def test_first_frame_mode_omits_image_role(self):
|
||||
def test_first_frame_mode_sets_first_frame_role(self):
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"dreamina-seedance-2-5-hc",
|
||||
"",
|
||||
@@ -334,7 +395,6 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"5秒",
|
||||
True,
|
||||
False,
|
||||
0,
|
||||
["https://ark-project.tos-cn-beijing.volces.com/doc_image/i2v_foxrgirl.png"],
|
||||
[],
|
||||
[],
|
||||
@@ -342,12 +402,14 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
generation_mode="首尾帧",
|
||||
)
|
||||
|
||||
self.assertEqual(body["content"][0], {
|
||||
image_items = [item for item in body["content"] if item["type"] == "image_url"]
|
||||
self.assertEqual(image_items, [{
|
||||
"type": "image_url",
|
||||
"image_url": {
|
||||
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/i2v_foxrgirl.png"
|
||||
},
|
||||
})
|
||||
"role": "first_frame",
|
||||
}])
|
||||
|
||||
def test_request_body_matches_o1key_video_builder(self):
|
||||
actual = SeedanceAutoPass._build_body(
|
||||
@@ -358,7 +420,6 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"30秒",
|
||||
True,
|
||||
True,
|
||||
42,
|
||||
["asset://image-1"],
|
||||
["asset://video-1"],
|
||||
["asset://audio-1"],
|
||||
@@ -377,7 +438,6 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"aspect_ratio": "auto",
|
||||
"generate_audio": True,
|
||||
"return_last_frame": True,
|
||||
"seed": 42,
|
||||
}, {
|
||||
"first_frame": None,
|
||||
"last_frame": None,
|
||||
@@ -388,6 +448,24 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertNotIn("web_search", actual)
|
||||
|
||||
def test_request_body_is_printed_without_credentials(self):
|
||||
body = {
|
||||
"model": "dreamina-seedance-2-0-hc",
|
||||
"content": [{"type": "text", "text": "prompt"}],
|
||||
"duration": -1,
|
||||
}
|
||||
|
||||
with patch("builtins.print") as print_mock:
|
||||
SeedanceAutoPass._print_request("https://api.example.com", body)
|
||||
|
||||
printed = "\n".join(
|
||||
str(call.args[0]) for call in print_mock.call_args_list if call.args
|
||||
)
|
||||
self.assertIn("POST https://api.example.com/v1/video/generations", printed)
|
||||
self.assertIn('"model": "dreamina-seedance-2-0-hc"', printed)
|
||||
self.assertIn("Authorization: Bearer ***", printed)
|
||||
self.assertTrue(print_mock.call_args.kwargs.get("flush"))
|
||||
|
||||
def test_manual_asset_creation_uses_existing_asset_ids(self):
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"dreamina-seedance-2-5-hc",
|
||||
@@ -397,7 +475,6 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
"5秒",
|
||||
False,
|
||||
False,
|
||||
0,
|
||||
["image-1"],
|
||||
["asset://video-1"],
|
||||
["audio-1"],
|
||||
@@ -435,12 +512,12 @@ class SeedanceAutoPassV3Tests(unittest.TestCase):
|
||||
audio_path = Path(root) / "reference.mp3"
|
||||
audio_path.write_bytes(b"audio")
|
||||
SeedanceAutoPass._validate_reference_media(
|
||||
[valid_image], [Video()], [str(audio_path)],
|
||||
"seedance 2.0", [valid_image], [Video()], [str(audio_path)],
|
||||
)
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "宽高必须分别在 300~6000px"):
|
||||
SeedanceAutoPass._validate_reference_media(
|
||||
[Image.new("RGB", (299, 300))], [], [],
|
||||
"seedance 2.0", [Image.new("RGB", (299, 300))], [], [],
|
||||
)
|
||||
|
||||
|
||||
@@ -718,36 +795,50 @@ class SeedanceAutoPassExecuteTests(unittest.IsolatedAsyncioTestCase):
|
||||
"seed": [0],
|
||||
})
|
||||
|
||||
async def test_seedance_25_supports_1080p_and_4k(self):
|
||||
for resolution in ("1080p", "4k"):
|
||||
with self.subTest(resolution=resolution):
|
||||
create = AsyncMock(return_value=([], [], []))
|
||||
submit = AsyncMock(return_value=("result.mp4", "done"))
|
||||
with (
|
||||
patch.object(SeedanceAutoPass, "_create_assets", create),
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", 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(**{
|
||||
"提示词": "test prompt",
|
||||
"生成模式": {
|
||||
"生成模式": "文生视频",
|
||||
"联网搜索": "关闭",
|
||||
},
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "海外HC",
|
||||
"分辨率": resolution,
|
||||
"宽高比": "智能",
|
||||
"时长": "30秒",
|
||||
"生成音频": "关闭",
|
||||
"seed": 0,
|
||||
})
|
||||
async def test_seedance_25_accepts_1080p_and_rejects_4k(self):
|
||||
create = AsyncMock(return_value=([], [], []))
|
||||
submit = AsyncMock(return_value=("result.mp4", "done"))
|
||||
with (
|
||||
patch.object(SeedanceAutoPass, "_create_assets", create),
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", 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(**{
|
||||
"提示词": "test prompt",
|
||||
"生成模式": {
|
||||
"生成模式": "文生视频",
|
||||
"联网搜索": "关闭",
|
||||
},
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "海外HC",
|
||||
"分辨率": "1080p",
|
||||
"宽高比": "智能",
|
||||
"时长": "30秒",
|
||||
"生成音频": "关闭",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
self.assertEqual(submit.await_args.args[0]["resolution"], resolution)
|
||||
self.assertEqual(submit.await_args.args[0]["resolution"], "1080p")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "分辨率仅支持"):
|
||||
await SeedanceAutoPass.execute(**{
|
||||
"提示词": "test prompt",
|
||||
"生成模式": {
|
||||
"生成模式": "文生视频",
|
||||
"联网搜索": "关闭",
|
||||
},
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "海外HC",
|
||||
"分辨率": "4k",
|
||||
"宽高比": "智能",
|
||||
"时长": "30秒",
|
||||
"生成音频": "关闭",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
async def test_seedance_fast_still_rejects_1080p_before_upload(self):
|
||||
with self.assertRaisesRegex(ValueError, "仅支持 480p / 720p"):
|
||||
@@ -805,7 +896,7 @@ class SeedanceAutoPassExecuteTests(unittest.IsolatedAsyncioTestCase):
|
||||
"联网搜索": "关闭",
|
||||
# 旧工作流参数即使仍存在,也必须被新的自动匹配规则忽略。
|
||||
"自动创建素材": "关闭",
|
||||
"素材创建模式": "标准",
|
||||
"素材创建模式": "自动创建",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
@@ -821,7 +912,238 @@ class SeedanceAutoPassExecuteTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertNotIn("camera_fixed", body)
|
||||
self.assertIs(output.result[0], video_output)
|
||||
self.assertIsNone(output.result[1])
|
||||
self.assertEqual(len(output.result), 2)
|
||||
self.assertEqual(output.result[2], "")
|
||||
self.assertEqual(len(output.result), 3)
|
||||
|
||||
async def test_execute_keeps_reference_images_in_video_edit_mode(self):
|
||||
image_1 = object()
|
||||
video_1 = object()
|
||||
|
||||
create = AsyncMock(return_value=(["asset://image-1"], ["asset://video-1"], []))
|
||||
submit = AsyncMock(return_value=("result.mp4", None))
|
||||
|
||||
with (
|
||||
patch.object(SeedanceAutoPass, "_create_assets", create),
|
||||
patch.object(SeedanceAutoPass, "_validate_reference_media"),
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", 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(**{
|
||||
"提示词": "把 @video1 的男子替换为 @image1 的女子",
|
||||
"生成模式": "视频编辑",
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "国内",
|
||||
"分辨率": "480p",
|
||||
"宽高比": "智能",
|
||||
"时长": "自动",
|
||||
"生成音频": "关闭",
|
||||
"素材创建模式": "自动创建",
|
||||
"参考图片": {"参考图片1": image_1},
|
||||
"参考视频": {"参考视频1": video_1},
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
create.assert_awaited_once_with(
|
||||
[image_1], [video_1], [], "https://api.example.com", "Doubao"
|
||||
)
|
||||
body = submit.await_args.args[0]
|
||||
self.assertEqual(body["omni_reference_task_type"], "edit")
|
||||
self.assertEqual(
|
||||
[item.get("role") for item in body["content"] if item["type"] != "text"],
|
||||
["reference_image", "reference_video"],
|
||||
)
|
||||
|
||||
async def test_draft_generation_forces_480p_and_returns_task_id(self):
|
||||
video_output = object()
|
||||
draft_task = "cgt-20260101120000-draft"
|
||||
|
||||
async def fake_submit(body, base_url, captured=None):
|
||||
if isinstance(captured, dict):
|
||||
captured["task_id"] = draft_task
|
||||
return "result.mp4", None
|
||||
|
||||
submit = AsyncMock(side_effect=fake_submit)
|
||||
with (
|
||||
patch.object(
|
||||
SeedanceAutoPass, "_create_assets", AsyncMock(return_value=([], [], []))
|
||||
),
|
||||
patch.object(SeedanceAutoPass, "_validate_reference_media"),
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", submit),
|
||||
patch.object(InputImpl, "VideoFromFile", return_value=video_output),
|
||||
patch(
|
||||
"comfyui_o1key.nodes.seedance_autopass.get_base_url_by_route",
|
||||
return_value="https://api.example.com",
|
||||
),
|
||||
):
|
||||
output = await SeedanceAutoPass.execute(**{
|
||||
"提示词": "一只猫在院子里追蝴蝶",
|
||||
"生成模式": "多模态",
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "国内",
|
||||
"分辨率": "1080p",
|
||||
"宽高比": "智能",
|
||||
"时长": "自动",
|
||||
"生成音频": "关闭",
|
||||
"素材创建模式": "自动创建",
|
||||
"样片模式": "生成样片",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
body = submit.await_args.args[0]
|
||||
self.assertTrue(body["draft"])
|
||||
self.assertEqual(body["resolution"], "480p")
|
||||
self.assertIs(output.result[0], video_output)
|
||||
self.assertEqual(output.result[2], draft_task)
|
||||
|
||||
async def test_draft_final_request_carries_only_the_draft_task(self):
|
||||
video_output = object()
|
||||
submit = AsyncMock(return_value=("result.mp4", None))
|
||||
create = AsyncMock()
|
||||
verify = AsyncMock(return_value={"model": ""})
|
||||
with (
|
||||
patch.object(SeedanceAutoPass, "_create_assets", create),
|
||||
patch.object(SeedanceAutoPass, "_validate_reference_media"),
|
||||
patch.object(SeedanceAutoPass, "_verify_draft_task", verify),
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", submit),
|
||||
patch.object(InputImpl, "VideoFromFile", return_value=video_output),
|
||||
patch(
|
||||
"comfyui_o1key.nodes.seedance_autopass.get_base_url_by_route",
|
||||
return_value="https://api.example.com",
|
||||
),
|
||||
):
|
||||
output = await SeedanceAutoPass.execute(**{
|
||||
"提示词": "这段提示词会被样片复用,不应再次发送",
|
||||
"生成模式": "多模态",
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "国内",
|
||||
"分辨率": "1080p",
|
||||
"宽高比": "智能",
|
||||
"时长": "自动",
|
||||
"生成音频": "关闭",
|
||||
"素材创建模式": "自动创建",
|
||||
"样片模式": "按样片生成",
|
||||
"样片任务ID": "cgt-20260101120000-draft",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
create.assert_not_awaited()
|
||||
verify.assert_awaited_once_with("https://api.example.com", "cgt-20260101120000-draft")
|
||||
self.assertEqual(submit.await_args.args[0], {
|
||||
"model": "doubao-seedance-2-5-260628-max",
|
||||
"content": [
|
||||
{
|
||||
"type": "draft_task",
|
||||
"draft_task": {"id": "cgt-20260101120000-draft"},
|
||||
},
|
||||
],
|
||||
})
|
||||
self.assertEqual(output.result[2], "cgt-20260101120000-draft")
|
||||
|
||||
async def test_draft_final_prefers_linked_task_id_and_uses_draft_model(self):
|
||||
submit = AsyncMock(return_value=("result.mp4", None))
|
||||
verify = AsyncMock(return_value={"model": "dreamina-seedance-2-5-hc"})
|
||||
with (
|
||||
patch.object(SeedanceAutoPass, "_validate_reference_media"),
|
||||
patch.object(SeedanceAutoPass, "_verify_draft_task", verify),
|
||||
patch.object(SeedanceAutoPass, "_submit_poll_download", 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(**{
|
||||
"提示词": "ignored",
|
||||
"生成模式": "多模态",
|
||||
"主模型": "seedance 2.5",
|
||||
"模型线路": "海外",
|
||||
"分辨率": "1080p",
|
||||
"宽高比": "智能",
|
||||
"时长": "自动",
|
||||
"生成音频": "关闭",
|
||||
"素材创建模式": "自动创建",
|
||||
"样片模式": "按样片生成",
|
||||
"样片任务ID": "cgt-widget",
|
||||
"样片任务ID输入": "cgt-linked",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
verify.assert_awaited_once_with("https://api.example.com", "cgt-linked")
|
||||
body = submit.await_args.args[0]
|
||||
self.assertEqual(body["content"][0]["draft_task"]["id"], "cgt-linked")
|
||||
self.assertEqual(body["model"], "dreamina-seedance-2-5-hc")
|
||||
|
||||
async def test_draft_task_verification_rejects_unfinished_task(self):
|
||||
fake_client = type("FakeSeedanceClient", (), {})()
|
||||
fake_client.base_url = ""
|
||||
fake_client.get_task_async = AsyncMock(return_value={
|
||||
"data": {"status": "running"},
|
||||
})
|
||||
with patch(
|
||||
"comfyui_o1key.nodes.seedance_autopass.SeedanceClient",
|
||||
return_value=fake_client,
|
||||
):
|
||||
with self.assertRaisesRegex(ValueError, "尚未完成"):
|
||||
await SeedanceAutoPass._verify_draft_task(
|
||||
"https://api.example.com", "cgt-1"
|
||||
)
|
||||
|
||||
async def test_draft_task_verification_reports_failed_task(self):
|
||||
fake_client = type("FakeSeedanceClient", (), {})()
|
||||
fake_client.base_url = ""
|
||||
fake_client.get_task_async = AsyncMock(return_value={
|
||||
"data": {"status": "failed", "error": {"message": "policy violation"}},
|
||||
})
|
||||
with patch(
|
||||
"comfyui_o1key.nodes.seedance_autopass.SeedanceClient",
|
||||
return_value=fake_client,
|
||||
):
|
||||
with self.assertRaisesRegex(ValueError, "已失败.*policy violation"):
|
||||
await SeedanceAutoPass._verify_draft_task(
|
||||
"https://api.example.com", "cgt-1"
|
||||
)
|
||||
|
||||
async def test_draft_task_verification_returns_draft_specs(self):
|
||||
fake_client = type("FakeSeedanceClient", (), {})()
|
||||
fake_client.base_url = ""
|
||||
fake_client.get_task_async = AsyncMock(return_value={
|
||||
"data": {
|
||||
"status": "succeeded",
|
||||
"model": "doubao-seedance-2-5-260628-max",
|
||||
"resolution": "480p",
|
||||
"duration": 6,
|
||||
},
|
||||
})
|
||||
with patch(
|
||||
"comfyui_o1key.nodes.seedance_autopass.SeedanceClient",
|
||||
return_value=fake_client,
|
||||
):
|
||||
summary = await SeedanceAutoPass._verify_draft_task(
|
||||
"https://api.example.com", "cgt-1"
|
||||
)
|
||||
self.assertEqual(summary["model"], "doubao-seedance-2-5-260628-max")
|
||||
self.assertEqual(summary["resolution"], "480p")
|
||||
self.assertEqual(summary["duration"], 6)
|
||||
|
||||
async def test_draft_mode_requires_seedance_25(self):
|
||||
with self.assertRaisesRegex(ValueError, "样片模式仅支持 seedance 2.5"):
|
||||
await SeedanceAutoPass.execute(**{
|
||||
"提示词": "prompt",
|
||||
"生成模式": "多模态",
|
||||
"主模型": "seedance 2.0",
|
||||
"模型线路": "国内",
|
||||
"分辨率": "720p",
|
||||
"宽高比": "智能",
|
||||
"时长": "5秒",
|
||||
"生成音频": "关闭",
|
||||
"素材创建模式": "自动创建",
|
||||
"样片模式": "生成样片",
|
||||
"seed": 0,
|
||||
})
|
||||
|
||||
|
||||
class SeedanceAutoPassBatchV3Tests(unittest.TestCase):
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
"""Offline tests for Seedance task polling and result parsing."""
|
||||
|
||||
import json
|
||||
import sys
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, call, patch
|
||||
|
||||
|
||||
PACKAGE_DIR = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(PACKAGE_DIR.parent))
|
||||
|
||||
# Load only the client module. Importing the plugin-wide registry would make
|
||||
# this offline test depend on the portable build's CUDA availability.
|
||||
package = types.ModuleType("comfyui_o1key")
|
||||
package.__path__ = [str(PACKAGE_DIR)]
|
||||
sys.modules["comfyui_o1key"] = package
|
||||
for child in ("clients", "utils"):
|
||||
module = types.ModuleType(f"comfyui_o1key.{child}")
|
||||
module.__path__ = [str(PACKAGE_DIR / child)]
|
||||
sys.modules[f"comfyui_o1key.{child}"] = module
|
||||
|
||||
from comfyui_o1key.clients.seedance_client import SeedanceClient # noqa: E402
|
||||
|
||||
|
||||
def make_client():
|
||||
client = SeedanceClient.__new__(SeedanceClient)
|
||||
client.api_key = "test-token"
|
||||
client.base_url = "https://new-api.example.com"
|
||||
return client
|
||||
|
||||
|
||||
def response(payload):
|
||||
value = AsyncMock()
|
||||
value.text = AsyncMock(return_value=json.dumps(payload))
|
||||
value.release = lambda: None
|
||||
return value
|
||||
|
||||
|
||||
class SeedancePollingTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_completed_task_reads_metadata_urls(self):
|
||||
request = AsyncMock(side_effect=[
|
||||
response({
|
||||
"task_id": "task-1",
|
||||
"status": "queued",
|
||||
"progress": 0,
|
||||
}),
|
||||
response({
|
||||
"task_id": "task-1",
|
||||
"status": "completed",
|
||||
"progress": 100,
|
||||
"metadata": {
|
||||
"url": "https://cdn.example.com/video.mp4",
|
||||
"last_frame_url": "https://cdn.example.com/frame.png",
|
||||
},
|
||||
}),
|
||||
])
|
||||
|
||||
with (
|
||||
patch("comfyui_o1key.clients.seedance_client.async_request_with_retry", request),
|
||||
patch("comfyui_o1key.clients.seedance_client.interruptible_sleep", AsyncMock()),
|
||||
):
|
||||
video_url, last_frame_url = await make_client().poll_async("task-1", object())
|
||||
|
||||
self.assertEqual(video_url, "https://cdn.example.com/video.mp4")
|
||||
self.assertEqual(last_frame_url, "https://cdn.example.com/frame.png")
|
||||
|
||||
async def test_polling_uses_the_retrying_request_helper(self):
|
||||
request = AsyncMock(return_value=response({
|
||||
"status": "completed",
|
||||
"result_url": "https://cdn.example.com/video.mp4",
|
||||
}))
|
||||
|
||||
with patch("comfyui_o1key.clients.seedance_client.async_request_with_retry", request):
|
||||
await make_client().poll_async("task-1", object())
|
||||
|
||||
self.assertEqual(request.await_args_list, [
|
||||
call(
|
||||
unittest.mock.ANY,
|
||||
"GET",
|
||||
"https://new-api.example.com/v1/video/generations/task-1",
|
||||
headers={
|
||||
"Authorization": "Bearer test-token",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
prefix="Seedance 状态查询: ",
|
||||
),
|
||||
])
|
||||
|
||||
|
||||
async def test_get_task_async_reads_one_status_response(self):
|
||||
request = AsyncMock(return_value=response({
|
||||
"data": {
|
||||
"status": "succeeded",
|
||||
"model": "doubao-seedance-2-5-260628-max",
|
||||
"resolution": "480p",
|
||||
},
|
||||
}))
|
||||
|
||||
with patch("comfyui_o1key.clients.seedance_client.async_request_with_retry", request):
|
||||
payload = await make_client().get_task_async(
|
||||
"cgt-1", session=object()
|
||||
)
|
||||
|
||||
self.assertEqual(payload["data"]["status"], "succeeded")
|
||||
self.assertEqual(request.await_args.args[2], "https://new-api.example.com/v1/video/generations/cgt-1")
|
||||
self.assertEqual(request.await_args.kwargs["prefix"], "Seedance 任务查询: ")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -5,6 +5,7 @@ import sys
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
PACKAGE_DIR = Path(__file__).resolve().parents[1]
|
||||
@@ -146,6 +147,50 @@ class SeedanceHCAssetClientTests(unittest.IsolatedAsyncioTestCase):
|
||||
_, query_kwargs = session.get_call
|
||||
self.assertEqual(query_kwargs["params"], {"type": "doubao"})
|
||||
|
||||
async def test_create_logs_full_response_but_folds_signed_urls(self):
|
||||
session = _FakeSession(post_payload={
|
||||
"success": True,
|
||||
"data": {
|
||||
"Id": "asset-test",
|
||||
"Status": "Active",
|
||||
"SourceUrl": "https://upload.example.com/a.png?signature=secret",
|
||||
},
|
||||
})
|
||||
|
||||
with patch("builtins.print") as print_mock:
|
||||
await self.client.create_hc_asset(
|
||||
name="参考图片1",
|
||||
asset_url="https://upload.o1key.com/uploads/reference.png",
|
||||
asset_type="image",
|
||||
session=session,
|
||||
)
|
||||
|
||||
printed = "\n".join(
|
||||
str(call.args[0]) for call in print_mock.call_args_list if call.args
|
||||
)
|
||||
self.assertIn("创建响应体 HTTP 200", printed)
|
||||
self.assertIn('"Id": "asset-test"', printed)
|
||||
self.assertIn('"Status": "Active"', printed)
|
||||
self.assertNotIn("signature=secret", printed)
|
||||
|
||||
async def test_query_logs_response_only_when_status_changes(self):
|
||||
session = _FakeSession(get_payload={
|
||||
"success": True,
|
||||
"data": {"Id": "asset-q", "Status": "Processing"},
|
||||
})
|
||||
|
||||
with patch("builtins.print") as print_mock:
|
||||
await self.client.get_hc_asset("asset-q", session=session)
|
||||
await self.client.get_hc_asset("asset-q", session=session)
|
||||
|
||||
printed = [
|
||||
str(call.args[0])
|
||||
for call in print_mock.call_args_list
|
||||
if call.args
|
||||
]
|
||||
self.assertEqual(sum("查询响应体" in line for line in printed), 1)
|
||||
self.assertIn('"Status": "Processing"', "\n".join(printed))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -24,6 +24,7 @@ for child in ("nodes", "utils", "clients"):
|
||||
|
||||
from comfyui_o1key.nodes import seedance_element
|
||||
from comfyui_o1key.nodes.seedance_element import SeedanceElementCreate
|
||||
from comfyui_o1key.nodes.seedance_autopass import SeedanceAutoPass
|
||||
from comfyui_o1key.nodes import seedance_video
|
||||
from comfyui_o1key.nodes.seedance_video import (
|
||||
SeedanceMultiModal,
|
||||
@@ -69,6 +70,7 @@ class SeedanceParameterSyncTests(unittest.TestCase):
|
||||
)
|
||||
self.assertIn("30秒", inputs["时长"].options)
|
||||
self.assertEqual(inputs["seed"].max, 0xffffffffffffffff)
|
||||
self.assertEqual(inputs["seed"].default, 0)
|
||||
self.assertEqual(
|
||||
_resolve_model_matrix("seedance 2.5", "海外HC"),
|
||||
"dreamina-seedance-2-5-hc",
|
||||
@@ -87,17 +89,112 @@ class SeedanceParameterSyncTests(unittest.TestCase):
|
||||
self.assertTrue(_is_new_format_model("dreamina-seedance-2-0-hc"))
|
||||
self.assertTrue(_is_new_format_model("dreamina-seedance-2-5-hc"))
|
||||
_check_fast_resolution("dreamina-seedance-2-5-hc", "1080p")
|
||||
_check_fast_resolution("dreamina-seedance-2-5-hc", "4k")
|
||||
with self.assertRaisesRegex(ValueError, "不支持 4k"):
|
||||
_check_fast_resolution("dreamina-seedance-2-5-hc", "4k")
|
||||
with self.assertRaisesRegex(ValueError, "不支持 4k"):
|
||||
_check_fast_resolution("dreamina-seedance-2-0-fast-hc", "4k")
|
||||
for limited_model in (
|
||||
"doubao-seedance-2-0-fast-260128-max",
|
||||
"doubao-seedance-2-0-mini-260615-max",
|
||||
"seedance-2-0-fast-260128-d",
|
||||
"seedance-2-0-mini-260615-d",
|
||||
):
|
||||
with self.subTest(limited_model=limited_model):
|
||||
with self.assertRaisesRegex(ValueError, "不支持 4k"):
|
||||
_check_fast_resolution(limited_model, "4k")
|
||||
_check_fast_resolution("doubao-seedance-2-5-260628-max", "4k")
|
||||
with self.assertRaisesRegex(ValueError, "不支持 4k"):
|
||||
_check_fast_resolution("doubao-seedance-2-5-260628-max", "4k")
|
||||
|
||||
def test_seed_is_never_sent_to_the_provider(self):
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"doubao-seedance-2-5-260628-max",
|
||||
"prompt",
|
||||
"1080p",
|
||||
"智能",
|
||||
"5秒",
|
||||
False,
|
||||
False,
|
||||
["asset://image-1"],
|
||||
[],
|
||||
[],
|
||||
generation_mode="多模态参考生视频",
|
||||
)
|
||||
self.assertNotIn("seed", body)
|
||||
|
||||
def test_generation_modes_cover_document_scenarios(self):
|
||||
schema = SeedanceAutoPass.GET_SCHEMA()
|
||||
inputs = {item.id: item for item in schema.inputs}
|
||||
self.assertEqual(
|
||||
inputs["生成模式"].options,
|
||||
["多模态", "首尾帧", "视频编辑", "视频延长"],
|
||||
)
|
||||
self.assertEqual(inputs["输出格式"].options, ["mp4", "mov"])
|
||||
self.assertEqual(inputs["seed"].default, 0)
|
||||
|
||||
def test_edit_body_carries_task_type_and_output_format(self):
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"doubao-seedance-2-5-260628-max",
|
||||
"去掉背景里的行人",
|
||||
"1080p",
|
||||
"auto",
|
||||
-1,
|
||||
False,
|
||||
False,
|
||||
[],
|
||||
["https://example.invalid/clip.mp4"],
|
||||
[],
|
||||
generation_mode="edit",
|
||||
output_format="mov",
|
||||
)
|
||||
self.assertEqual(body["omni_reference_task_type"], "edit")
|
||||
self.assertEqual(body["output_format"], "mov")
|
||||
self.assertEqual(body["duration"], -1)
|
||||
self.assertEqual(body["ratio"], "adaptive")
|
||||
self.assertEqual(
|
||||
[item["video_url"]["url"] for item in body["content"] if item["type"] == "video_url"],
|
||||
["https://example.invalid/clip.mp4"],
|
||||
)
|
||||
|
||||
def test_edit_body_carries_reference_images_before_the_video(self):
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"doubao-seedance-2-5-260628-max",
|
||||
"把 @video1 中的男子替换为 @image1 中的女子",
|
||||
"480p",
|
||||
"auto",
|
||||
-1,
|
||||
False,
|
||||
False,
|
||||
["asset://image-1"],
|
||||
["asset://video-1"],
|
||||
[],
|
||||
generation_mode="edit",
|
||||
)
|
||||
self.assertEqual(body["omni_reference_task_type"], "edit")
|
||||
self.assertEqual(
|
||||
[item.get("role") for item in body["content"] if item["type"] != "text"],
|
||||
["reference_image", "reference_video"],
|
||||
)
|
||||
self.assertNotIn(
|
||||
"first_frame",
|
||||
[item.get("role") for item in body["content"]],
|
||||
)
|
||||
|
||||
def test_auto_duration_and_adaptive_ratio_reach_the_request_body(self):
|
||||
body = SeedanceAutoPass._build_body(
|
||||
"doubao-seedance-2-5-260628-max",
|
||||
"prompt",
|
||||
"1080p",
|
||||
"智能",
|
||||
"自动",
|
||||
False,
|
||||
False,
|
||||
["asset://image-1"],
|
||||
[],
|
||||
[],
|
||||
generation_mode="多模态参考生视频",
|
||||
)
|
||||
self.assertEqual(body["duration"], -1)
|
||||
self.assertEqual(body["ratio"], "adaptive")
|
||||
|
||||
def test_multimodal_uses_v3_autogrow_media_inputs(self):
|
||||
self.assertTrue(issubclass(SeedanceMultiModal, io.ComfyNode))
|
||||
|
||||
@@ -24,13 +24,16 @@ from comfyui_o1key.nodes.universal_llm import ( # noqa: E402
|
||||
|
||||
|
||||
class UniversalLLMModelTests(unittest.TestCase):
|
||||
def test_gpt_6_sol_is_supported_and_default(self):
|
||||
def test_new_models_are_supported_and_claude_opus_5_5_is_default(self):
|
||||
schema = UniversalLLMChat.GET_SCHEMA()
|
||||
schema.validate()
|
||||
model_input = next(item for item in schema.inputs if item.id == "模型")
|
||||
|
||||
self.assertEqual(DEFAULT_MODEL, "gpt-6-sol")
|
||||
self.assertEqual(DEFAULT_MODEL, "claude-opus-5-5")
|
||||
self.assertEqual(SUPPORTED_MODELS[0], DEFAULT_MODEL)
|
||||
self.assertIn("gemini-4-argon", SUPPORTED_MODELS)
|
||||
self.assertIn("gpt-6-sol", SUPPORTED_MODELS)
|
||||
self.assertIn("claude-opus-5", SUPPORTED_MODELS)
|
||||
self.assertIn("gpt-6-astra", SUPPORTED_MODELS)
|
||||
self.assertEqual(model_input.options, SUPPORTED_MODELS)
|
||||
self.assertEqual(model_input.default, DEFAULT_MODEL)
|
||||
|
||||
Reference in New Issue
Block a user