Compare commits

...
14 Commits
14 changed files with 13561 additions and 10077 deletions
+53
View File
@@ -0,0 +1,53 @@
H3-LongVideos — Licence
Copyright (c) 2026 Smite79. All rights reserved.
This licence applies to every version published on or after 2026-09-07.
WHAT YOU MAY DO
1. Download and use this software, in unmodified or modified form, for your
own purposes, personal or commercial. Rendering with it, and whatever you
render with it, is yours and is not covered by this licence.
2. Modify your own copy.
3. Submit changes back to the original project.
WHAT YOU MAY NOT DO WITHOUT WRITTEN PERMISSION
4. Redistribute this software, in whole or in part, modified or unmodified.
That includes publishing it to any repository, registry, model hub, node
manager, marketplace, or mirror; bundling it inside another package,
product, image, or installer; and hosting it as a service.
5. Remove, alter, or obscure the copyright notice above, this licence, or the
attribution in the source files — including where a permitted redistribution
has been agreed.
6. Represent this software, or a derivative of it, as your own work.
ASKING
Permission for anything under 4 is granted case by case and is usually given
for things like inclusion in a node manager. Ask via the project's GitHub
issues at https://github.com/Smite79/MiniMax-H3-LongVideos.
EARLIER VERSIONS
Versions published before 2026-09-07 were released under Apache License 2.0.
That grant is irrevocable for those versions: copies obtained under it stay
under it, and this licence does not and cannot withdraw it retroactively. It
governs this version and every version after it.
Apache 2.0 also required attribution, so a copy of an earlier version
republished with the copyright notice stripped was already in breach of the
licence it was taken under.
NO WARRANTY
This software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose, and non-infringement. In no event shall the
copyright holder be liable for any claim, damages, or other liability, whether
in an action of contract, tort, or otherwise, arising from, out of, or in
connection with the software or the use or other dealings in the software.
+28 -23
View File
@@ -33,18 +33,13 @@
- Outputs: `plan`, `image1`..`image9`, `connected_images` - Outputs: `plan`, `image1`..`image9`, `connected_images`
- Reads back the nine optional images for a selected MiniMax H3 plan scene, for example by connecting the current `clip_index`. - Reads back the nine optional images for a selected MiniMax H3 plan scene, for example by connecting the current `clip_index`.
- `Dumas H3 Long Videos (FL2VA + REF2VA)` - `Dumas H3 Long Videos`
- Inputs: H3 model stack, prompt socket, optional `first_frame`, optional `ref_1`..`ref_9`, plus the upstream long-video control surface for pacing, continuity, audio, overlays, and guards - Inputs/outputs: the current upstream `MiniMax-H3-Longvideos` sampler surface, exposed under the existing `DumasH3LongVideos` key for saved Dumas workflows.
- Outputs: `images`, `audio`, `info`, `script`, `frames_per_shot`, `total_frames`, `shots`, `video_seconds`, `fps`, `fps_int`, `latent`, `soundscape` - The local Dumas prompt-engineering fork has been removed from this node. Long Videos now wraps the upstream sampler/engine directly so it can track the source project again.
- First-pass Dumas port of the `MiniMax-H3-Longvideos` sampler, brought in as a local starting point for long-form H3 chaining work. - Upstream compatibility keys `H3LongVideos`, `H3LongVideosFL2VA`, `H3LongVideosV1`, and `H3LongVideosREF2VA` are also registered to the same class.
- Keeps the upstream split-beats / handoff / ref-routing behavior close to source so future Dumas-specific improvements can be compared against a known baseline. - The old Dumas browser widget grouping script is disabled for this node because it targeted controls that no longer exist on the upstream sampler.
- Full user guide: [`H3_LONG_VIDEOS_GUIDE.md`](./H3_LONG_VIDEOS_GUIDE.md) - `handoff_frames` extends the upstream last-frame handoff: `1` keeps the current single keyframe behavior; higher values keep that final-frame keyframe and add earlier tail frames from the previous shot as claimed reference context for the next beat.
- Only the canonical `DumasH3LongVideos` node key is exposed now; the older FL2VA/REF2VA alias entries are no longer duplicated in the Add Node menu. - Upstream license text is included in [`H3_LONGVIDEOS_UPSTREAM_LICENSE.txt`](./H3_LONGVIDEOS_UPSTREAM_LICENSE.txt).
- Prompt `<Picture N>` tags now map to the actual ref socket numbers you wire, even with gaps such as only `ref_2` and `ref_7` connected.
- Character refs now contribute appearance and wardrobe context from the same structured object, while location refs contribute environment context from theirs.
- The default ref2v bias is now stronger: `ref_mode` defaults to `auto ref2v` so untagged prompts condition every shot instead of only shot 1, and `ref_noise_aug` defaults to `0.95` rather than the upstream-literal `0.999`.
- `Dumas H3 Latent Upscale Params` provides the optional pre-decode latent refinement stage for the long-video node.
- Per-shot directives now support `continuity:`, `ref_mode:`, `ref_noise_aug:`, `anchor_add:`, `soundscape:`, and `music:` in addition to the existing timing and wardrobe directives.
- `Dumas H3 Latent Upscale Params` - `Dumas H3 Latent Upscale Params`
- Inputs: `mode`, `model_name`, `method`, `width`, `height`, `device`, `precision`, `sampler_name`, `scheduler`, `steps`, `denoise`, `megapixels`, `tile_width`, `tile_height`, `overlap`, `fade_width`, `fade_height`, `overlap_mode`, `overlap_blend`, `tile_size_mode`, `grid_rows`, `grid_cols`, `spatial_w_overlap`, `spatial_h_overlap`, `min_tile_size`, `masked_area_noise`, `brightness_match`, `dynamic_fade`, `dynamic_fade_min`, `chunk_length`, `temporal_overlap`, `resize_conditioning`, `anchor_strength` - Inputs: `mode`, `model_name`, `method`, `width`, `height`, `device`, `precision`, `sampler_name`, `scheduler`, `steps`, `denoise`, `megapixels`, `tile_width`, `tile_height`, `overlap`, `fade_width`, `fade_height`, `overlap_mode`, `overlap_blend`, `tile_size_mode`, `grid_rows`, `grid_cols`, `spatial_w_overlap`, `spatial_h_overlap`, `min_tile_size`, `masked_area_noise`, `brightness_match`, `dynamic_fade`, `dynamic_fade_min`, `chunk_length`, `temporal_overlap`, `resize_conditioning`, `anchor_strength`
@@ -54,14 +49,17 @@
- `Dumas H3 Beat Prompt` - `Dumas H3 Beat Prompt`
- Inputs: authored through the custom front-end beat editor - Inputs: authored through the custom front-end beat editor
- Output: `prompt` - Output: `prompt`
- Builds one H3 prompt block per beat, with quick controls for per-shot timing, continuity, ref behavior, anchor additions, soundscape, and music while staying compatible with direct text editing. - Builds an upstream-compatible Long Videos prompt: optional scene paragraph, optional character sheet, then one blank-line-separated textbox per beat.
- Per-beat helpers only emit upstream-supported state directives: `remove:` / `removed:` / `off:` and `add:` / `wear:` / `wearing:`.
- Old Dumas-only beat directives such as `seconds:`, `continuity:`, `ref_mode:`, `ref_noise_aug:`, `anchor_add:`, `soundscape:`, and `music:` are stripped from the generated prompt so they are not sent to the upstream node as visible text.
- `Dumas H3 Prompt Curator` - `Dumas H3 Prompt Curator`
- Inputs: `action_prompt`, `anatomy_guard`, `subject_count_guard`, optional `anchor`, optional `soundscape`, optional `ref_1` through `ref_9` - Inputs: `action_prompt`, `anatomy_guard`, `subject_count_guard`, optional `anchor`, optional `soundscape`, optional `bgm`, optional `ref_1` through `ref_9`
- Outputs: `prompt`, `ref_image_1` through `ref_image_9`, `reference_count`, `debug` - Outputs: `prompt`, `ref_image_1` through `ref_image_9`, `reference_count`, `debug`, `anchor`, `sounds`, `bgm`, `original_ref_1` through `original_ref_9`, `compiled_ref_description_1` through `compiled_ref_description_9`
- Builds one standalone MiniMax H3 prompt from your final action text plus structured character/location references. - Builds one standalone MiniMax H3 prompt from your final action text plus structured character/location references.
- The action text can mention references by character/location name, alias, `<Picture N>`, or `<refN>`. Only mentioned references are emitted, and the output images are compacted/renumbered so skipped inputs do not leave gaps. - The action text can mention references by character/location name, alias, `<Picture N>`, or `<refN>`. Only mentioned references are emitted, and the output images are compacted/renumbered so skipped inputs do not leave gaps.
- Adds curated reference context, anatomy guard text, optional subject-count guard text, anchor/style text, and `overall_soundscape:` text while respecting MiniMax H3's reference-generation shape: one prompt plus up to nine reference images. - Extra component outputs expose the cleaned anchor, sounds, BGM, and each selected original reference image plus its compiled reference description in compacted order.
- Adds curated reference context, anatomy guard text, optional subject-count guard text, anchor/style text, `overall_soundscape:` text, and `background_music:` text while respecting MiniMax H3's reference-generation shape: one prompt plus up to nine reference images.
- `Dumas H3 Shot Length` - `Dumas H3 Shot Length`
- Inputs: `shot_seconds`, `fps`, optional `cap_to_h3_max` - Inputs: `shot_seconds`, `fps`, optional `cap_to_h3_max`
@@ -85,25 +83,32 @@
- `Dumas Character Helper` - `Dumas Character Helper`
- Inputs: `image1`, `image2`, picture IDs, character identity fields, `general`, `wardrobe` - Inputs: `image1`, `image2`, picture IDs, character identity fields, `general`, `wardrobe`
- Outputs: `image1`, `image2`, `reference_prompt`, `wardrobe` - Outputs: `image1`, `image2`, `reference_prompt`, `wardrobe`, `reference1`, `reference2`
- Restores the original general-purpose helper shape: pass two images through unchanged and emit prompt text/wardrobe text for manual wiring. - Restores the original general-purpose helper shape while also emitting two structured `REFERENCE` objects for the prompt curator.
- The structured references carry the same character name, alias, age, height, gender, nationality, occupation, accent, wardrobe, and notes, so mentioning the character name in `Dumas H3 Prompt Curator` can include both helper images and the character facts automatically.
- `Dumas Location Helper` - `Dumas Location Helper`
- Inputs: `image1`, `image2`, picture IDs, `location_id`, `name`, `alias`, `description`, `general` - Inputs: `image1`, `image2`, picture IDs, `location_id`, `name`, `alias`, `description`, `general`
- Outputs: `image1`, `image2`, `reference_prompt` - Outputs: `image1`, `image2`, `reference_prompt`, `reference1`, `reference2`
- Matching general-purpose helper for environments/locations: pass two images through unchanged and emit location reference prompt text. - Matching general-purpose helper for environments/locations: pass two images through unchanged, emit location reference prompt text, and provide two structured `REFERENCE` objects for the prompt curator.
- The structured references carry the same location name, alias, description, and notes, so mentioning the location name in `Dumas H3 Prompt Curator` can include both helper images and the location context automatically.
- `Dumas Anchor Style` - `Dumas Anchor Style`
- Inputs: `anchor_style`, `style_description` - Inputs: `anchor_style`, `style_description`
- Output: `anchor` - Output: `anchor`
- Offers a large preset dropdown of anchor-style titles such as cinematic action movie, comedy, found footage, 90s sitcom, mobile/cell phone captured, news broadcast, mockumentary, heist thriller, cyberpunk neon, nature documentary, courtroom drama, and more. - Offers a large preset dropdown of anchor-style titles such as cinematic action movie, comedy, found footage, 90s sitcom, mobile/cell phone captured, news broadcast, mockumentary, heist thriller, cyberpunk neon, nature documentary, courtroom drama, and more.
- The preset wording is tuned for H3-safe persistent anchors: camera language, lighting, texture, production treatment, and tone, without naming characters or describing one-off actions. - The preset wording is tuned for H3-safe persistent anchors: camera language, lighting, texture, production treatment, and tone, without naming characters or describing one-off actions.
- Selecting a preset fills the editable description field, and the edited multiline description is the `STRING` value passed downstream into H3 anchor sockets such as `anchor_override`. - Selecting a preset fills the editable description field, and the edited multiline description is the `STRING` value passed downstream.
- `Dumas Soundscape Helper` - `Dumas Soundscape Helper`
- Inputs: `soundscape`, `soundscape_description` - Inputs: `soundscape`, `soundscape_description`
- Output: `soundscape` - Output: `soundscape`
- Matching soundscape helper for standalone H3 prompts. Pick a preset such as quiet interior, rainy street, cafe, city night, forest, industrial, or silent, then edit the text that flows into `Dumas H3 Prompt Curator`. - Matching soundscape helper for standalone H3 prompts. Pick a preset such as quiet interior, rainy street, cafe, city night, forest, industrial, or silent; the preset fills the editable textbox, and the edited text flows into `Dumas H3 Prompt Curator`.
- `Dumas Background Music Helper`
- Inputs: `bgm`, `bgm_description`
- Output: `bgm`
- Matching BGM helper for standalone H3 prompts. Pick a preset such as subtle tension, cinematic suspense, emotional piano, dark ambient, hopeful orchestral, retro synth, action pulse, lo-fi, or no vocals; the preset fills the editable textbox, and the edited text flows into `Dumas H3 Prompt Curator`.
- `Dumas JSON String to Object` - `Dumas JSON String to Object`
- Input: `json_string` - Input: `json_string`
@@ -261,7 +266,7 @@ decr -> use index - 1
`Dumas H3 Plan Attach Scene Images` and `Dumas H3 Plan Extract Scene Images` are a companion pair for `ComfyUI-MiniMaxH3-Contex-Loop` and the local `ref2v` lane. The upstream H3 plan node cannot dynamically grow nine new image sockets for every JSON-defined scene, so Dumas stores scene image bindings beside the plan using a lightweight token and an in-memory registry. That keeps `plan.json` archiving intact while still letting you wire up nine IMAGE sockets per scene through chained helper nodes. `Dumas H3 Plan Attach Scene Images` and `Dumas H3 Plan Extract Scene Images` are a companion pair for `ComfyUI-MiniMaxH3-Contex-Loop` and the local `ref2v` lane. The upstream H3 plan node cannot dynamically grow nine new image sockets for every JSON-defined scene, so Dumas stores scene image bindings beside the plan using a lightweight token and an in-memory registry. That keeps `plan.json` archiving intact while still letting you wire up nine IMAGE sockets per scene through chained helper nodes.
`Dumas Character Helper` is the restored two-image/text helper for general H3 workflows, and `Dumas Location Helper` mirrors it for scene/environment references. The structured `Dumas Character Reference` and `Dumas Location Reference` nodes remain available separately for workflows that want a single `REFERENCE` socket. `Dumas H3 Prompt Curator` consumes those structured references, assigns the final `<Picture N>` numbering, and outputs only the compacted images the prompt actually mentions. `Dumas Character Helper` is the restored two-image/text helper for general H3 workflows, and `Dumas Location Helper` mirrors it for scene/environment references. Both helpers also emit structured `REFERENCE` sockets for the curator. The structured `Dumas Character Reference` and `Dumas Location Reference` nodes remain available separately for workflows that want a single `REFERENCE` socket. `Dumas H3 Prompt Curator` consumes those structured references plus optional anchor, soundscape, and BGM strings, assigns the final `<Picture N>` numbering, and outputs only the compacted images the prompt actually mentions.
`Dumas Strip Iteration Suffix` keeps the part before the first underscore and drops the rest. Names like `char123_pose_final.png` become `char123.png`, while names with no underscore such as `char123.png` are left untouched. `Dumas Strip Iteration Suffix` keeps the part before the first underscore and drops the rest. Names like `char123_pose_final.png` become `char123.png`, while names with no underscore such as `char123.png` are left untouched.
+55 -8
View File
@@ -2,11 +2,46 @@ import json
_DEFAULT_BEAT = "Describe this beat." _DEFAULT_BEAT = "Describe this beat."
_DEFAULT_STATE = {"beats": [{"text": _DEFAULT_BEAT}]} _DEFAULT_STATE = {"scene": "", "character_sheet": "", "beats": [{"text": _DEFAULT_BEAT}]}
_LEGACY_DIRECTIVE_PREFIXES = (
"seconds",
"duration",
"continuity",
"ref_mode",
"ref_noise_aug",
"anchor_add",
"overall_soundscape",
"soundscape",
"non_diegetic_music",
"music",
"wardrobe",
"enter",
"exit",
)
def _clone_default_state(): def _clone_default_state():
return {"beats": [{"text": _DEFAULT_BEAT}]} return {
"scene": "",
"character_sheet": "",
"beats": [{"text": _DEFAULT_BEAT}],
}
def _strip_legacy_directives(text):
"""Remove directives from the abandoned Dumas Long Videos fork.
The upstream Long Videos node sends unknown field labels to the model as text,
so this builder strips the old managed controls rather than emitting prompts
that ask H3 to draw labels such as "seconds:" or "music:" in the frame.
"""
kept = []
for line in str(text or "").splitlines():
lowered = line.strip().lower()
if any(lowered.startswith(f"{name}:") for name in _LEGACY_DIRECTIVE_PREFIXES):
continue
kept.append(line)
return "\n".join(kept).strip()
def _parse_beat_prompt_state(value): def _parse_beat_prompt_state(value):
@@ -21,6 +56,8 @@ def _parse_beat_prompt_state(value):
except Exception: except Exception:
return _clone_default_state() return _clone_default_state()
scene = str(raw.get("scene") or "")
character_sheet = str(raw.get("character_sheet") or "")
beats = [] beats = []
for item in list(raw.get("beats") or []): for item in list(raw.get("beats") or []):
if isinstance(item, dict): if isinstance(item, dict):
@@ -30,15 +67,25 @@ def _parse_beat_prompt_state(value):
beats.append({"text": text}) beats.append({"text": text})
if not beats: if not beats:
return _clone_default_state() beats = [{"text": _DEFAULT_BEAT}]
return {"beats": beats} return {
"scene": scene,
"character_sheet": character_sheet,
"beats": beats,
}
def _assemble_beat_prompt(state): def _assemble_beat_prompt(state):
parsed = _parse_beat_prompt_state(state) parsed = _parse_beat_prompt_state(state)
chunks = [] chunks = []
scene = str(parsed.get("scene") or "").strip()
if scene:
chunks.append(scene)
character_sheet = str(parsed.get("character_sheet") or "").strip()
if character_sheet:
chunks.append(character_sheet)
for beat in parsed["beats"]: for beat in parsed["beats"]:
text = str(beat.get("text") or "").strip() text = _strip_legacy_directives(beat.get("text") or "")
if text: if text:
chunks.append(text) chunks.append(text)
return "\n\n".join(chunks) return "\n\n".join(chunks)
@@ -46,9 +93,9 @@ def _assemble_beat_prompt(state):
class DumasH3BeatPromptNode: class DumasH3BeatPromptNode:
DESCRIPTION = ( DESCRIPTION = (
"Build a MiniMax H3 prompt from one textbox per beat, with a front-end beat " "Build an upstream MiniMax H3 Long Videos prompt: optional scene paragraph, "
"editor that can append directive examples and expose per-shot controls for " "optional character sheet, then one blank-line-separated textbox per beat. "
"timing, continuity, ref behavior, anchor additions, soundscape, and music." "Per-beat helpers only emit directives the upstream node understands."
) )
RETURN_TYPES = ("STRING",) RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("prompt",) RETURN_NAMES = ("prompt",)
+26 -7919
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+238 -16
View File
@@ -27,6 +27,12 @@ _H3_PLAN_IMAGE_BINDINGS_CAP = 128
_H3_PLAN_IMAGE_SLOTS = 9 _H3_PLAN_IMAGE_SLOTS = 9
_FOLDER_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif", ".tiff", ".tif") _FOLDER_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif", ".tiff", ".tif")
_ANCHOR_STYLE_H3_NOTE = "" _ANCHOR_STYLE_H3_NOTE = ""
_ANCHOR_STYLE_LEGACY_NOTE_RE = re.compile(
r"\s*Keep this anchor focused on persistent camera language, lighting, "
r"texture, environment treatment, and tone; do not name characters or "
r"describe one-off actions\.?",
re.I,
)
_H3_PROMPT_REF_SLOTS = 9 _H3_PROMPT_REF_SLOTS = 9
_H3_PROMPT_MAX_CHARS = 7000 _H3_PROMPT_MAX_CHARS = 7000
_PICTURE_TAG_RE = re.compile(r"<\s*picture[\s_\-]*(\d+)\s*>", re.I) _PICTURE_TAG_RE = re.compile(r"<\s*picture[\s_\-]*(\d+)\s*>", re.I)
@@ -392,6 +398,51 @@ _SOUNDSCAPE_PRESETS = OrderedDict(
("custom", ""), ("custom", ""),
] ]
) )
_BGM_PRESETS = OrderedDict(
[
(
"none",
"",
),
(
"subtle tension",
"low, restrained tension bed with sparse pulses and no vocals",
),
(
"cinematic suspense",
"cinematic suspense score with muted strings, low drones, and controlled rising pressure",
),
(
"emotional piano",
"soft emotional piano underscoring with gentle space and no vocals",
),
(
"dark ambient",
"dark ambient music bed with deep drones, distant texture, and slow unease",
),
(
"hopeful orchestral",
"hopeful orchestral underscore with warm strings, gentle brass, and restrained lift",
),
(
"retro synth",
"retro synth score with analog pulses, warm pads, and steady momentum",
),
(
"action pulse",
"driving action pulse with percussion, rhythmic bass, and urgent forward motion",
),
(
"lo-fi",
"soft lo-fi instrumental bed with mellow rhythm and warm tape texture",
),
(
"no vocals",
"instrumental background music only, no singing, no lyrics, no vocal hooks",
),
("custom", ""),
]
)
def _soundscape_options(): def _soundscape_options():
@@ -400,6 +451,14 @@ def _soundscape_options():
def _soundscape_description(soundscape_name): def _soundscape_description(soundscape_name):
return _SOUNDSCAPE_PRESETS.get(soundscape_name, "") return _SOUNDSCAPE_PRESETS.get(soundscape_name, "")
def _bgm_options():
return list(_BGM_PRESETS.keys())
def _bgm_description(bgm_name):
return _BGM_PRESETS.get(bgm_name, "")
_LOAD_IMAGES_FOLDER_DEFAULT_STATE = { _LOAD_IMAGES_FOLDER_DEFAULT_STATE = {
"version": 1, "version": 1,
"folder": "", "folder": "",
@@ -420,6 +479,11 @@ def _anchor_style_description(style_name):
return _ANCHOR_STYLE_PRESETS.get(str(style_name or "").strip().lower(), "") return _ANCHOR_STYLE_PRESETS.get(str(style_name or "").strip().lower(), "")
def _clean_anchor_style_text(text):
cleaned = _ANCHOR_STYLE_LEGACY_NOTE_RE.sub("", str(text or ""))
return re.sub(r"[ \t]{2,}", " ", cleaned).strip()
def _clean_input_token_value(value): def _clean_input_token_value(value):
cleaned = "" cleaned = ""
if value is not None: if value is not None:
@@ -1137,10 +1201,15 @@ def _reference_context(ref, compact_picture_number):
def _subject_count_guard_text(selected_refs): def _subject_count_guard_text(selected_refs):
character_labels = [] character_labels = []
seen_characters = set()
for picture_number, (_slot, ref) in enumerate(selected_refs or (), 1): for picture_number, (_slot, ref) in enumerate(selected_refs or (), 1):
if ref.get("kind") != "character": if ref.get("kind") != "character":
continue continue
name = _reference_text(ref.get("name")) or _reference_text(ref.get("id")) name = _reference_text(ref.get("name")) or _reference_text(ref.get("id"))
key = (_reference_text(ref.get("id")) or name or f"picture-{picture_number}").lower()
if key in seen_characters:
continue
seen_characters.add(key)
label = f"<Picture {picture_number}>" label = f"<Picture {picture_number}>"
if name: if name:
label = f"{label} {name}" label = f"{label} {name}"
@@ -1171,6 +1240,7 @@ def curate_h3_prompt(
action_prompt, action_prompt,
anchor="", anchor="",
soundscape="", soundscape="",
bgm="",
refs=(), refs=(),
anatomy_guard="auto", anatomy_guard="auto",
subject_count_guard="auto", subject_count_guard="auto",
@@ -1179,12 +1249,21 @@ def curate_h3_prompt(
selected = _selected_prompt_refs(action_prompt, normalized_refs) selected = _selected_prompt_refs(action_prompt, normalized_refs)
picture_map = {slot_number: index for index, (slot_number, _ref) in enumerate(selected, 1)} picture_map = {slot_number: index for index, (slot_number, _ref) in enumerate(selected, 1)}
action = _replace_reference_tags(action_prompt, picture_map) action = _replace_reference_tags(action_prompt, picture_map)
anchor_text = _reference_text(anchor)
soundscape_text = _reference_text(soundscape)
bgm_text = _reference_text(bgm)
reference_description = ""
individual_reference_descriptions = []
if selected:
individual_reference_descriptions = [
_reference_context(ref, picture_number)
for picture_number, (_slot, ref) in enumerate(selected, 1)
]
reference_description = " ".join(individual_reference_descriptions)
prompt_parts = [] prompt_parts = []
_append_prompt_section(prompt_parts, "Scene anchor", anchor) _append_prompt_section(prompt_parts, "Scene anchor", anchor_text)
if selected: _append_prompt_section(prompt_parts, "Reference context", reference_description)
contexts = [_reference_context(ref, picture_number) for picture_number, (_slot, ref) in enumerate(selected, 1)]
_append_prompt_section(prompt_parts, "Reference context", " ".join(contexts))
_append_prompt_section(prompt_parts, "Action", action) _append_prompt_section(prompt_parts, "Action", action)
if anatomy_guard == "on" or (anatomy_guard == "auto" and any(ref.get("kind") == "character" for _slot, ref in selected)): if anatomy_guard == "on" or (anatomy_guard == "auto" and any(ref.get("kind") == "character" for _slot, ref in selected)):
_append_prompt_section(prompt_parts, "Anatomy guard", _ANATOMY_GUARD_TEXT) _append_prompt_section(prompt_parts, "Anatomy guard", _ANATOMY_GUARD_TEXT)
@@ -1192,13 +1271,17 @@ def curate_h3_prompt(
subject_count_guard == "auto" and any(ref.get("kind") == "character" for _slot, ref in selected) subject_count_guard == "auto" and any(ref.get("kind") == "character" for _slot, ref in selected)
): ):
_append_prompt_section(prompt_parts, "Subject count guard", _subject_count_guard_text(selected)) _append_prompt_section(prompt_parts, "Subject count guard", _subject_count_guard_text(selected))
_append_prompt_section(prompt_parts, "overall_soundscape", soundscape) _append_prompt_section(prompt_parts, "overall_soundscape", soundscape_text)
_append_prompt_section(prompt_parts, "background_music", bgm_text)
prompt = "\n\n".join(prompt_parts).strip() prompt = "\n\n".join(prompt_parts).strip()
if len(prompt) > _H3_PROMPT_MAX_CHARS: if len(prompt) > _H3_PROMPT_MAX_CHARS:
prompt = prompt[: _H3_PROMPT_MAX_CHARS - 3].rstrip() + "..." prompt = prompt[: _H3_PROMPT_MAX_CHARS - 3].rstrip() + "..."
images = [_reference_image(ref) for _slot, ref in selected] images = [_reference_image(ref) for _slot, ref in selected]
images.extend([None] * (_H3_PROMPT_REF_SLOTS - len(images))) images.extend([None] * (_H3_PROMPT_REF_SLOTS - len(images)))
individual_reference_descriptions.extend(
[""] * (_H3_PROMPT_REF_SLOTS - len(individual_reference_descriptions))
)
debug = ( debug = (
f"Selected {len(selected)} reference(s): " f"Selected {len(selected)} reference(s): "
+ ", ".join( + ", ".join(
@@ -1208,7 +1291,17 @@ def curate_h3_prompt(
if selected if selected
else "Selected 0 references." else "Selected 0 references."
) )
return (prompt, *images[:_H3_PROMPT_REF_SLOTS], len(selected), debug) return (
prompt,
*images[:_H3_PROMPT_REF_SLOTS],
len(selected),
debug,
anchor_text,
soundscape_text,
bgm_text,
*images[:_H3_PROMPT_REF_SLOTS],
*individual_reference_descriptions[:_H3_PROMPT_REF_SLOTS],
)
def _parse_positive_int(value): def _parse_positive_int(value):
@@ -1960,8 +2053,8 @@ class DumasCharacterHelperNode:
"IMAGE sockets plus simple identity fields, while passing both images " "IMAGE sockets plus simple identity fields, while passing both images "
"through unchanged." "through unchanged."
) )
RETURN_TYPES = ("IMAGE", "IMAGE", "STRING", "STRING") RETURN_TYPES = ("IMAGE", "IMAGE", "STRING", "STRING", _REFERENCE_TYPE, _REFERENCE_TYPE)
RETURN_NAMES = ("image1", "image2", "reference_prompt", "wardrobe") RETURN_NAMES = ("image1", "image2", "reference_prompt", "wardrobe", "reference1", "reference2")
FUNCTION = "build_character_text" FUNCTION = "build_character_text"
CATEGORY = "Dumas/MiniMax" CATEGORY = "Dumas/MiniMax"
@@ -2122,7 +2215,36 @@ class DumasCharacterHelperNode:
name, name,
alias, alias,
) )
return (image1, image2, text, wardrobe_text) facts = {
"gender": _normalize_free_text(gender),
"age": str(_parse_positive_int(age) or ""),
"nationality": _normalize_free_text(nationality),
"occupation": _normalize_free_text(occupation),
"height_feet": str(height_feet or "").strip(),
"height_inches": str(height_inches or "").strip(),
"accent": _normalize_free_text(accent),
}
common = {
"kind": "character",
"explicit_id": character_id,
"name": name,
"aliases": alias,
"description": general,
"wardrobe": wardrobe,
"general": general,
"facts": facts,
}
reference1 = make_reference(
image=image1,
summary="Primary full-body character reference.",
**common,
)
reference2 = make_reference(
image=image2,
summary="Secondary facial character reference.",
**common,
)
return (image1, image2, text, wardrobe_text, reference1, reference2)
class DumasLocationHelperNode: class DumasLocationHelperNode:
@@ -2130,8 +2252,8 @@ class DumasLocationHelperNode:
"Build a general location reference prompt from two IMAGE sockets plus " "Build a general location reference prompt from two IMAGE sockets plus "
"simple environment fields, while passing both images through unchanged." "simple environment fields, while passing both images through unchanged."
) )
RETURN_TYPES = ("IMAGE", "IMAGE", "STRING") RETURN_TYPES = ("IMAGE", "IMAGE", "STRING", _REFERENCE_TYPE, _REFERENCE_TYPE)
RETURN_NAMES = ("image1", "image2", "reference_prompt") RETURN_NAMES = ("image1", "image2", "reference_prompt", "reference1", "reference2")
FUNCTION = "build_location_text" FUNCTION = "build_location_text"
CATEGORY = "Dumas/MiniMax" CATEGORY = "Dumas/MiniMax"
@@ -2219,7 +2341,26 @@ class DumasLocationHelperNode:
description, description,
general, general,
) )
return (image1, image2, text) common = {
"kind": "location",
"explicit_id": location_id,
"name": name,
"aliases": alias,
"description": description,
"general": general,
"facts": {},
}
reference1 = make_reference(
image=image1,
summary="Primary location reference.",
**common,
)
reference2 = make_reference(
image=image2,
summary="Secondary location reference.",
**common,
)
return (image1, image2, text, reference1, reference2)
class DumasCharacterReferenceNode: class DumasCharacterReferenceNode:
@@ -2497,14 +2638,63 @@ class DumasSoundscapeHelperNode:
return (text,) return (text,)
class DumasBackgroundMusicHelperNode:
DESCRIPTION = (
"Choose a background music preset, auto-fill its editable description, "
"and pass the final BGM text downstream for MiniMax H3 prompts."
)
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("bgm",)
FUNCTION = "build_bgm"
CATEGORY = "Dumas/MiniMax"
@classmethod
def INPUT_TYPES(cls):
default_bgm = "none"
return {
"required": {
"bgm": (
_bgm_options(),
{
"default": default_bgm,
"tooltip": "Preset title used to seed the editable background music description.",
},
),
"bgm_description": (
"STRING",
{
"default": _bgm_description(default_bgm),
"multiline": True,
"tooltip": (
"Editable background music description. Whatever text is here "
"is what the node outputs to the bgm socket."
),
},
),
}
}
def build_bgm(self, bgm, bgm_description):
text = str(bgm_description or "").strip()
if not text:
text = _bgm_description(bgm)
return (text,)
class DumasH3PromptCuratorNode: class DumasH3PromptCuratorNode:
DESCRIPTION = ( DESCRIPTION = (
"Curate one MiniMax H3 prompt from an action textbox, anchor text, " "Curate one MiniMax H3 prompt from an action textbox, anchor text, "
"soundscape text, and up to nine structured references. References are " "soundscape/BGM text, and up to nine structured references. References are "
"compacted so only mentioned names, aliases, or explicit <Picture N>/<refN> " "compacted so only mentioned names, aliases, or explicit <Picture N>/<refN> "
"tags are sent onward." "tags are sent onward."
) )
RETURN_TYPES = ("STRING",) + ("IMAGE",) * _H3_PROMPT_REF_SLOTS + ("INT", "STRING") RETURN_TYPES = (
("STRING",)
+ ("IMAGE",) * _H3_PROMPT_REF_SLOTS
+ ("INT", "STRING", "STRING", "STRING", "STRING")
+ ("IMAGE",) * _H3_PROMPT_REF_SLOTS
+ ("STRING",) * _H3_PROMPT_REF_SLOTS
)
RETURN_NAMES = ( RETURN_NAMES = (
"prompt", "prompt",
"ref_image_1", "ref_image_1",
@@ -2518,6 +2708,27 @@ class DumasH3PromptCuratorNode:
"ref_image_9", "ref_image_9",
"reference_count", "reference_count",
"debug", "debug",
"anchor",
"sounds",
"bgm",
"original_ref_1",
"original_ref_2",
"original_ref_3",
"original_ref_4",
"original_ref_5",
"original_ref_6",
"original_ref_7",
"original_ref_8",
"original_ref_9",
"compiled_ref_description_1",
"compiled_ref_description_2",
"compiled_ref_description_3",
"compiled_ref_description_4",
"compiled_ref_description_5",
"compiled_ref_description_6",
"compiled_ref_description_7",
"compiled_ref_description_8",
"compiled_ref_description_9",
) )
FUNCTION = "curate_prompt" FUNCTION = "curate_prompt"
CATEGORY = "Dumas/MiniMax" CATEGORY = "Dumas/MiniMax"
@@ -2539,6 +2750,13 @@ class DumasH3PromptCuratorNode:
"tooltip": "Optional soundscape text, usually from Dumas Soundscape Helper.", "tooltip": "Optional soundscape text, usually from Dumas Soundscape Helper.",
}, },
), ),
"bgm": (
"STRING",
{
"forceInput": True,
"tooltip": "Optional background music text, usually from Dumas Background Music Helper.",
},
),
} }
for slot in range(1, _H3_PROMPT_REF_SLOTS + 1): for slot in range(1, _H3_PROMPT_REF_SLOTS + 1):
optional[f"ref_{slot}"] = ( optional[f"ref_{slot}"] = (
@@ -2594,6 +2812,7 @@ class DumasH3PromptCuratorNode:
subject_count_guard, subject_count_guard,
anchor="", anchor="",
soundscape="", soundscape="",
bgm="",
ref_1=None, ref_1=None,
ref_2=None, ref_2=None,
ref_3=None, ref_3=None,
@@ -2608,6 +2827,7 @@ class DumasH3PromptCuratorNode:
action_prompt, action_prompt,
anchor=anchor, anchor=anchor,
soundscape=soundscape, soundscape=soundscape,
bgm=bgm,
refs=(ref_1, ref_2, ref_3, ref_4, ref_5, ref_6, ref_7, ref_8, ref_9), refs=(ref_1, ref_2, ref_3, ref_4, ref_5, ref_6, ref_7, ref_8, ref_9),
anatomy_guard=anatomy_guard, anatomy_guard=anatomy_guard,
subject_count_guard=subject_count_guard, subject_count_guard=subject_count_guard,
@@ -2651,9 +2871,9 @@ class DumasAnchorStyleNode:
} }
def build_anchor(self, anchor_style, style_description): def build_anchor(self, anchor_style, style_description):
text = str(style_description or "").strip() text = _clean_anchor_style_text(style_description)
if not text: if not text:
text = _anchor_style_description(anchor_style) text = _clean_anchor_style_text(_anchor_style_description(anchor_style))
return (text,) return (text,)
@@ -2666,6 +2886,7 @@ NODE_CLASS_MAPPINGS = {
"DumasCharacterReference": DumasCharacterReferenceNode, "DumasCharacterReference": DumasCharacterReferenceNode,
"DumasLocationReference": DumasLocationReferenceNode, "DumasLocationReference": DumasLocationReferenceNode,
"DumasSoundscapeHelper": DumasSoundscapeHelperNode, "DumasSoundscapeHelper": DumasSoundscapeHelperNode,
"DumasBackgroundMusicHelper": DumasBackgroundMusicHelperNode,
"DumasH3PromptCurator": DumasH3PromptCuratorNode, "DumasH3PromptCurator": DumasH3PromptCuratorNode,
"DumasAnchorStyle": DumasAnchorStyleNode, "DumasAnchorStyle": DumasAnchorStyleNode,
"DumasCharacterHelper": DumasCharacterHelperNode, "DumasCharacterHelper": DumasCharacterHelperNode,
@@ -2682,6 +2903,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"DumasCharacterReference": "Dumas Character Reference", "DumasCharacterReference": "Dumas Character Reference",
"DumasLocationReference": "Dumas Location Reference", "DumasLocationReference": "Dumas Location Reference",
"DumasSoundscapeHelper": "Dumas Soundscape Helper", "DumasSoundscapeHelper": "Dumas Soundscape Helper",
"DumasBackgroundMusicHelper": "Dumas Background Music Helper",
"DumasH3PromptCurator": "Dumas H3 Prompt Curator", "DumasH3PromptCurator": "Dumas H3 Prompt Curator",
"DumasAnchorStyle": "Dumas Anchor Style", "DumasAnchorStyle": "Dumas Anchor Style",
"DumasCharacterHelper": "Dumas Character Helper", "DumasCharacterHelper": "Dumas Character Helper",
+51 -7
View File
@@ -3,7 +3,7 @@ import { app } from "/scripts/app.js";
const NODE_NAME = "DumasAnchorStyle"; const NODE_NAME = "DumasAnchorStyle";
const STYLE_INPUT = "anchor_style"; const STYLE_INPUT = "anchor_style";
const DESCRIPTION_INPUT = "style_description"; const DESCRIPTION_INPUT = "style_description";
const H3_NOTE = " Keep this anchor focused on persistent camera language, lighting, texture, environment treatment, and tone; do not name characters or describe one-off actions."; const H3_NOTE = "";
const PRESETS = { const PRESETS = {
"cinematic action movie": "Big-screen action cinema with assertive visual storytelling: dynamic camera placement, strong forward momentum, crisp geography, muscular lighting contrast, practical atmosphere, and a sense of physical consequence. Favor heroic framing, controlled handheld energy or motivated tracking moves, dramatic silhouettes, tasteful lens flares, impact-driven pacing, and polished studio spectacle without drifting into comic-book unreality unless the shot explicitly asks for it." + H3_NOTE, "cinematic action movie": "Big-screen action cinema with assertive visual storytelling: dynamic camera placement, strong forward momentum, crisp geography, muscular lighting contrast, practical atmosphere, and a sense of physical consequence. Favor heroic framing, controlled handheld energy or motivated tracking moves, dramatic silhouettes, tasteful lens flares, impact-driven pacing, and polished studio spectacle without drifting into comic-book unreality unless the shot explicitly asks for it." + H3_NOTE,
"comedy": "Play the scene for comedic readability and timing: clear staging, expressive performances, slightly heightened reactions, clean eyelines, and visual beats that leave room for the joke to land. Use bright approachable lighting, grounded but playful production design, readable framing, and a tone that feels observant, awkward, or absurd without becoming broad parody unless the action supports it." + H3_NOTE, "comedy": "Play the scene for comedic readability and timing: clear staging, expressive performances, slightly heightened reactions, clean eyelines, and visual beats that leave room for the joke to land. Use bright approachable lighting, grounded but playful production design, readable framing, and a tone that feels observant, awkward, or absurd without becoming broad parody unless the action supports it." + H3_NOTE,
@@ -51,28 +51,72 @@ const PRESETS = {
"fantasy adventure": "Rousing fantasy-adventure language: scenic scale, adventurous clarity, tactile costume-and-prop detail, and camera movement that feels exploratory rather than oppressive. Favor storybook geography, weathered materials, golden or stormy atmosphere, and a tone of peril, wonder, and forward motion." + H3_NOTE, "fantasy adventure": "Rousing fantasy-adventure language: scenic scale, adventurous clarity, tactile costume-and-prop detail, and camera movement that feels exploratory rather than oppressive. Favor storybook geography, weathered materials, golden or stormy atmosphere, and a tone of peril, wonder, and forward motion." + H3_NOTE,
}; };
const SOUNDSCAPE_PRESETS = {
"quiet interior": "quiet indoor room tone, faint ventilation and distant household ambience",
"rainy street": "steady rain, wet pavement, distant traffic hum",
"cafe": "low room tone, faint glassware, cutlery, and muted conversation",
"city night": "distant traffic hum, occasional horn, night air",
"forest": "wind in leaves, distant birds, soft natural ambience",
"industrial": "large interior reverb, distant metal ticks, low machine hum",
"silent": "no dialogue, no vocals, only the natural ambient bed of the scene",
"custom": "",
};
const BGM_PRESETS = {
"none": "",
"subtle tension": "low, restrained tension bed with sparse pulses and no vocals",
"cinematic suspense": "cinematic suspense score with muted strings, low drones, and controlled rising pressure",
"emotional piano": "soft emotional piano underscoring with gentle space and no vocals",
"dark ambient": "dark ambient music bed with deep drones, distant texture, and slow unease",
"hopeful orchestral": "hopeful orchestral underscore with warm strings, gentle brass, and restrained lift",
"retro synth": "retro synth score with analog pulses, warm pads, and steady momentum",
"action pulse": "driving action pulse with percussion, rhythmic bass, and urgent forward motion",
"lo-fi": "soft lo-fi instrumental bed with mellow rhythm and warm tape texture",
"no vocals": "instrumental background music only, no singing, no lyrics, no vocal hooks",
"custom": "",
};
const NODE_CONFIGS = {
[NODE_NAME]: {
presetInput: STYLE_INPUT,
descriptionInput: DESCRIPTION_INPUT,
presets: PRESETS,
},
DumasSoundscapeHelper: {
presetInput: "soundscape",
descriptionInput: "soundscape_description",
presets: SOUNDSCAPE_PRESETS,
},
DumasBackgroundMusicHelper: {
presetInput: "bgm",
descriptionInput: "bgm_description",
presets: BGM_PRESETS,
},
};
function findWidget(node, name) { function findWidget(node, name) {
return (node.widgets || []).find((widget) => widget?.name === name) || null; return (node.widgets || []).find((widget) => widget?.name === name) || null;
} }
app.registerExtension({ app.registerExtension({
name: "Dumas.AnchorStyle", name: "Dumas.PresetTextHelpers",
async beforeRegisterNodeDef(nodeType, nodeData) { async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData?.name !== NODE_NAME) return; const config = NODE_CONFIGS[nodeData?.name];
if (!config) return;
const originalOnNodeCreated = nodeType.prototype.onNodeCreated; const originalOnNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function onNodeCreated() { nodeType.prototype.onNodeCreated = function onNodeCreated() {
const created = originalOnNodeCreated?.apply(this, arguments); const created = originalOnNodeCreated?.apply(this, arguments);
const styleWidget = findWidget(this, STYLE_INPUT); const styleWidget = findWidget(this, config.presetInput);
const descriptionWidget = findWidget(this, DESCRIPTION_INPUT); const descriptionWidget = findWidget(this, config.descriptionInput);
if (!styleWidget || !descriptionWidget) return created; if (!styleWidget || !descriptionWidget) return created;
const originalCallback = styleWidget.callback; const originalCallback = styleWidget.callback;
styleWidget.callback = (...args) => { styleWidget.callback = (...args) => {
const selected = String(styleWidget.value || ""); const selected = String(styleWidget.value || "");
if (Object.hasOwn(PRESETS, selected)) { if (Object.hasOwn(config.presets, selected)) {
descriptionWidget.value = PRESETS[selected]; descriptionWidget.value = config.presets[selected];
descriptionWidget.inputEl?.dispatchEvent(new Event("input", { bubbles: true })); descriptionWidget.inputEl?.dispatchEvent(new Event("input", { bubbles: true }));
} }
this.setDirtyCanvas?.(true, true); this.setDirtyCanvas?.(true, true);
+74 -100
View File
@@ -8,32 +8,15 @@ const DEFAULT_W = 520;
const DEFAULT_H = 340; const DEFAULT_H = 340;
const DEFAULT_BEAT = "Describe this beat."; const DEFAULT_BEAT = "Describe this beat.";
const STATE_PROPERTY = "dumas_h3_beat_prompt_state"; const STATE_PROPERTY = "dumas_h3_beat_prompt_state";
const CONTINUITY_OPTIONS = ["", "soft carry", "hard cut", "keyframe carry", "handoff ref"];
const REF_MODE_OPTIONS = ["", "auto ref2v", "where tagged", "first shot", "every shot", "every shot + handoff ref"];
const MANAGED_DIRECTIVES = { const MANAGED_DIRECTIVES = {
seconds: ["seconds", "duration"], remove: ["remove", "removed", "off"],
continuity: ["continuity"], add: ["add", "wear", "wearing"],
ref_mode: ["ref_mode"],
ref_noise_aug: ["ref_noise_aug"],
anchor_add: ["anchor_add"],
overall_soundscape: ["overall_soundscape", "soundscape"],
non_diegetic_music: ["non_diegetic_music", "music"],
}; };
const DIRECTIVE_EXAMPLES = [ const DIRECTIVE_EXAMPLES = [
["wardrobe set", "wardrobe: Maya = grey shorts, red jacket"], ["remove", "remove: red jacket"],
["wardrobe add", "wardrobe: Maya += red jacket"], ["off", "off: steel collar"],
["wardrobe remove", "wardrobe: Maya -= red jacket"], ["add", "add: white shirt underneath"],
["seconds", "seconds: 8"], ["wearing", "wearing: black coat"],
["exit", "exit: Maya"],
["enter", "enter: Jon"],
["continuity", "continuity: hard cut"],
["ref_mode", "ref_mode: every shot"],
["ref_noise_aug", "ref_noise_aug: 0.92"],
["anchor_add", "anchor_add: harsh sodium-vapor spill, wet pavement, long-lens compression"],
["overall_soundscape", "overall_soundscape: soft rain, distant traffic"],
["non_diegetic_music", "non_diegetic_music: tense analog synth pulse"],
["soundscape", "soundscape: fluorescent room tone, faint HVAC hum"],
["music", "music: low ominous cello and sparse percussion"],
]; ];
function injectCSS() { function injectCSS() {
@@ -183,7 +166,7 @@ function injectCSS() {
} }
function defaultState() { function defaultState() {
return { beats: [{ text: DEFAULT_BEAT }] }; return { scene: "", character_sheet: "", beats: [{ text: DEFAULT_BEAT }] };
} }
function normalizeState(value) { function normalizeState(value) {
@@ -200,7 +183,11 @@ function normalizeState(value) {
const normalized = beats.map((beat) => ({ const normalized = beats.map((beat) => ({
text: typeof beat?.text === "string" ? beat.text : String(beat?.text || ""), text: typeof beat?.text === "string" ? beat.text : String(beat?.text || ""),
})); }));
return normalized.length ? { beats: normalized } : defaultState(); return {
scene: typeof parsed.scene === "string" ? parsed.scene : String(parsed.scene || ""),
character_sheet: typeof parsed.character_sheet === "string" ? parsed.character_sheet : String(parsed.character_sheet || ""),
beats: normalized.length ? normalized : [{ text: DEFAULT_BEAT }],
};
} }
function readState(node) { function readState(node) {
@@ -321,6 +308,51 @@ function renderUI(node) {
node._dh3bpRenderedState = JSON.stringify(state); node._dh3bpRenderedState = JSON.stringify(state);
ui.list.innerHTML = ""; ui.list.innerHTML = "";
const buildTopTextarea = ({ labelText, placeholder, value, onInput }) => {
const card = document.createElement("div");
card.className = "dh3bp-beat";
const label = document.createElement("div");
label.className = "dh3bp-label";
label.textContent = labelText;
const textarea = document.createElement("textarea");
textarea.className = "dh3bp-text";
textarea.placeholder = placeholder;
textarea.value = value || "";
textarea.addEventListener("input", () => {
onInput(textarea.value);
updateTextareaHeight(textarea);
});
textarea.addEventListener("keydown", stopCanvasKeyboard);
card.append(label, textarea);
updateTextareaHeight(textarea);
return card;
};
ui.list.appendChild(buildTopTextarea({
labelText: "Scene paragraph",
placeholder: "Optional. Persistent location, lighting, camera, tone. Leave empty if you wire the Long Videos anchor input.",
value: state.scene,
onInput: (value) => {
const next = readState(node);
next.scene = value;
writeState(node, next);
},
}));
ui.list.appendChild(buildTopTextarea({
labelText: "Character sheet",
placeholder: "Optional. One character per line, e.g. Maya: 27, she, silver hair, red jacket, the woman in <Picture 1>.",
value: state.character_sheet,
onInput: (value) => {
const next = readState(node);
next.character_sheet = value;
writeState(node, next);
},
}));
state.beats.forEach((beat, index) => { state.beats.forEach((beat, index) => {
const card = document.createElement("div"); const card = document.createElement("div");
card.className = "dh3bp-beat"; card.className = "dh3bp-beat";
@@ -379,85 +411,27 @@ function renderUI(node) {
return wrap; return wrap;
}; };
const secondsInput = document.createElement("input"); const removeInput = document.createElement("input");
secondsInput.className = "dh3bp-input"; removeInput.className = "dh3bp-input";
secondsInput.type = "text"; removeInput.type = "text";
secondsInput.placeholder = "8"; removeInput.placeholder = "red jacket";
secondsInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.seconds); removeInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.remove);
secondsInput.addEventListener("input", () => { removeInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "seconds", MANAGED_DIRECTIVES.seconds, secondsInput.value)); applyTextUpdate(setDirectiveValue(textarea.value, "remove", MANAGED_DIRECTIVES.remove, removeInput.value));
}); });
const continuitySelect = document.createElement("select"); const addInput = document.createElement("input");
continuitySelect.className = "dh3bp-select"; addInput.className = "dh3bp-input";
CONTINUITY_OPTIONS.forEach((value) => { addInput.type = "text";
const option = document.createElement("option"); addInput.placeholder = "white shirt underneath";
option.value = value; addInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.add);
option.textContent = value || "Default"; addInput.addEventListener("input", () => {
continuitySelect.appendChild(option); applyTextUpdate(setDirectiveValue(textarea.value, "add", MANAGED_DIRECTIVES.add, addInput.value));
});
continuitySelect.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.continuity);
continuitySelect.addEventListener("change", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "continuity", MANAGED_DIRECTIVES.continuity, continuitySelect.value));
});
const refModeSelect = document.createElement("select");
refModeSelect.className = "dh3bp-select";
REF_MODE_OPTIONS.forEach((value) => {
const option = document.createElement("option");
option.value = value;
option.textContent = value || "Global";
refModeSelect.appendChild(option);
});
refModeSelect.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.ref_mode);
refModeSelect.addEventListener("change", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "ref_mode", MANAGED_DIRECTIVES.ref_mode, refModeSelect.value));
});
const refNoiseInput = document.createElement("input");
refNoiseInput.className = "dh3bp-input";
refNoiseInput.type = "text";
refNoiseInput.placeholder = "0.95";
refNoiseInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.ref_noise_aug);
refNoiseInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "ref_noise_aug", MANAGED_DIRECTIVES.ref_noise_aug, refNoiseInput.value));
});
const anchorInput = document.createElement("input");
anchorInput.className = "dh3bp-input";
anchorInput.type = "text";
anchorInput.placeholder = "extra per-shot style treatment";
anchorInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.anchor_add);
anchorInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "anchor_add", MANAGED_DIRECTIVES.anchor_add, anchorInput.value));
});
const soundscapeInput = document.createElement("input");
soundscapeInput.className = "dh3bp-input";
soundscapeInput.type = "text";
soundscapeInput.placeholder = "faint traffic, loose sign rattle";
soundscapeInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.overall_soundscape);
soundscapeInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "overall_soundscape", MANAGED_DIRECTIVES.overall_soundscape, soundscapeInput.value));
});
const musicInput = document.createElement("input");
musicInput.className = "dh3bp-input";
musicInput.type = "text";
musicInput.placeholder = "low pulsing synth tension";
musicInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.non_diegetic_music);
musicInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "non_diegetic_music", MANAGED_DIRECTIVES.non_diegetic_music, musicInput.value));
}); });
controls.append( controls.append(
buildField({ labelText: "Seconds", input: secondsInput }), buildField({ labelText: "Remove from memory", input: removeInput }),
buildField({ labelText: "Continuity", input: continuitySelect }), buildField({ labelText: "Add to memory", input: addInput }),
buildField({ labelText: "Ref Mode", input: refModeSelect }),
buildField({ labelText: "Ref Noise Aug", input: refNoiseInput }),
buildField({ labelText: "Anchor Add", className: "dh3bp-control-wide", input: anchorInput }),
buildField({ labelText: "Shot Soundscape", className: "dh3bp-control-wide", input: soundscapeInput }),
buildField({ labelText: "Shot Music", className: "dh3bp-control-wide", input: musicInput }),
); );
const directives = document.createElement("div"); const directives = document.createElement("div");
@@ -501,7 +475,7 @@ function setupNode(node) {
title.textContent = "Beat Prompt Builder"; title.textContent = "Beat Prompt Builder";
const subtitle = document.createElement("div"); const subtitle = document.createElement("div");
subtitle.className = "dh3bp-subtitle"; subtitle.className = "dh3bp-subtitle";
subtitle.textContent = "One textbox per H3 beat, plus per-shot controls for timing, ref behavior, continuity, anchor adds, and audio directives."; subtitle.textContent = "Upstream Long Videos format: optional scene, optional character sheet, then one blank-line-separated beat per shot.";
titleWrap.append(title, subtitle); titleWrap.append(title, subtitle);
const addButton = document.createElement("button"); const addButton = document.createElement("button");
+5 -371
View File
@@ -1,375 +1,9 @@
import { app } from "/scripts/app.js"; import { app } from "/scripts/app.js";
import { applyAdaptiveCanvasOnly } from "../shared/nodes2.mjs";
const COMFY_CLASS = "DumasH3LongVideos";
const STATE_PROPERTY = "dumas_h3_longvideos_section_state";
const DOM_WIDGET_NAME = "dumas_h3_longvideos_sections";
const MIN_WIDTH = 520;
const MIN_HEIGHT = 280;
const GROUPS = [
{
id: "prompt",
label: "Prompt",
defaultCollapsed: false,
widgets: ["prompt", "resolution", "megapixels", "beat_split", "anchor_override", "shot_seconds", "plan_only", "fps"],
},
{
id: "refs",
label: "Refs",
defaultCollapsed: true,
widgets: ["ref_mode", "ref_image_size", "ref_noise_aug", "character_memory", "trim_seam", "vary_seed_per_shot", "handoff_offset"],
},
{
id: "sampling",
label: "Sampling",
defaultCollapsed: true,
widgets: [
"steps", "cfg", "sampler_name", "scheduler", "seed",
"apply_model_sampling", "shift_video", "shift_audio",
"vram_headroom_gb", "allow_res_backoff",
"decode_tile_frames", "decode_tile_size",
],
},
{
id: "audio",
label: "Audio",
defaultCollapsed: true,
widgets: [
"global_soundscape", "non_diegetic_music", "auto_soundscape",
"auto_silence_nonspeech", "allow_nonspeech_vocals",
"mute_nonspeech_audio", "mute_fade_ms",
],
},
{
id: "scene",
label: "Scene Logic",
defaultCollapsed: true,
widgets: [
"auto_wardrobe", "auto_props", "prevent_nudity", "exposed_terms",
"anatomy_guard", "subject_count_guard", "lock_restraints",
"contact_guard", "motion_guard", "solidity_guard",
],
},
{
id: "finish",
label: "Upscale",
defaultCollapsed: true,
widgets: [
"upscale", "upscale_model", "upscale_target_short_edge", "upscale_batch",
],
},
{
id: "overlay",
label: "Overlays",
defaultCollapsed: true,
widgets: [
"watermark_text", "watermark_position", "watermark_size", "watermark_opacity", "watermark_margin",
"intro_text", "intro_position", "intro_seconds", "intro_fade", "intro_size",
"overlay_font", "overlay_stroke",
],
},
];
function injectCSS() {
if (document.getElementById("dumas-h3lv-sections-css")) return;
const style = document.createElement("style");
style.id = "dumas-h3lv-sections-css";
style.textContent = `
.dh3lv-sections {
box-sizing: border-box;
width: 100%;
padding: 8px 10px 6px;
color: #e6e7eb;
font: 12px/1.35 "Segoe UI", sans-serif;
pointer-events: auto;
background: linear-gradient(180deg, rgba(33, 36, 42, 0.96), rgba(22, 24, 29, 0.96));
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.dh3lv-sections-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
}
.dh3lv-sections-title {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.08em;
color: #9da5b1;
}
.dh3lv-sections-actions {
display: flex;
gap: 6px;
}
.dh3lv-sections-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.dh3lv-chip,
.dh3lv-action {
appearance: none;
border: 1px solid #464d59;
background: #262c35;
color: #d7dce3;
border-radius: 999px;
padding: 5px 9px;
cursor: pointer;
font: inherit;
line-height: 1.1;
}
.dh3lv-chip[data-open="true"] {
background: #d96f2b;
border-color: #f09358;
color: #fff7f0;
}
.dh3lv-chip:hover,
.dh3lv-action:hover {
filter: brightness(1.06);
}
.dh3lv-count {
opacity: 0.78;
margin-left: 4px;
font-size: 11px;
}
`;
document.head.appendChild(style);
}
function defaultState() {
const state = {};
for (const group of GROUPS) state[group.id] = !group.defaultCollapsed;
return state;
}
function parseState(value) {
let parsed = value;
if (typeof parsed === "string") {
try {
parsed = JSON.parse(parsed);
} catch (_error) {
parsed = null;
}
}
const base = defaultState();
if (!parsed || typeof parsed !== "object") return base;
for (const group of GROUPS) {
if (typeof parsed[group.id] === "boolean") base[group.id] = parsed[group.id];
}
return base;
}
function readState(node) {
return parseState(node.properties?.[STATE_PROPERTY] || node._dh3lvSectionState || "");
}
function writeState(node, state) {
const normalized = parseState(state);
const serialized = JSON.stringify(normalized);
node._dh3lvSectionState = serialized;
node.properties = node.properties || {};
node.properties[STATE_PROPERTY] = serialized;
}
function findWidget(node, name) {
return (node.widgets || []).find((widget) => widget?.name === name) || null;
}
function isInteractiveTarget(target) {
return !!target?.closest?.("button, input, textarea, select, label");
}
function stopCanvasEvent(event) {
if (isInteractiveTarget(event.target)) event.stopPropagation();
}
function stopCanvasKeyboard(event) {
if (isInteractiveTarget(event.target)) event.stopImmediatePropagation();
}
function setWidgetHidden(widget, hidden) {
if (!widget) return;
if (!widget._dh3lvOriginal) {
widget._dh3lvOriginal = {
type: widget.type,
computeSize: widget.computeSize,
hidden: widget.hidden,
};
}
if (hidden) {
widget.type = "hidden";
widget.hidden = true;
widget.computeSize = () => [0, -4];
return;
}
widget.type = widget._dh3lvOriginal.type;
widget.hidden = !!widget._dh3lvOriginal.hidden;
widget.computeSize = widget._dh3lvOriginal.computeSize;
}
function applyVisibility(node) {
const state = readState(node);
for (const group of GROUPS) {
for (const name of group.widgets) {
const widget = findWidget(node, name);
if (!widget || widget.name === DOM_WIDGET_NAME) continue;
setWidgetHidden(widget, !state[group.id]);
}
}
}
function resizeNode(node) {
requestAnimationFrame(() => {
const size = node.computeSize?.();
if (Array.isArray(size)) {
node.size[0] = Math.max(MIN_WIDTH, size[0] || 0, node.size?.[0] || 0);
node.size[1] = Math.max(MIN_HEIGHT, size[1] || 0);
}
node.setDirtyCanvas?.(true, true);
});
}
function renderToolbar(node) {
const ui = node._dh3lvUI;
if (!ui) return;
const state = readState(node);
ui.list.innerHTML = "";
for (const group of GROUPS) {
const button = document.createElement("button");
button.type = "button";
button.className = "dh3lv-chip";
button.dataset.open = state[group.id] ? "true" : "false";
button.textContent = state[group.id] ? `Hide ${group.label}` : `Show ${group.label}`;
const count = document.createElement("span");
count.className = "dh3lv-count";
count.textContent = String(group.widgets.filter((name) => findWidget(node, name)).length);
button.appendChild(count);
button.addEventListener("click", () => {
const next = readState(node);
next[group.id] = !next[group.id];
writeState(node, next);
applyVisibility(node);
renderToolbar(node);
resizeNode(node);
});
ui.list.appendChild(button);
}
}
function setAll(node, open) {
const next = {};
for (const group of GROUPS) next[group.id] = !!open;
writeState(node, next);
applyVisibility(node);
renderToolbar(node);
resizeNode(node);
}
function setupNode(node) {
if (node._dh3lvUI) return;
injectCSS();
writeState(node, readState(node));
const root = document.createElement("div");
root.className = "dh3lv-sections";
const head = document.createElement("div");
head.className = "dh3lv-sections-head";
const title = document.createElement("div");
title.className = "dh3lv-sections-title";
title.textContent = "Sections";
const actions = document.createElement("div");
actions.className = "dh3lv-sections-actions";
const expandAll = document.createElement("button");
expandAll.type = "button";
expandAll.className = "dh3lv-action";
expandAll.textContent = "Expand All";
expandAll.addEventListener("click", () => setAll(node, true));
const collapseAll = document.createElement("button");
collapseAll.type = "button";
collapseAll.className = "dh3lv-action";
collapseAll.textContent = "Collapse Extras";
collapseAll.addEventListener("click", () => {
const next = defaultState();
writeState(node, next);
applyVisibility(node);
renderToolbar(node);
resizeNode(node);
});
actions.append(expandAll, collapseAll);
head.append(title, actions);
const list = document.createElement("div");
list.className = "dh3lv-sections-list";
root.append(head, list);
root.addEventListener("pointerdown", stopCanvasEvent);
root.addEventListener("mousedown", stopCanvasEvent);
root.addEventListener("click", stopCanvasEvent);
root.addEventListener("dblclick", stopCanvasEvent);
root.addEventListener("keydown", stopCanvasKeyboard, true);
node._dh3lvUI = { root, list };
const widget = node.addDOMWidget(DOM_WIDGET_NAME, "custom", root, {
getValue: () => null,
setValue: () => {},
serialize: false,
getMinHeight: () => 52,
hideOnZoom: false,
});
applyAdaptiveCanvasOnly(widget);
const widgets = node.widgets || [];
const index = widgets.indexOf(widget);
if (index > 0) {
widgets.splice(index, 1);
widgets.unshift(widget);
}
applyVisibility(node);
renderToolbar(node);
resizeNode(node);
}
// The Dumas Long Videos node now wraps the upstream MiniMax-H3-Longvideos
// sampler directly. The old local frontend grouped Dumas-specific widgets that
// no longer exist on the upstream node, so this extension intentionally does
// nothing.
app.registerExtension({ app.registerExtension({
name: "Dumas.H3LongVideosSections", name: "Dumas.H3LongVideos.UpstreamWrapper",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData?.name !== COMFY_CLASS) return;
const originalOnNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function onNodeCreated() {
const result = originalOnNodeCreated?.apply(this, arguments);
setupNode(this);
return result;
};
const originalConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onConfigure = function onConfigure() {
const result = originalConfigure?.apply(this, arguments);
setupNode(this);
writeState(this, readState(this));
applyVisibility(this);
renderToolbar(this);
resizeNode(this);
return result;
};
const originalSerialize = nodeType.prototype.onSerialize;
nodeType.prototype.onSerialize = function onSerialize(o) {
writeState(this, readState(this));
const result = originalSerialize?.apply(this, arguments);
if (o && this.properties?.[STATE_PROPERTY]) {
o.properties = o.properties || {};
o.properties[STATE_PROPERTY] = this.properties[STATE_PROPERTY];
}
return result;
};
},
}); });
+85
View File
@@ -0,0 +1,85 @@
import { app } from "/scripts/app.js";
const NODE_NAME = "DumasH3PromptCurator";
const EXPECTED_OUTPUTS = [
"prompt",
"ref_image_1",
"ref_image_2",
"ref_image_3",
"ref_image_4",
"ref_image_5",
"ref_image_6",
"ref_image_7",
"ref_image_8",
"ref_image_9",
"reference_count",
"debug",
"anchor",
"sounds",
"bgm",
"original_ref_1",
"original_ref_2",
"original_ref_3",
"original_ref_4",
"original_ref_5",
"original_ref_6",
"original_ref_7",
"original_ref_8",
"original_ref_9",
"compiled_ref_description_1",
"compiled_ref_description_2",
"compiled_ref_description_3",
"compiled_ref_description_4",
"compiled_ref_description_5",
"compiled_ref_description_6",
"compiled_ref_description_7",
"compiled_ref_description_8",
"compiled_ref_description_9",
];
const EXPECTED_NAMES = new Set(EXPECTED_OUTPUTS);
function pruneStaleOutputs(node) {
if (!Array.isArray(node.outputs)) return;
const byName = new Map();
for (const output of node.outputs) {
if (!output?.name || !EXPECTED_NAMES.has(output.name) || byName.has(output.name)) continue;
byName.set(output.name, output);
}
const nextOutputs = [];
for (const name of EXPECTED_OUTPUTS) {
const existing = byName.get(name);
if (existing) {
nextOutputs.push(existing);
}
}
if (nextOutputs.length && nextOutputs.length !== node.outputs.length) {
node.outputs = nextOutputs;
node.size = node.computeSize?.() || node.size;
node.setDirtyCanvas?.(true, true);
}
}
app.registerExtension({
name: "Dumas.H3PromptCuratorOutputs",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData?.name !== NODE_NAME) return;
const originalOnNodeCreated = nodeType.prototype.onNodeCreated;
const originalOnConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onNodeCreated = function onNodeCreated() {
const created = originalOnNodeCreated?.apply(this, arguments);
pruneStaleOutputs(this);
return created;
};
nodeType.prototype.onConfigure = function onConfigure() {
const configured = originalOnConfigure?.apply(this, arguments);
pruneStaleOutputs(this);
return configured;
};
},
});
+37 -10
View File
@@ -11,35 +11,62 @@ class DumasH3BeatPromptTests(unittest.TestCase):
state = self.module._parse_beat_prompt_state("not json") state = self.module._parse_beat_prompt_state("not json")
self.assertEqual( self.assertEqual(
state, state,
{"beats": [{"text": "Describe this beat."}]}, {
"scene": "",
"character_sheet": "",
"beats": [{"text": "Describe this beat."}],
},
) )
def test_assemble_prompt_joins_beats_with_blank_lines(self): def test_assemble_prompt_outputs_upstream_sections(self):
prompt = self.module._assemble_beat_prompt( prompt = self.module._assemble_beat_prompt(
{ {
"scene": "A rainy kitchen at night.",
"character_sheet": "Maya: 27, she, red jacket, silver hair.",
"beats": [ "beats": [
{"text": "A woman enters the room."}, {"text": "Maya enters the room."},
{"text": "wardrobe: Maya = red jacket\nShe sits at the table."}, {"text": "remove: red jacket\nadd: white shirt underneath\nShe sits at the table."},
{"text": " "}, {"text": " "},
{"text": "music: low synth pulse"},
] ]
} }
) )
self.assertEqual( self.assertEqual(
prompt, prompt,
( (
"A woman enters the room.\n\n" "A rainy kitchen at night.\n\n"
"wardrobe: Maya = red jacket\nShe sits at the table.\n\n" "Maya: 27, she, red jacket, silver hair.\n\n"
"music: low synth pulse" "Maya enters the room.\n\n"
"remove: red jacket\nadd: white shirt underneath\nShe sits at the table."
), ),
) )
def test_assemble_prompt_strips_old_dumas_directives(self):
prompt = self.module._assemble_beat_prompt(
{
"beats": [
{
"text": (
"seconds: 8\n"
"continuity: hard cut\n"
"ref_mode: every shot\n"
"soundscape: soft rain\n"
"music: low synth\n"
"Maya opens the cupboard.\n"
"remove: red jacket"
)
},
]
}
)
self.assertEqual(prompt, "Maya opens the cupboard.\nremove: red jacket")
def test_node_build_prompt_uses_hidden_state(self): def test_node_build_prompt_uses_hidden_state(self):
node = self.module.DumasH3BeatPromptNode() node = self.module.DumasH3BeatPromptNode()
result = node.build_prompt( result = node.build_prompt(
'{"beats":[{"text":"Beat one"},{"text":"Beat two"}]}' '{"scene":"Scene","character_sheet":"Maya: 27, she","beats":[{"text":"Beat one"},{"text":"Beat two"}]}'
) )
self.assertEqual(result, ("Beat one\n\nBeat two",)) self.assertEqual(result, ("Scene\n\nMaya: 27, she\n\nBeat one\n\nBeat two",))
if __name__ == "__main__": if __name__ == "__main__":
File diff suppressed because it is too large Load Diff
+140 -2
View File
@@ -386,6 +386,17 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertIn("Dave is also known as The Locksmith", result[2]) self.assertIn("Dave is also known as The Locksmith", result[2])
self.assertIn("is 41 years old", result[2]) self.assertIn("is 41 years old", result[2])
self.assertEqual(result[3], "Dave = weathered red flight jacket, grey cargo shorts, black boots") self.assertEqual(result[3], "Dave = weathered red flight jacket, grey cargo shorts, black boots")
self.assertIs(result[4]["image"], image1)
self.assertIs(result[5]["image"], image2)
self.assertEqual(result[4]["id"], "char-dave")
self.assertEqual(result[5]["id"], "char-dave")
self.assertEqual(result[4]["name"], "Dave")
self.assertEqual(result[4]["aliases"], ["The Locksmith"])
self.assertEqual(result[4]["facts"]["age"], "41")
self.assertEqual(result[4]["facts"]["height_feet"], "6")
self.assertEqual(result[4]["facts"]["height_inches"], "2")
self.assertEqual(result[4]["wardrobe"], "weathered red flight jacket, grey cargo shorts, black boots")
self.assertEqual(len(result), 6)
def test_location_helper_matches_character_helper_shape_without_wardrobe(self): def test_location_helper_matches_character_helper_shape_without_wardrobe(self):
node = self.image_nodes.DumasLocationHelperNode() node = self.image_nodes.DumasLocationHelperNode()
@@ -410,7 +421,17 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertIn("Coffee Shop is also known as Cafe Interior", result[2]) self.assertIn("Coffee Shop is also known as Cafe Interior", result[2])
self.assertIn("Warm tungsten lighting, narrow counter, rainy front window.", result[2]) self.assertIn("Warm tungsten lighting, narrow counter, rainy front window.", result[2])
self.assertIn("Evening ambience, cramped but cozy.", result[2]) self.assertIn("Evening ambience, cramped but cozy.", result[2])
self.assertEqual(len(result), 3) self.assertIs(result[3]["image"], image1)
self.assertIs(result[4]["image"], image2)
self.assertEqual(result[3]["kind"], "location")
self.assertEqual(result[4]["kind"], "location")
self.assertEqual(result[3]["id"], "coffee-shop-01")
self.assertEqual(result[4]["id"], "coffee-shop-01")
self.assertEqual(result[3]["name"], "Coffee Shop")
self.assertEqual(result[3]["aliases"], ["Cafe Interior"])
self.assertEqual(result[3]["description"], "Warm tungsten lighting, narrow counter, rainy front window")
self.assertEqual(result[3]["general"], "Evening ambience, cramped but cozy")
self.assertEqual(len(result), 5)
def test_soundscape_helper_defaults_to_selected_preset_description(self): def test_soundscape_helper_defaults_to_selected_preset_description(self):
node = self.image_nodes.DumasSoundscapeHelperNode() node = self.image_nodes.DumasSoundscapeHelperNode()
@@ -419,6 +440,13 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertEqual(result[0], "steady rain, wet pavement, distant traffic hum") self.assertEqual(result[0], "steady rain, wet pavement, distant traffic hum")
def test_background_music_helper_defaults_to_selected_preset_description(self):
node = self.image_nodes.DumasBackgroundMusicHelperNode()
result = node.build_bgm("subtle tension", "")
self.assertEqual(result[0], "low, restrained tension bed with sparse pulses and no vocals")
def test_h3_prompt_curator_compacts_named_references(self): def test_h3_prompt_curator_compacts_named_references(self):
node = self.image_nodes.DumasH3PromptCuratorNode() node = self.image_nodes.DumasH3PromptCuratorNode()
dave_image = FakeTensorBatch() dave_image = FakeTensorBatch()
@@ -451,6 +479,7 @@ class DumasImageNodeTests(unittest.TestCase):
subject_count_guard="auto", subject_count_guard="auto",
anchor="grounded handheld thriller", anchor="grounded handheld thriller",
soundscape="steady rain", soundscape="steady rain",
bgm="low suspense music",
ref_1=dave, ref_1=dave,
ref_2=van, ref_2=van,
ref_3=cafe, ref_3=cafe,
@@ -462,12 +491,25 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertIn("Action: Dave runs from the Coffee Shop into the rain.", prompt) self.assertIn("Action: Dave runs from the Coffee Shop into the rain.", prompt)
self.assertIn("Anatomy guard:", prompt) self.assertIn("Anatomy guard:", prompt)
self.assertIn("Subject count guard:", prompt) self.assertIn("Subject count guard:", prompt)
self.assertIn("overall_soundscape: steady rain", prompt)
self.assertIn("background_music: low suspense music", prompt)
self.assertIn("exactly one named character: <Picture 1> Dave", prompt) self.assertIn("exactly one named character: <Picture 1> Dave", prompt)
self.assertIs(result[1], dave_image) self.assertIs(result[1], dave_image)
self.assertIs(result[2], cafe_image) self.assertIs(result[2], cafe_image)
self.assertIsNone(result[3]) self.assertIsNone(result[3])
self.assertEqual(result[10], 2) self.assertEqual(result[10], 2)
self.assertIn("input 3-><Picture 2> Coffee Shop", result[11]) self.assertIn("input 3-><Picture 2> Coffee Shop", result[11])
self.assertEqual(result[12], "grounded handheld thriller")
self.assertEqual(result[13], "steady rain")
self.assertEqual(result[14], "low suspense music")
self.assertIs(result[15], dave_image)
self.assertIs(result[16], cafe_image)
self.assertIsNone(result[17])
self.assertIn("<Picture 1> Dave", result[24])
self.assertNotIn("<Picture 2> Coffee Shop", result[24])
self.assertIn("<Picture 2> Coffee Shop", result[25])
self.assertIn("Location context for <Picture 2> Coffee Shop", result[25])
self.assertEqual(result[26], "")
def test_h3_prompt_curator_renumbers_explicit_reference_tags(self): def test_h3_prompt_curator_renumbers_explicit_reference_tags(self):
node = self.image_nodes.DumasH3PromptCuratorNode() node = self.image_nodes.DumasH3PromptCuratorNode()
@@ -508,6 +550,81 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertIn("Only include the people explicitly described", result[0]) self.assertIn("Only include the people explicitly described", result[0])
self.assertEqual(result[10], 0) self.assertEqual(result[10], 0)
def test_h3_prompt_curator_treats_helper_image_pair_as_one_character(self):
helper = self.image_nodes.DumasCharacterHelperNode()
curator = self.image_nodes.DumasH3PromptCuratorNode()
image1 = FakeTensorBatch()
image2 = FakeTensorBatch()
helper_result = helper.build_character_text(
image1=image1,
image2=image2,
image1_picture_id="1",
image2_picture_id="2",
character_id="char_dave",
name="Dave",
alias="The Locksmith",
gender="male",
age="41",
nationality="English",
occupation="detective",
height_feet="6",
height_inches="2",
accent="English",
general="Tired eyes, cropped brown hair",
wardrobe="weathered red flight jacket",
)
result = curator.curate_prompt(
action_prompt="Dave checks the locked door.",
anatomy_guard="on",
subject_count_guard="auto",
ref_1=helper_result[4],
ref_2=helper_result[5],
)
self.assertIs(result[1], image1)
self.assertIs(result[2], image2)
self.assertEqual(result[10], 2)
self.assertIn("Character facts for <Picture 1> Dave", result[0])
self.assertIn("41 years old", result[0])
self.assertIn("6 foot 2 tall", result[0])
self.assertIn("exactly one named character: <Picture 1> Dave", result[0])
self.assertNotIn("exactly 2 named characters", result[0])
def test_h3_prompt_curator_uses_location_helper_references_by_name(self):
helper = self.image_nodes.DumasLocationHelperNode()
curator = self.image_nodes.DumasH3PromptCuratorNode()
image1 = FakeTensorBatch()
image2 = FakeTensorBatch()
helper_result = helper.build_location_text(
image1=image1,
image2=image2,
image1_picture_id="1",
image2_picture_id="2",
location_id="coffee_shop",
name="Coffee Shop",
alias="Cafe Interior",
description="Warm tungsten lighting, narrow counter, rainy front window",
general="Evening ambience, cramped but cozy",
)
result = curator.curate_prompt(
action_prompt="A slow push through the Coffee Shop as rain streaks the windows.",
anatomy_guard="on",
subject_count_guard="auto",
ref_1=helper_result[3],
ref_2=helper_result[4],
)
self.assertIs(result[1], image1)
self.assertIs(result[2], image2)
self.assertEqual(result[10], 2)
self.assertIn("<Picture 1> Coffee Shop", result[0])
self.assertIn("<Picture 2> Coffee Shop", result[0])
self.assertIn("Location context for <Picture 1> Coffee Shop", result[0])
self.assertIn("Warm tungsten lighting", result[0])
self.assertNotIn("Subject count guard:", result[0])
def test_h3_prompt_curator_defaults_anatomy_guard_to_on(self): def test_h3_prompt_curator_defaults_anatomy_guard_to_on(self):
required = self.image_nodes.DumasH3PromptCuratorNode.INPUT_TYPES()["required"] required = self.image_nodes.DumasH3PromptCuratorNode.INPUT_TYPES()["required"]
@@ -520,16 +637,24 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertIs(mappings["DumasCharacterHelper"], self.image_nodes.DumasCharacterHelperNode) self.assertIs(mappings["DumasCharacterHelper"], self.image_nodes.DumasCharacterHelperNode)
self.assertIs(mappings["DumasLocationHelper"], self.image_nodes.DumasLocationHelperNode) self.assertIs(mappings["DumasLocationHelper"], self.image_nodes.DumasLocationHelperNode)
self.assertIs(mappings["DumasSoundscapeHelper"], self.image_nodes.DumasSoundscapeHelperNode) self.assertIs(mappings["DumasSoundscapeHelper"], self.image_nodes.DumasSoundscapeHelperNode)
self.assertIs(mappings["DumasBackgroundMusicHelper"], self.image_nodes.DumasBackgroundMusicHelperNode)
self.assertIs(mappings["DumasH3PromptCurator"], self.image_nodes.DumasH3PromptCuratorNode) self.assertIs(mappings["DumasH3PromptCurator"], self.image_nodes.DumasH3PromptCuratorNode)
self.assertEqual(display["DumasCharacterHelper"], "Dumas Character Helper") self.assertEqual(display["DumasCharacterHelper"], "Dumas Character Helper")
self.assertEqual(display["DumasLocationHelper"], "Dumas Location Helper") self.assertEqual(display["DumasLocationHelper"], "Dumas Location Helper")
self.assertEqual(display["DumasSoundscapeHelper"], "Dumas Soundscape Helper") self.assertEqual(display["DumasSoundscapeHelper"], "Dumas Soundscape Helper")
self.assertEqual(display["DumasBackgroundMusicHelper"], "Dumas Background Music Helper")
self.assertEqual(display["DumasH3PromptCurator"], "Dumas H3 Prompt Curator") self.assertEqual(display["DumasH3PromptCurator"], "Dumas H3 Prompt Curator")
def test_h3_prompt_curator_uses_documented_reference_limits(self): def test_h3_prompt_curator_uses_documented_reference_limits(self):
node = self.image_nodes.DumasH3PromptCuratorNode() node = self.image_nodes.DumasH3PromptCuratorNode()
self.assertEqual(len(node.RETURN_TYPES), 12) self.assertEqual(len(node.RETURN_TYPES), 33)
self.assertEqual(node.RETURN_NAMES[1:10], tuple(f"ref_image_{i}" for i in range(1, 10))) self.assertEqual(node.RETURN_NAMES[1:10], tuple(f"ref_image_{i}" for i in range(1, 10)))
self.assertEqual(node.RETURN_NAMES[12:15], ("anchor", "sounds", "bgm"))
self.assertEqual(node.RETURN_NAMES[15:24], tuple(f"original_ref_{i}" for i in range(1, 10)))
self.assertEqual(
node.RETURN_NAMES[24:33],
tuple(f"compiled_ref_description_{i}" for i in range(1, 10)),
)
def test_normalize_reference_upgrades_generic_summary_with_socket_picture_id(self): def test_normalize_reference_upgrades_generic_summary_with_socket_picture_id(self):
image = FakeTensorBatch() image = FakeTensorBatch()
@@ -592,6 +717,19 @@ class DumasImageNodeTests(unittest.TestCase):
self.assertIn("real time", result[0]) self.assertIn("real time", result[0])
self.assertNotIn("persistent camera language", result[0]) self.assertNotIn("persistent camera language", result[0])
def test_anchor_style_node_strips_legacy_persistent_anchor_note(self):
node = self.image_nodes.DumasAnchorStyleNode()
legacy = (
"Gritty handheld realism. Keep this anchor focused on persistent camera "
"language, lighting, texture, environment treatment, and tone; do not "
"name characters or describe one-off actions."
)
result = node.build_anchor("cinematic action movie", legacy)
self.assertEqual(result[0], "Gritty handheld realism.")
self.assertNotIn("persistent camera language", result[0])
def test_anchor_style_node_prefers_manual_description_edits(self): def test_anchor_style_node_prefers_manual_description_edits(self):
node = self.image_nodes.DumasAnchorStyleNode() node = self.image_nodes.DumasAnchorStyleNode()
custom = "Lo-fi pirate broadcast with smeared highlights and anxious zoom corrections." custom = "Lo-fi pirate broadcast with smeared highlights and anxious zoom corrections."