replace prompt builder image inputs with ordered refmod sockets

This commit is contained in:
2026-10-20 15:53:13 +00:00
parent 5d41800ffb
commit 6f8fd85405
4 changed files with 52 additions and 139 deletions
+19 -21
View File
@@ -208,15 +208,11 @@ class DumasH3SequencePromptBuilder:
},
"optional": {
**{
f"reference_image_{index}": ("IMAGE", {
"display_name": f"Reference Image {index} (@R{index})",
"tooltip": f"Fixed Reference Image {index}; use @R{index} in a clip prompt.",
f"ref_mod_{index}": ("H3_REF_MODS", {
"display_name": f"RefMod {index} (@R{index})",
"tooltip": f"RefMod socket {index}; use @R{index} in a clip prompt.",
}) for index in range(1, 10)
},
"ref_mods": ("H3_REF_MODS", {
"display_name": "RefMods (assign @R slots after images)",
"tooltip": "Visual RefMods are described in the prompt and emitted for the Continuum bridge.",
}),
},
}
@@ -240,15 +236,15 @@ class DumasH3SequencePromptBuilder:
directive = routing_directive
sound = str(soundscape or "").strip() or "N/A"
music_text = str(music or "").strip() or "N/A"
connected_image_slots = [
index for index in range(1, 10)
if kwargs.get(f"reference_image_{index}") is not None
]
refmods = _visual_refmods(kwargs.get("ref_mods"))
refmod_offset = max(connected_image_slots, default=0)
if refmod_offset + len(refmods) > 9:
raise ValueError("The prompt builder supports at most nine combined image and RefMod slots.")
generated = _refmod_directive(refmods, refmod_offset + 1)
# Each socket is one deterministic @R slot. This avoids trying to
# inspect the contents of a chained bundle in the browser and makes
# the socket order match the prompt chips exactly.
refmods = []
for index in range(1, 10):
refmods.extend(_visual_refmods(kwargs.get(f"ref_mod_{index}")))
if len(refmods) > 9:
raise ValueError("The prompt builder supports at most nine RefMod slots.")
generated = _refmod_directive(refmods, 1)
if generated:
directive = "\n\n".join(part for part in (directive, generated) if part)
for reference_index in range(1, 10):
@@ -262,8 +258,7 @@ class DumasH3SequencePromptBuilder:
f"overall_soundscape: {sound}",
f"non_diegetic_music: {music_text}",
])
available = kwargs.get(f"reference_image_{reference_index}") is not None
available = available or refmod_offset < reference_index <= refmod_offset + len(refmods)
available = reference_index <= len(refmods)
if available and re.search(
rf"@(R{reference_index}|image{reference_index})(?![A-Za-z0-9_])",
text,
@@ -271,7 +266,10 @@ class DumasH3SequencePromptBuilder:
):
chunks.append(chunk_index)
selectors.append(",".join(map(str, chunks)) or "off")
images = tuple(kwargs.get(f"reference_image_{index}") for index in range(1, 10))
# Keep the typed reference-images output for compatibility with the
# Continuum bridge, but it is intentionally empty: this builder now
# owns RefMod sockets rather than image sockets.
images = (None,) * 9
reference_bundle = _continuum_reference_bundle_type()(
images=images,
reference_use="Per chunk",
@@ -287,8 +285,8 @@ class DumasH3SequencePromptBuilder:
len(sequence["clips"]),
float(default_chunk_seconds),
reference_bundle,
kwargs.get("ref_mods") or [],
refmod_offset,
refmods,
0,
)