diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b16eb2..64b73e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,18 @@ --- +## 2026-11-17 + +### 新增 +- MiniMax H3 视频节点新增 `MiniMax-H3-Highspeed` 和 `MiniMax-H3-Lite`,兼容模型各自的分辨率、时长、参考素材和画面比例限制。 +- Seedance 全能生成视频及其批量版本在普通 2.5 下方新增 `seedance 2.5 flash`,支持国内线路、480p/720p、4~30 秒及对应素材数量限制。 + +### 调整 +- MiniMax 的模型参数移至生成模式上方,“参考素材生视频”更名为“多模态生视频”并设为新节点默认值。 +- 补齐模型切换时的参数联动及旧工作流迁移,保留已有模式、素材、种子和随机化设置。 + +--- + ## [1.10.4] - 2026-04-13 ### 修复 diff --git a/README.md b/README.md index dccb4d9..3f5af0b 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,8 @@ Google Gemini 模型节点,支持更多模型选择。 两个单节点及「Seedance 全能生成视频(批量)」共用模型能力限制:Seedance 2.0 系列支持 4~15 秒,Seedance 2.5 支持 4~30 秒;2.5 支持 `480p / 720p / 1080p`,并允许最多 30 个图片类、10 个视频类和 10 个音频类参考内容。批量节点固定使用直接上传,不创建素材。多模态节点中的直接媒体与对应素材 ID 共用这组数量额度。fast 和 mini 模型仍只支持 `480p / 720p`。宽高比统一为智能、`16:9 / 9:16 / 4:3 / 3:4 / 1:1 / 21:9`,其中“智能”按上游 `adaptive` 提交,首帧和首尾帧模式跟随图片比例;时长的“自动”按上游 `-1` 提交。 +「Seedance 全能生成视频」及其批量版本的主模型列表在 `seedance 2.5` 下方提供 `seedance 2.5 flash`,使用国内模型 `doubao-seedance-2-5-flash`。Flash 支持 `480p / 720p`、4~30 秒或自动时长,最多 10 张参考图、5 段参考视频、5 段参考音频,视频和音频各自总时长不超过 30 秒;支持多模态、首尾帧、视频编辑和延长,编辑自动使用 `duration: -1`,首尾帧/编辑/延长自动跟随素材比例。切换 Flash 时自动改为国内线路、纠正不支持的分辨率,并关闭普通 2.5 专用的样片模式;默认主模型仍为普通 2.5。 + 「Seedance 全能生成视频」现与「o1key 视频生成」共用参数标准、素材限制、`content` 请求体构造和 Seedance 提交/轮询/下载客户端。生成模式简化为“多模态”和“首尾帧”:新节点默认多模态,无参考素材而仅填写提示词时自动按文生视频提交;首尾帧需要一个首帧素材,尾帧可选,没有尾帧时自动按仅首帧提交。“素材创建模式”默认关闭,此时上传连接素材并按线路创建 HC/Doubao Asset;打开后显示编号式素材 ID 输入并跳过上传,使用已有图片、视频和音频素材 ID,其中首尾帧模式填写一个或两个图片素材 ID。连接的图片会按 PNG 上传且单项不超过 30MB,宽高各为 `300~6000px`、比例为 `0.4~2.5`;视频仅支持 MP4/MOV,单项不超过 200MB,并额外要求总像素为 `407,696~8,295,044`;音频支持 WAV/MP3,单项不超过 15MB。参考视频和参考音频的单项及总时长上限为 15 秒(2.0 系列)或 30 秒(2.5)。所有素材在上传和创建素材前完成校验,准备阶段最多并发处理三个素材并保持输入顺序。seed 仍位于普通参数区,但仅作为 ComfyUI 的重新执行判断依据,不会随请求提交,实际种子由 Seedance 自行生成。"联网搜索"为旧工作流保留并保持隐藏,"返回末帧图片"可正常使用。联网搜索仅为旧工作流保留,当前统一的 `content` 请求不会发送该参数。旧的四种生成模式、参数顺序和“海外HC”线路会在加载时自动迁移。 “生成模式”除“多模态”和“首尾帧”外,还提供 Seedance 2.5 专用的“视频编辑”和“视频延长”:两者都要求连接且仅连接一段参考视频并填写提示词,宽高比固定按 `adaptive` 提交,编辑任务按上游要求显式传 `duration: -1`,延长任务可选 4~30 秒或自动。选择“输出格式”为 `mov` 时,2.5 任务会附带 `output_format`,便于需要保留音画连续的延长结果。 @@ -285,17 +287,21 @@ Google Gemini 模型节点,支持更多模型选择。 ### MiniMax H3 / H3 Max 视频生成 -通过 New API 网关调用 `MiniMax-H3` 或 `MiniMax-H3-MAX`。两者均支持文生视频、 -首帧、尾帧和首尾帧生视频;`MiniMax-H3` 另外支持多图片、多视频、多音频参考素材生成。 +同一节点的“模型”下拉框支持 `MiniMax-H3`、`MiniMax-H3-MAX`、 +`MiniMax-H3-Highspeed` 和 `MiniMax-H3-Lite`。H3、Highspeed、Lite 支持文生视频、 +首帧/首尾帧及多图片、多视频、多音频参考素材生成。 节点完成后会立即下载临时 CDN 视频并输出 ComfyUI 原生 `VIDEO`,可连接内置保存视频节点。 - `MiniMax-H3`:`768P` / `2K`,4~15 秒,支持最多 9 张参考图、3 个参考视频、3 个参考音频,参考素材合计最多 12 个 - `MiniMax-H3-MAX`:`480P` / `768P`,5~15 秒,不支持参考素材模式 +- `MiniMax-H3-Highspeed`:`480P` / `768P`,4~15 秒,兼顾质量与速度,支持多模态参考 +- `MiniMax-H3-Lite`:`480P` / `768P`,4~15 秒,侧重低成本,支持多模态参考;参考模式必须指定具体比例 +- 参数顺序为“提示词 → 模型 → 生成模式 → 分辨率 → 时长 → seed”;生成模式默认“多模态生视频”(原“参考素材生视频”),需要连接至少一种参考素材;切换模型时自动更新分辨率、最短时长和比例选项,旧工作流自动迁移并保留原有选择 - 查询任务按接口建议每 10 秒轮询;短暂的 `unknown` 状态按排队中处理,总等待上限为 2000 秒 - `seed` 为原生生成参数,支持固定、递增、递减和每次随机化 - 文生视频比例:21:9、16:9、4:3、1:1、3:4、9:16 -- 首帧、尾帧、首尾帧模式自动使用 `adaptive` -- 参考素材:最多 9 张图片、3 个视频、3 段音频;默认 `adaptive`,也可指定具体输出比例 +- 首帧、首尾帧模式自动使用 `adaptive`;Highspeed/Lite 使用尾帧时须同时提供首帧,界面自动切换为“首尾帧生视频”;H3/H3 Max 保留原有尾帧模式兼容 +- 参考素材:最多 9 张图片、3 个视频、3 段音频,合计最多 12 个;H3/Highspeed 默认 `adaptive`,Lite 自动调整为 `16:9`,可改选其他具体比例;后端会在上传和请求前拒绝 Lite 的无效参考比例 - API Token 从插件配置读取,不会保存在工作流中 --- diff --git a/docs/architecture.md b/docs/architecture.md index 5e0363a..82fda6e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -59,15 +59,30 @@ Only `omni_flash_abra_edit` task creation adds the `X-No-Watermark: video` heade `clients/` owns request construction, provider endpoints, polling protocols, and response normalization. Its package exports are lazy so importing one provider does not initialize all providers. Video task polling uses the shared 2,000-second deadline unless a caller explicitly supplies a different value. -The `MiniMaxH3Video` node keeps its released node ID and original first four -inputs. Its append-only `模型` widget selects `MiniMax-H3` or -`MiniMax-H3-MAX`, followed by an append-only native `seed` widget. Workflow -migration supplies `MiniMax-H3` and seed `0` to older saved graphs. The seed is +The `MiniMaxH3Video` node keeps its released node ID and input IDs. Its schema +order is `提示词`, `模型`, `生成模式`, `分辨率`, `时长`, `seed`. +The model widget selects `MiniMax-H3`, `MiniMax-H3-MAX`, +`MiniMax-H3-Highspeed`, or `MiniMax-H3-Lite`. New nodes default to +`多模态生视频`, the first DynamicCombo option. Workflow migration first supplies +missing model/seed defaults, then moves the former trailing model to index 1 +and renames `参考素材生视频` to `多模态生视频`. It preserves selected modes, +reference values, seed controls, and nested subgraphs; repeated migration is +idempotent. Request construction and execution retain the old mode as an alias. +See [ADR 0018](decisions/0018-minimax-model-order-and-multimodal-default.md). +The seed is validated as an integer and passed unchanged in the provider request. Backend validation owns the authoritative model-specific resolution, duration, mode, and aggregate reference-count rules, while the frontend guard updates the visible resolution and duration constraints and prevents H3 Max from selecting -reference mode. +reference mode. Highspeed and Lite allow 480P/768P and 4–15 seconds with the +same reference limits as H3. Lite reference mode requires a fixed ratio; +the frontend changes adaptive to 16:9 and the backend rejects missing/adaptive +ratios before uploads or submission. Frame modes retain adaptive for Lite. +Highspeed/Lite tail input requires a first frame, so the frontend selects the +existing first/last mode and the backend rejects tail-only requests; legacy +H3/Max tail-only workflows remain accepted. Migration recognizes all four +model IDs, including workflows with the native seed control serialized after +the seed, so new workflows are not mistaken for workflows missing a model. The MiniMax client creates tasks through `/v1/video/generations` and queries them through `/v1/videos/{task_id}` every 10 seconds. New API's documented @@ -234,6 +249,20 @@ Seedance model capabilities are shared across the single, multimodal, and batch `SeedanceMultiModal`, `SeedanceAutoPass`, and `SeedanceAutoPassBatch` expose both `国内` and `海外` model routes and default newly created nodes to `国内`; `海外` is the display-name replacement for the former `海外HC` value. The domestic route maps the four existing base-model choices to `doubao-seedance-2-0-260128-max`, `doubao-seedance-2-0-fast-260128-max`, `doubao-seedance-2-0-mini-260615-max`, and `doubao-seedance-2-5-260628-max`; it reuses the same capability envelope and new-format request body as the corresponding overseas choices. `SeedanceAutoPass` exposes `多模态`, `首尾帧`, `视频编辑`, and `视频延长`: the backend resolves prompt-only multimodal calls to `text`, resolves one or two frame images to `first_frame` or `first_last_frame`, and passes an explicitly selected edit/extend mode through with its single reference video plus any optional reference images and audio. Its `素材创建` branch mirrors the unified generator's `auto/manual` contract; automatic media is validated and converted into HC/Doubao assets, while manual IDs bypass upload and enter `build_seedance_video_body` through the `assets` fields. The node translates its Chinese widget values into `o1key_video_catalog.py` and submits through `SeedanceClient`, so the unified panel and graph node cannot drift in scalar parameters or request shape. `migrateWorkflow.js` performs an idempotent compatibility migration for the former four mode values, moved web-search widget, former route label, last-frame default, and newly added asset-creation selector. Seedance 2.5's draft flow is exposed through the append-only `样片模式` / `样片任务ID` widgets and the new `样片任务ID` output: `生成样片` submits the normal request body with `draft: true` and a forced `480p` resolution and returns the preview plus the provider task ID, while `按样片生成` submits only `content: [{"type": "draft_task", "draft_task": {"id": ...}}]` so the provider reuses the draft's prompt, media, duration, ratio, and audio and renders the 1080p final; both requests go through `SeedanceClient`, and the task ID is captured from the submission callback. The draft task ID can be typed into the widget or received through the optional `样片任务ID输入` STRING socket (a connected link wins over the widget); before submitting the final request the node queries the task once through `SeedanceClient.get_task_async`, requires a succeeded status, logs the reported model/resolution/duration, and reuses the reported model for the final body. +The graph-connected `SeedanceAutoPass` and its batch counterpart list +`seedance 2.5 flash` immediately after regular 2.5. The shared capability +registry includes `seedance-2.5-flash`, mapped only on the domestic route to +`doubao-seedance-2-5-flash`: 480p/720p, 4–30 seconds, 10 images, 5 videos, +5 audios, and 30-second reference limits. The curated panel and multimodal +node model menus remain unchanged. Shared normalization accepts the registry +superset so the graph nodes retain one source for limits and request bodies. +Flash follows 2.5 frame/edit/extend and audio-only-reference rules, including +MOV output and automatic ratio/duration normalization. The existing 1080p +draft-final workflow remains regular-2.5-only. The frontend clamps route and +resolution on model changes, and backend validation rejects incompatible +parameters before uploads or submission. Migration recognizes the new model +without changing widget order or defaults. + #### Panel-driven unified video generation `O1keyVideoGenerator` exposes append-only `VIDEO` and `LAST_FRAME` outputs while keeping paid generation exclusively behind `POST /o1key/video/jobs`. Every panel click creates and connects a native `SaveVideo`; when `return_last_frame` is enabled, it also creates and connects a native `SaveImage`. The completed safe descriptors are dispatched to those native nodes for preview and persisted on them for workflow reload recovery. The generator's native `execute` may resolve only the latest completed local descriptors and can never submit or retry a paid request. `O1keyVideoResult` remains registered as deprecated compatibility support for saved workflows but is never created by the current panel. `ParallelVideoJobManager` still starts every accepted job immediately without entering ComfyUI's native queue or imposing an internal concurrency ceiling. Provider-side quotas and rate limits remain authoritative. diff --git a/docs/decisions/0018-minimax-model-order-and-multimodal-default.md b/docs/decisions/0018-minimax-model-order-and-multimodal-default.md new file mode 100644 index 0000000..78c0045 --- /dev/null +++ b/docs/decisions/0018-minimax-model-order-and-multimodal-default.md @@ -0,0 +1,38 @@ +# 0018: MiniMax model order and multimodal default + +- Status: Accepted +- Date: 2026-11-17 +- Owners: Maintainers + +## Context + +The user requested the MiniMax model above generation mode and renamed the +reference-material mode to `多模态生视频`, with that mode as the default. +Saved workflows use positional widget values and previously kept the model +after duration, so a schema-only change would misassign saved parameters. + +## Decision + +Use `提示词`, `模型`, `生成模式`, `分辨率`, `时长`, `seed` as the schema order. +Place `多模态生视频` first in DynamicCombo options to select it for new nodes. +Keep node/input IDs and the execution signature stable. Migrate missing +model/seed defaults first, then move the trailing model to index 1 and rename +the old mode. Keep `参考素材生视频` as a backend execution/payload alias. + +## Consequences + +Existing workflows preserve their mode, references, duration, seed, and seed +control rather than inheriting the new default. Migration applies to root and +subgraph nodes and must remain idempotent. H3 Max continues to switch to text +mode because it does not support multimodal references. + +## Alternatives considered + +Moving only the displayed widget would leave schema and serialized order +inconsistent. Changing the schema without migration would break saved graphs. + +## Validation + +`tests/test_minimax_h3.py` covers schema order, default mode, and the old alias. +`tests/test_o1key_image_generator_frontend.mjs` covers old/current workflow +layouts, all four models, seed controls, subgraphs, and repeat migration. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index a5cd1ea..ca24c3d 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -29,3 +29,4 @@ Use ADRs for decisions that constrain future changes: node ID compatibility, pac - [0015: Canonical image-generator workflow values](0015-image-generator-workflow-values.md) - [0016: Add Kling 4.0 modes to the released K video node](0016-kling-v4-generation-modes.md) - [0017: Remove retired Nano Banana models from the unified image generator](0017-remove-retired-unified-nano-models.md) +- [0018: MiniMax model order and multimodal default](0018-minimax-model-order-and-multimodal-default.md) diff --git a/docs/development.md b/docs/development.md index 8ac971f..2fae7e8 100644 --- a/docs/development.md +++ b/docs/development.md @@ -24,6 +24,13 @@ The left toolbar Update button sits after Token Manager and before Restart. Open 7. If widget order changes, add an idempotent migration to `web/js/migrateWorkflow.js`. 8. Add an offline test and update user/architecture docs when behavior is visible. +For `MiniMaxH3Video`, keep `模型` immediately before `生成模式` and keep +`多模态生视频` first in the DynamicCombo options so new nodes use it by default. +Preserve the backend `参考素材生视频` alias and the migration sequence that supplies +missing model/seed defaults before moving the former trailing model and renaming +the saved mode. Cover both root/subgraph workflows and optional seed controls in +`tests/test_o1key_image_generator_frontend.mjs` after changing these widgets. + For `O1keyPromptMultiFunction`, keep the original first two widgets unchanged and retain backend aliases for the legacy `随机抽取1套` / `随机抽取多套` values. The visible mode remains `随机抽取n套`; migration must map old single-random workflows to count `1`. Its dynamic extension may hide inactive selection widgets but must retain their values and serialization. Future selection controls must remain append-only, and every multi-prompt result must use a standalone `---` line so downstream batch nodes retain the same parsing contract. ## Add or change a provider client diff --git a/nodes/minimax_h3_video.py b/nodes/minimax_h3_video.py index 1744006..954b9aa 100644 --- a/nodes/minimax_h3_video.py +++ b/nodes/minimax_h3_video.py @@ -24,21 +24,28 @@ from ..utils.r2_uploader import upload_audio, upload_image, upload_video MODEL_ID = "MiniMax-H3" MODEL_MAX_ID = "MiniMax-H3-MAX" -MODEL_OPTIONS = [MODEL_ID, MODEL_MAX_ID] +MODEL_HIGHSPEED_ID = "MiniMax-H3-Highspeed" +MODEL_LITE_ID = "MiniMax-H3-Lite" +MODEL_OPTIONS = [MODEL_ID, MODEL_MAX_ID, MODEL_HIGHSPEED_ID, MODEL_LITE_ID] MODE_TEXT = "文生视频" MODE_FIRST = "首帧图生视频" MODE_LAST = "尾帧图生视频" MODE_FIRST_LAST = "首尾帧生视频" -MODE_REFERENCE = "参考素材生视频" +MODE_REFERENCE = "多模态生视频" +LEGACY_MODE_REFERENCE = "参考素材生视频" RESOLUTION_OPTIONS = ["2K", "768P", "480P"] MODEL_RESOLUTIONS = { MODEL_ID: {"768P", "2K"}, MODEL_MAX_ID: {"480P", "768P"}, + MODEL_HIGHSPEED_ID: {"480P", "768P"}, + MODEL_LITE_ID: {"480P", "768P"}, } MODEL_DURATION_RANGES = { MODEL_ID: (4, 15), MODEL_MAX_ID: (5, 15), + MODEL_HIGHSPEED_ID: (4, 15), + MODEL_LITE_ID: (4, 15), } RATIO_OPTIONS = ["16:9", "21:9", "4:3", "1:1", "3:4", "9:16"] REFERENCE_RATIO_OPTIONS = ["adaptive", *RATIO_OPTIONS] @@ -90,6 +97,18 @@ def _validate_generation_options( ) if model == MODEL_MAX_ID and mode == MODE_REFERENCE: raise ValueError("MiniMax-H3-MAX 不支持图片、视频或音频参考素材模式。") + if model in (MODEL_HIGHSPEED_ID, MODEL_LITE_ID) and mode == MODE_LAST: + raise ValueError(f"{model} 使用尾帧时必须同时提供首帧,请选择首尾帧生视频。") + + +def _validate_ratio(model: str, mode: str, ratio: Optional[str]) -> None: + if mode == MODE_TEXT and ratio not in RATIO_OPTIONS: + raise ValueError("MiniMax H3 文生视频必须选择具体宽高比,不能使用 adaptive。") + if mode == MODE_REFERENCE: + if model == MODEL_LITE_ID and ratio not in RATIO_OPTIONS: + raise ValueError("MiniMax-H3-Lite 参考素材模式必须选择具体宽高比,不能省略或使用 adaptive。") + if (ratio or "adaptive") not in REFERENCE_RATIO_OPTIONS: + raise ValueError(f"MiniMax H3 参考素材模式不支持宽高比:{ratio}") def _validate_reference_counts( @@ -155,10 +174,13 @@ def build_request_body( reference_video_urls: Optional[list[str]] = None, reference_audio_urls: Optional[list[str]] = None, ) -> dict: - """Build and validate the documented MiniMax H3 / H3 Max request body.""" + """Build and validate the documented MiniMax H3 family request body.""" prompt = _validate_prompt(prompt) + if mode == LEGACY_MODE_REFERENCE: + mode = MODE_REFERENCE seed = _validate_seed(seed) _validate_generation_options(model, resolution, duration, mode) + _validate_ratio(model, mode, ratio) reference_image_urls = [url for url in (reference_image_urls or []) if url] reference_video_urls = [url for url in (reference_video_urls or []) if url] @@ -179,8 +201,6 @@ def build_request_body( if mode == MODE_TEXT: if has_first_last_material or has_reference_material: raise ValueError("文生视频不能同时使用首尾帧或参考素材。") - if ratio not in RATIO_OPTIONS: - raise ValueError("MiniMax H3 文生视频必须选择具体宽高比,不能使用 adaptive。") request_ratio = ratio elif mode == MODE_FIRST: if last_url or has_reference_material: @@ -252,8 +272,6 @@ def build_request_body( for url in reference_audio_urls ) request_ratio = ratio or "adaptive" - if request_ratio not in REFERENCE_RATIO_OPTIONS: - raise ValueError(f"MiniMax H3 参考素材模式不支持宽高比:{request_ratio}") else: raise ValueError(f"不支持的 MiniMax H3 生成模式:{mode}") @@ -300,6 +318,21 @@ def _build_mode_input(): return io.DynamicCombo.Input( "生成模式", options=[ + # DynamicCombo defaults to its first option in the bundled frontend. + io.DynamicCombo.Option( + MODE_REFERENCE, + [ + reference_images, + reference_videos, + reference_audios, + io.Combo.Input( + "宽高比", + options=REFERENCE_RATIO_OPTIONS, + default="adaptive", + tooltip="H3/Highspeed 默认 adaptive;Lite 必须指定具体比例。", + ), + ], + ), io.DynamicCombo.Option( MODE_TEXT, [ @@ -326,20 +359,6 @@ def _build_mode_input(): io.Image.Input("尾帧图片"), ], ), - io.DynamicCombo.Option( - MODE_REFERENCE, - [ - reference_images, - reference_videos, - reference_audios, - io.Combo.Input( - "宽高比", - options=REFERENCE_RATIO_OPTIONS, - default="adaptive", - tooltip="参考素材模式默认 adaptive,也可指定具体比例。", - ), - ], - ), ], tooltip="首尾帧模式与参考素材模式互斥。", ) @@ -403,7 +422,7 @@ class MiniMaxH3Video(io.ComfyNode): display_name="MiniMax H3 / H3 Max 视频生成", category="comfyui_o1key/Video", description=( - "通过 New API 网关调用 MiniMax-H3 或 MiniMax-H3-MAX;H3 支持多模态参考,H3 Max 支持文生和首尾帧模式。" + "支持 H3、Highspeed、Lite、H3 Max;前三者支持多模态参考。Highspeed 兼顾质量与速度,Lite 侧重低成本。Lite 参考模式须指定具体比例;Highspeed/Lite 使用尾帧时须同时提供首帧。" ), inputs=[ io.String.Input( @@ -413,6 +432,12 @@ class MiniMaxH3Video(io.ComfyNode): placeholder="描述画面、动作、镜头与声音...", tooltip="必填,最多 7000 字符。", ), + io.Combo.Input( + "模型", + options=MODEL_OPTIONS, + default=MODEL_ID, + tooltip="H3:768P/2K;Highspeed/Lite:480P/768P、多模态参考;H3 Max:480P/768P,不支持参考素材。", + ), _build_mode_input(), io.Combo.Input( "分辨率", @@ -426,13 +451,7 @@ class MiniMaxH3Video(io.ComfyNode): max=15, step=1, display_mode=io.NumberDisplay.slider, - tooltip="H3 支持 4~15 秒;H3 Max 支持 5~15 秒。", - ), - io.Combo.Input( - "模型", - options=MODEL_OPTIONS, - default=MODEL_ID, - tooltip="H3 支持 768P/2K 和多模态参考;H3 Max 支持 480P/768P,不支持参考素材模式。", + tooltip="H3/Highspeed/Lite 支持 4~15 秒;H3 Max 支持 5~15 秒。", ), io.Int.Input( "seed", @@ -447,7 +466,7 @@ class MiniMaxH3Video(io.ComfyNode): ], outputs=[io.Video.Output(display_name="视频")], not_idempotent=True, - search_aliases=["MiniMax H3", "MiniMax H3 Max", "海螺视频", "H3 视频"], + search_aliases=["MiniMax H3", "MiniMax H3 Max", "MiniMax H3 Highspeed", "MiniMax H3 Lite", "海螺视频", "H3 视频"], accept_all_inputs=True, ) @@ -466,7 +485,10 @@ class MiniMaxH3Video(io.ComfyNode): if not isinstance(生成模式, dict): raise ValueError("MiniMax H3 生成模式参数无效。") mode = 生成模式.get("生成模式") + if mode == LEGACY_MODE_REFERENCE: + mode = MODE_REFERENCE _validate_generation_options(模型, 分辨率, int(时长), mode) + _validate_ratio(模型, mode, 生成模式.get("宽高比")) base_url = get_base_url_by_route() first_url = None diff --git a/nodes/seedance_autopass.py b/nodes/seedance_autopass.py index df72982..8c9332f 100644 --- a/nodes/seedance_autopass.py +++ b/nodes/seedance_autopass.py @@ -45,7 +45,8 @@ from comfy_api.latest import InputImpl, io _BASE_MODELS = ["seedance 2.0", "seedance 2.0 fast", "seedance 2.0 mini", "seedance 2.5"] # 全能生成视频节点把最新的 2.5 放在模型选择最上方。 -_AUTOPASS_BASE_MODELS = ["seedance 2.5", "seedance 2.0", "seedance 2.0 fast", "seedance 2.0 mini"] +_AUTOPASS_BASE_MODELS = ["seedance 2.5", "seedance 2.5 flash", "seedance 2.0", "seedance 2.0 fast", "seedance 2.0 mini"] +_BASE_MODELS_25 = {"seedance 2.5", "seedance 2.5 flash"} _MODEL_ROUTES = ["海外", "国内"] _LEGACY_MODEL_ROUTES = { "海外HC": "海外", @@ -61,6 +62,7 @@ _CANONICAL_MODELS = { "seedance 2.0 fast": "seedance-2.0-fast", "seedance 2.0 mini": "seedance-2.0-mini", "seedance 2.5": "seedance-2.5", + "seedance 2.5 flash": "seedance-2.5-flash", } _CANONICAL_ROUTES = {"国内": "domestic", "海外": "overseas_hc"} @@ -69,12 +71,16 @@ _MODEL_MATRIX = { (display_model, display_route): SEEDANCE_MODEL_MATRIX[(model, route)] for display_model, model in _CANONICAL_MODELS.items() for display_route, route in _CANONICAL_ROUTES.items() + if (model, route) in SEEDANCE_MODEL_MATRIX } _MODEL_CAPABILITIES = { display_model: { **SEEDANCE_CAPABILITIES[model], - "routes": set(_MODEL_ROUTES), + "routes": { + display_route for display_route, route in _CANONICAL_ROUTES.items() + if (model, route) in SEEDANCE_MODEL_MATRIX + }, } for display_model, model in _CANONICAL_MODELS.items() } @@ -396,7 +402,7 @@ class SeedanceAutoPass(io.ComfyNode): if canonical_mode in {"edit", "extend"}: if len(ref_videos) != 1: raise ValueError("视频编辑和视频延长必须且只能提供一段参考视频") - if base_model != "seedance 2.5": + if base_model not in _BASE_MODELS_25: raise ValueError("视频编辑和视频延长仅支持 seedance 2.5") if not prompt: raise ValueError("视频编辑和视频延长必须填写提示词") @@ -415,9 +421,9 @@ class SeedanceAutoPass(io.ComfyNode): if not (prompt or ref_images or ref_videos or ref_audios): raise ValueError("多模态模式下,提示词和参考素材不能同时为空") - if base_model != "seedance 2.5" and ref_audios and not (ref_images or ref_videos): + if base_model not in _BASE_MODELS_25 and ref_audios and not (ref_images or ref_videos): raise ValueError("Seedance 2.0 系列不可单独输入参考音频,须同时提供参考图片或参考视频") - if base_model == "seedance 2.5" and ref_audios and not (ref_images or ref_videos) and not prompt: + if base_model in _BASE_MODELS_25 and ref_audios and not (ref_images or ref_videos) and not prompt: raise ValueError("Seedance 2.5 仅有参考音频时必须填写提示词") return canonical_mode @@ -641,7 +647,7 @@ class SeedanceAutoPass(io.ComfyNode): asset_creation_mode=normalized["asset_creation_mode"], output_format=( output_format - if base_model == "seedance 2.5" and output_format == "mov" + if base_model in _BASE_MODELS_25 and output_format == "mov" else None ), ) diff --git a/tests/test_minimax_h3.py b/tests/test_minimax_h3.py index dd116f8..c79b7b1 100644 --- a/tests/test_minimax_h3.py +++ b/tests/test_minimax_h3.py @@ -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() diff --git a/tests/test_o1key_image_generator_frontend.mjs b/tests/test_o1key_image_generator_frontend.mjs index 27d8e7c..3045a0d 100644 --- a/tests/test_o1key_image_generator_frontend.mjs +++ b/tests/test_o1key_image_generator_frontend.mjs @@ -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秒"); } { diff --git a/tests/test_seedance_autopass_v3.py b/tests/test_seedance_autopass_v3.py index c42f336..c2ef69e 100644 --- a/tests/test_seedance_autopass_v3.py +++ b/tests/test_seedance_autopass_v3.py @@ -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(**{ diff --git a/utils/o1key_video_catalog.py b/utils/o1key_video_catalog.py index 7f8c19b..f5629f0 100644 --- a/utils/o1key_video_catalog.py +++ b/utils/o1key_video_catalog.py @@ -12,6 +12,8 @@ SEEDANCE_MODEL_OPTIONS = [ "seedance-2.0-mini", "seedance-2.5", ] +# Panel choices stay curated; the shared capability registry also serves graph nodes. +SEEDANCE_25_MODELS = {"seedance-2.5", "seedance-2.5-flash"} SEEDANCE_ROUTE_OPTIONS = ["domestic", "overseas_hc"] SEEDANCE_ASSET_CREATION_MODE_OPTIONS = ["direct", "auto", "manual"] VIDEO_GENERATION_MODE_OPTIONS = [ @@ -44,6 +46,7 @@ SEEDANCE_MODEL_MATRIX = { ("seedance-2.0-fast", "domestic"): "doubao-seedance-2-0-fast-260128-max", ("seedance-2.0-mini", "domestic"): "doubao-seedance-2-0-mini-260615-max", ("seedance-2.5", "domestic"): "doubao-seedance-2-5-260628-max", + ("seedance-2.5-flash", "domestic"): "doubao-seedance-2-5-flash", ("seedance-2.0", "overseas_hc"): "dreamina-seedance-2-0-hc", ("seedance-2.0-fast", "overseas_hc"): "dreamina-seedance-2-0-fast-hc", ("seedance-2.0-mini", "overseas_hc"): "dreamina-seedance-2-0-mini-hc", @@ -87,6 +90,15 @@ SEEDANCE_CAPABILITIES = { "resolutions": ["480p", "720p", "1080p"], "reference_seconds": 30, }, + "seedance-2.5-flash": { + "duration_min": 4, + "duration_max": 30, + "images": 10, + "videos": 5, + "audios": 5, + "resolutions": ["480p", "720p"], + "reference_seconds": 30, + }, } @@ -111,7 +123,7 @@ def normalize_seedance_parameters(payload: dict[str, Any]) -> dict[str, Any]: raise ValueError(f"暂不支持的视频提供方:{provider}") model = str(payload.get("model") or "seedance-2.0").strip() - if model not in SEEDANCE_MODEL_OPTIONS: + if model not in SEEDANCE_CAPABILITIES: raise ValueError(f"不支持的 Seedance 模型:{model}") route = str(payload.get("route") or "domestic").strip() if route not in SEEDANCE_ROUTE_OPTIONS: @@ -155,12 +167,12 @@ def normalize_seedance_parameters(payload: dict[str, Any]) -> dict[str, Any]: # 文档约束:2.5 的编辑/延长只用 adaptive,编辑必须显式 -1,首帧类也跟随图片比例 if mode in {"edit", "extend"}: - if model != "seedance-2.5": + if model not in SEEDANCE_25_MODELS: raise ValueError("视频编辑和视频延长仅支持 Seedance 2.5") aspect_ratio = "auto" if mode == "edit": duration = -1 - if model == "seedance-2.5" and mode in {"first_frame", "first_last_frame"}: + if model in SEEDANCE_25_MODELS and mode in {"first_frame", "first_last_frame"}: aspect_ratio = "auto" filename_prefix = str(payload.get("filename_prefix") or "o1key_video").strip() @@ -319,6 +331,7 @@ def public_video_capabilities() -> dict[str, Any]: __all__ = [ + "SEEDANCE_25_MODELS", "MAX_VIDEO_PROMPT_CHARS", "SEEDANCE_CAPABILITIES", "SEEDANCE_ASSET_CREATION_MODE_OPTIONS", diff --git a/utils/o1key_video_jobs.py b/utils/o1key_video_jobs.py index 0b5aab8..1890f05 100644 --- a/utils/o1key_video_jobs.py +++ b/utils/o1key_video_jobs.py @@ -23,6 +23,7 @@ from .config import get_base_url_by_route from .http_error import format_o1key_video_error from .o1key_image_save import normalize_save_location from .o1key_video_catalog import ( + SEEDANCE_25_MODELS, SEEDANCE_REFERENCE_AUDIO_EXTENSIONS, SEEDANCE_REFERENCE_AUDIO_MAX_BYTES, SEEDANCE_REFERENCE_IMAGE_MAX_BYTES, @@ -240,7 +241,7 @@ def normalize_video_job_payload(payload: Any) -> dict[str, Any]: ) if ( mode == "multimodal" - and normalized["model"] != "seedance-2.5" + and normalized["model"] not in SEEDANCE_25_MODELS and audio_total and not image_total and not video_total @@ -248,7 +249,7 @@ def normalize_video_job_payload(payload: Any) -> dict[str, Any]: raise ValueError("Seedance 2.0 系列不可单独使用参考音频") if ( mode == "multimodal" - and normalized["model"] == "seedance-2.5" + and normalized["model"] in SEEDANCE_25_MODELS and audio_total and not image_total and not video_total diff --git a/web/js/migrateWorkflow.js b/web/js/migrateWorkflow.js index 029f1cf..593b7d3 100644 --- a/web/js/migrateWorkflow.js +++ b/web/js/migrateWorkflow.js @@ -94,6 +94,7 @@ const SEEDANCE_AUTO_PASS_MODELS = new Set([ "seedance 2.0 fast", "seedance 2.0 mini", "seedance 2.5", + "seedance 2.5 flash", ]); const SEEDANCE_AUTO_PASS_ROUTES = new Set(["国内", "海外", "海外HC", "海外破限高并发", "海外破限", "海外破限标准", "海外标准"]); const SEEDANCE_AUTO_PASS_NODE_TYPES = new Set(["SeedanceAutoPass", "SeedanceAutoPassBatch"]); @@ -136,7 +137,7 @@ const GLOBAL_ROUTE_NODE_TYPES = new Set([ "SeedanceAutoPassBatch", "UniversalLLMChat", ]); -const MINIMAX_H3_MODELS = new Set(["MiniMax-H3", "MiniMax-H3-MAX"]); +const MINIMAX_H3_MODELS = new Set(["MiniMax-H3", "MiniMax-H3-MAX", "MiniMax-H3-Highspeed", "MiniMax-H3-Lite"]); const OMNI_FLASH_MODELS = new Set(["omni_flash_8s", "omni_flash_10s"]); const GROK_VIDEO_MODES = new Set(["文生视频", "图生视频", "参考生视频"]); const GROK_VIDEO_EDIT_MODES = new Set(["编辑视频", "续写视频"]); @@ -353,8 +354,10 @@ const MIGRATIONS = [ type: "MiniMaxH3Video", note: "为 MiniMax H3 节点补齐模型参数", when: (wv) => wv.length >= 4 + && !MINIMAX_H3_MODELS.has(wv[1]) && !MINIMAX_H3_MODELS.has(wv[wv.length - 1]) - && !MINIMAX_H3_MODELS.has(wv[wv.length - 2]), + && !MINIMAX_H3_MODELS.has(wv[wv.length - 2]) + && !MINIMAX_H3_MODELS.has(wv[wv.length - 3]), apply: (wv) => wv.push("MiniMax-H3"), }, { @@ -363,6 +366,23 @@ const MIGRATIONS = [ when: (wv) => wv.length >= 5 && MINIMAX_H3_MODELS.has(wv[wv.length - 1]), apply: (wv) => wv.push(0), }, + { + type: "MiniMaxH3Video", + note: "将 MiniMax H3 模型移至生成模式上方", + when: (wv) => !MINIMAX_H3_MODELS.has(wv[1]) + && [wv.length - 2, wv.length - 3].some((index) => MINIMAX_H3_MODELS.has(wv[index])), + apply: (wv) => { + const index = [wv.length - 2, wv.length - 3].find((index) => MINIMAX_H3_MODELS.has(wv[index])); + const [model] = wv.splice(index, 1); + wv.splice(1, 0, model); + }, + }, + { + type: "MiniMaxH3Video", + note: "将 MiniMax H3 参考素材模式更名为多模态生视频", + when: (wv) => wv[2] === "参考素材生视频", + apply: (wv) => { wv[2] = "多模态生视频"; }, + }, { type: "O1keyImageGenerator", note: "移除统一图片生成节点已停用的色彩纠正参数", diff --git a/web/js/minimaxH3ParameterGuard.js b/web/js/minimaxH3ParameterGuard.js index bb997ab..0bd4a33 100644 --- a/web/js/minimaxH3ParameterGuard.js +++ b/web/js/minimaxH3ParameterGuard.js @@ -3,19 +3,67 @@ import { app } from "../../../scripts/app.js"; const NODE_TYPE = "MiniMaxH3Video"; const MODEL_H3 = "MiniMax-H3"; const MODEL_MAX = "MiniMax-H3-MAX"; +const MODEL_HIGHSPEED = "MiniMax-H3-Highspeed"; +const MODEL_LITE = "MiniMax-H3-Lite"; const MODE_TEXT = "文生视频"; -const MODE_REFERENCE = "参考素材生视频"; +const MODE_REFERENCE = "多模态生视频"; +const MODE_LAST = "尾帧图生视频"; +const MODE_FIRST_LAST = "首尾帧生视频"; +const FIXED_RATIOS = ["16:9", "21:9", "4:3", "1:1", "3:4", "9:16"]; const RESOLUTIONS = { [MODEL_H3]: ["2K", "768P"], [MODEL_MAX]: ["768P", "480P"], + [MODEL_HIGHSPEED]: ["768P", "480P"], + [MODEL_LITE]: ["768P", "480P"], }; const MIN_DURATION = { [MODEL_H3]: 4, [MODEL_MAX]: 5, + [MODEL_HIGHSPEED]: 4, + [MODEL_LITE]: 4, }; function findWidget(node, name) { - return node.widgets?.find((widget) => widget.name === name); + for (const widget of node.widgets || node.childWidgets || []) { + if (widget.name === name || widget.name?.endsWith(`.${name}`)) return widget; + const nested = findWidget(widget, name); + if (nested) return nested; + } +} + +function selectedModel(node) { + const value = findWidget(node, "模型")?.value; + return Object.hasOwn(RESOLUTIONS, value) ? value : MODEL_H3; +} + +function allowedRatios(node) { + return findWidget(node, "生成模式")?.value === MODE_REFERENCE + && selectedModel(node) !== MODEL_LITE + ? ["adaptive", ...FIXED_RATIOS] : FIXED_RATIOS; +} + +function updateRatio(node, silent) { + const widget = findWidget(node, "宽高比"); + if (!widget) return; + widget.options ??= {}; + widget.options.values = allowedRatios(node); + if (!widget.__o1keyMiniMaxRatioGuard) { + widget.__o1keyMiniMaxRatioGuard = true; + const originalCallback = widget.callback; + widget.callback = function (value, ...args) { + const allowed = allowedRatios(node); + const next = allowed.includes(value) ? value : allowed[0]; + if (next !== value) { + widget.value = next; + notify(`${selectedModel(node)} 当前模式须使用具体比例,已切换为 ${next}。`); + } + return originalCallback?.call(this, next, ...args); + }; + } + if (!widget.options.values.includes(widget.value)) { + setWidgetValue(widget, widget.options.values[0]); + if (!silent) notify(`${selectedModel(node)} 当前模式须使用具体比例,已切换为 ${widget.value}。`); + } } function notify(detail) { @@ -40,7 +88,7 @@ function updateParameters(node, silent = false) { const durationWidget = findWidget(node, "时长"); if (!modelWidget || !modeWidget || !resolutionWidget || !durationWidget) return; - const model = modelWidget.value === MODEL_MAX ? MODEL_MAX : MODEL_H3; + const model = selectedModel(node); const allowedResolutions = RESOLUTIONS[model]; resolutionWidget.options ??= {}; resolutionWidget.options.values = [...allowedResolutions]; @@ -64,6 +112,13 @@ function updateParameters(node, silent = false) { if (!silent) notify("MiniMax-H3-MAX 不支持参考素材模式,已切换为文生视频。"); } + if ([MODEL_HIGHSPEED, MODEL_LITE].includes(model) && modeWidget.value === MODE_LAST) { + setWidgetValue(modeWidget, MODE_FIRST_LAST); + if (!silent) notify(`${model} 使用尾帧时须同时提供首帧,已切换为首尾帧生视频。`); + } + + updateRatio(node, silent); + node.setDirtyCanvas?.(true, true); } @@ -92,12 +147,14 @@ function guardNode(node) { node.setDirtyCanvas?.(true, true); return originalModeCallback?.call(this, MODE_TEXT); } - return originalModeCallback?.apply(this, arguments); + const result = originalModeCallback?.apply(this, arguments); + updateParameters(node); + return result; }; const originalResolutionCallback = resolutionWidget.callback; resolutionWidget.callback = function (value) { - const model = modelWidget.value === MODEL_MAX ? MODEL_MAX : MODEL_H3; + const model = selectedModel(node); if (!RESOLUTIONS[model].includes(value)) { resolutionWidget.value = "768P"; notify(`${model} 不支持 ${value},已切换为 768P。`); @@ -109,7 +166,7 @@ function guardNode(node) { const originalDurationCallback = durationWidget.callback; durationWidget.callback = function (value) { - const model = modelWidget.value === MODEL_MAX ? MODEL_MAX : MODEL_H3; + const model = selectedModel(node); const minimum = MIN_DURATION[model]; const duration = Number(value); if (Number.isFinite(duration) && duration < minimum) { diff --git a/web/js/seedanceAutoPassDynamic.js b/web/js/seedanceAutoPassDynamic.js index 3506d1e..de5cc5f 100644 --- a/web/js/seedanceAutoPassDynamic.js +++ b/web/js/seedanceAutoPassDynamic.js @@ -2,6 +2,7 @@ import { app } from "../../../scripts/app.js"; const NODE_TYPES = new Set(["SeedanceAutoPass", "SeedanceAutoPassBatch"]); const MODEL_25 = "seedance 2.5"; +const MODEL_25_FLASH = "seedance 2.5 flash"; const OVERSEAS_ROUTE = "海外"; const LEGACY_MODEL_ROUTES = new Set(["海外HC", "海外破限高并发", "海外破限", "海外破限标准", "海外标准"]); const ALL_RESOLUTIONS = ["480p", "720p", "1080p", "4k"]; @@ -9,6 +10,7 @@ const LIMITED_RESOLUTIONS = ["480p", "720p"]; const LIMITED_RESOLUTION_MODELS = new Set([ "seedance 2.0 fast", "seedance 2.0 mini", + MODEL_25_FLASH, ]); const NO_4K_RESOLUTIONS = ["480p", "720p", "1080p"]; const RESOLUTION_FALLBACK = "720p"; @@ -237,12 +239,16 @@ function updateDynamicParameters(node, silent = false) { const draftWidget = findWidget(node, "样片模式"); if (!modelWidget || !routeWidget || !resolutionWidget || !durationWidget) return; - const is25 = modelWidget.value === MODEL_25; + const is25 = [MODEL_25, MODEL_25_FLASH].includes(modelWidget.value); + const supportsDraft = modelWidget.value === MODEL_25; + const routes = modelWidget.value === MODEL_25_FLASH ? ["国内"] : ["海外", "国内"]; + routeWidget.options ??= {}; + routeWidget.options.values = routes; // 样片模式仅 2.5 可用:其他模型直接隐藏,并强制回到「关闭」。 if (draftWidget) { - setWidgetHidden(draftWidget, !is25); - if (!is25 && draftWidget.value !== DRAFT_OFF) { + setWidgetHidden(draftWidget, !supportsDraft); + if (!supportsDraft && draftWidget.value !== DRAFT_OFF) { setWidgetValue(draftWidget, DRAFT_OFF); if (!silent) notify("样片模式仅支持 Seedance 2.5,已关闭样片模式。"); } @@ -263,6 +269,10 @@ function updateDynamicParameters(node, silent = false) { if (LEGACY_MODEL_ROUTES.has(routeWidget.value)) { setWidgetValue(routeWidget, OVERSEAS_ROUTE); } + if (!routes.includes(routeWidget.value)) { + setWidgetValue(routeWidget, "国内"); + if (!silent) notify("Seedance 2.5 Flash 仅支持国内线路,已自动切换。"); + } if (!allowedResolutions.includes(resolutionWidget.value)) { setWidgetValue(resolutionWidget, fallbackResolution); @@ -309,6 +319,11 @@ function guardNode(node) { const originalRouteCallback = routeWidget.callback; routeWidget.callback = function (value) { + if (modelWidget.value === MODEL_25_FLASH && value !== "国内") { + routeWidget.value = "国内"; + notify("Seedance 2.5 Flash 仅支持国内线路。"); + return originalRouteCallback?.call(this, "国内"); + } if (LEGACY_MODEL_ROUTES.has(value)) { routeWidget.value = OVERSEAS_ROUTE; node.setDirtyCanvas?.(true, true); @@ -331,7 +346,7 @@ function guardNode(node) { const originalDurationCallback = durationWidget.callback; durationWidget.callback = function (value) { - const maximumDuration = modelWidget.value === MODEL_25 ? 30 : 15; + const maximumDuration = [MODEL_25, MODEL_25_FLASH].includes(modelWidget.value) ? 30 : 15; const duration = Number.parseInt(value, 10); if (Number.isFinite(duration) && duration > maximumDuration) { const fallback = `${maximumDuration}秒`;