replace prompt builder image inputs with ordered refmod sockets
This commit is contained in:
@@ -93,11 +93,14 @@ the chunk count, the shared chunk duration, and a per-chunk reference bundle.
|
|||||||
Reference images are inserted as `@R1` through `@R9`; routing is based on the
|
Reference images are inserted as `@R1` through `@R9`; routing is based on the
|
||||||
shared directive, soundscape, music, and each chunk's full prompt text.
|
shared directive, soundscape, music, and each chunk's full prompt text.
|
||||||
|
|
||||||
The builder also accepts an optional `H3_REF_MODS` input. Visual RefMods are
|
The builder exposes nine optional `H3_REF_MODS` sockets, labelled `RefMod 1`
|
||||||
assigned after any connected image-reference slots, automatically described in
|
through `RefMod 9`. Each connected socket occupies the matching `@R` slot in
|
||||||
the generated shared directive, and emitted together with their slot offset.
|
socket order, so the chips and generated prompt definitions are deterministic;
|
||||||
Connect those two outputs to `DUMAS H3 RefMods to Continuum` so the bridge can
|
there is no image-socket offset or chained-bundle ambiguity. Visual RefMods are
|
||||||
merge RefMods and ordinary image references into one Continuum bundle.
|
automatically described in the generated shared directive and emitted through
|
||||||
|
the `ref_mods` output for downstream RefMod handling. The typed
|
||||||
|
`reference_images` output remains as an empty compatibility bundle for older
|
||||||
|
workflows; this builder no longer accepts image sockets.
|
||||||
|
|
||||||
The prompt builder intentionally uses the `ReferenceImagesV39Bundle` class
|
The prompt builder intentionally uses the `ReferenceImagesV39Bundle` class
|
||||||
from the installed upstream H3 Continuum pack. Install that pack alongside
|
from the installed upstream H3 Continuum pack. Install that pack alongside
|
||||||
|
|||||||
+19
-21
@@ -208,15 +208,11 @@ class DumasH3SequencePromptBuilder:
|
|||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
**{
|
**{
|
||||||
f"reference_image_{index}": ("IMAGE", {
|
f"ref_mod_{index}": ("H3_REF_MODS", {
|
||||||
"display_name": f"Reference Image {index} (@R{index})",
|
"display_name": f"RefMod {index} (@R{index})",
|
||||||
"tooltip": f"Fixed Reference Image {index}; use @R{index} in a clip prompt.",
|
"tooltip": f"RefMod socket {index}; use @R{index} in a clip prompt.",
|
||||||
}) for index in range(1, 10)
|
}) 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
|
directive = routing_directive
|
||||||
sound = str(soundscape or "").strip() or "N/A"
|
sound = str(soundscape or "").strip() or "N/A"
|
||||||
music_text = str(music or "").strip() or "N/A"
|
music_text = str(music or "").strip() or "N/A"
|
||||||
connected_image_slots = [
|
# Each socket is one deterministic @R slot. This avoids trying to
|
||||||
index for index in range(1, 10)
|
# inspect the contents of a chained bundle in the browser and makes
|
||||||
if kwargs.get(f"reference_image_{index}") is not None
|
# the socket order match the prompt chips exactly.
|
||||||
]
|
refmods = []
|
||||||
refmods = _visual_refmods(kwargs.get("ref_mods"))
|
for index in range(1, 10):
|
||||||
refmod_offset = max(connected_image_slots, default=0)
|
refmods.extend(_visual_refmods(kwargs.get(f"ref_mod_{index}")))
|
||||||
if refmod_offset + len(refmods) > 9:
|
if len(refmods) > 9:
|
||||||
raise ValueError("The prompt builder supports at most nine combined image and RefMod slots.")
|
raise ValueError("The prompt builder supports at most nine RefMod slots.")
|
||||||
generated = _refmod_directive(refmods, refmod_offset + 1)
|
generated = _refmod_directive(refmods, 1)
|
||||||
if generated:
|
if generated:
|
||||||
directive = "\n\n".join(part for part in (directive, generated) if part)
|
directive = "\n\n".join(part for part in (directive, generated) if part)
|
||||||
for reference_index in range(1, 10):
|
for reference_index in range(1, 10):
|
||||||
@@ -262,8 +258,7 @@ class DumasH3SequencePromptBuilder:
|
|||||||
f"overall_soundscape: {sound}",
|
f"overall_soundscape: {sound}",
|
||||||
f"non_diegetic_music: {music_text}",
|
f"non_diegetic_music: {music_text}",
|
||||||
])
|
])
|
||||||
available = kwargs.get(f"reference_image_{reference_index}") is not None
|
available = reference_index <= len(refmods)
|
||||||
available = available or refmod_offset < reference_index <= refmod_offset + len(refmods)
|
|
||||||
if available and re.search(
|
if available and re.search(
|
||||||
rf"@(R{reference_index}|image{reference_index})(?![A-Za-z0-9_])",
|
rf"@(R{reference_index}|image{reference_index})(?![A-Za-z0-9_])",
|
||||||
text,
|
text,
|
||||||
@@ -271,7 +266,10 @@ class DumasH3SequencePromptBuilder:
|
|||||||
):
|
):
|
||||||
chunks.append(chunk_index)
|
chunks.append(chunk_index)
|
||||||
selectors.append(",".join(map(str, chunks)) or "off")
|
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()(
|
reference_bundle = _continuum_reference_bundle_type()(
|
||||||
images=images,
|
images=images,
|
||||||
reference_use="Per chunk",
|
reference_use="Per chunk",
|
||||||
@@ -287,8 +285,8 @@ class DumasH3SequencePromptBuilder:
|
|||||||
len(sequence["clips"]),
|
len(sequence["clips"]),
|
||||||
float(default_chunk_seconds),
|
float(default_chunk_seconds),
|
||||||
reference_bundle,
|
reference_bundle,
|
||||||
kwargs.get("ref_mods") or [],
|
refmods,
|
||||||
refmod_offset,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+15
-110
@@ -45,7 +45,7 @@ function widgetValue(node, name) {
|
|||||||
return get(node, name)?.value;
|
return get(node, name)?.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function refModDescriptorsForNode(node) {
|
function refModDescriptorsForNode(node, inputName = "ref_mods") {
|
||||||
const result = [];
|
const result = [];
|
||||||
const add = (name, copies = 1) => {
|
const add = (name, copies = 1) => {
|
||||||
const count = Math.max(1, Math.min(32, Number(copies) || 1));
|
const count = Math.max(1, Math.min(32, Number(copies) || 1));
|
||||||
@@ -55,8 +55,10 @@ function refModDescriptorsForNode(node) {
|
|||||||
};
|
};
|
||||||
const visited = new Set();
|
const visited = new Set();
|
||||||
const visit = (source) => {
|
const visit = (source) => {
|
||||||
if (!source || visited.has(source.id)) return;
|
if (!source) return;
|
||||||
visited.add(source.id);
|
const identity = source.id ?? source;
|
||||||
|
if (visited.has(identity)) return;
|
||||||
|
visited.add(identity);
|
||||||
const className = String(source.comfyClass || source.type || "");
|
const className = String(source.comfyClass || source.type || "");
|
||||||
// H3RefModLoader appends its selected item after the incoming bundle,
|
// H3RefModLoader appends its selected item after the incoming bundle,
|
||||||
// so recurse first to preserve the backend's @R ordering.
|
// so recurse first to preserve the backend's @R ordering.
|
||||||
@@ -83,7 +85,7 @@ function refModDescriptorsForNode(node) {
|
|||||||
// A custom bundle node's contents are only known after execution.
|
// A custom bundle node's contents are only known after execution.
|
||||||
add("Attached RefMod");
|
add("Attached RefMod");
|
||||||
};
|
};
|
||||||
visit(linkedNode(node, "ref_mods"));
|
visit(linkedNode(node, inputName));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,67 +443,12 @@ function configure(node) {
|
|||||||
shotChips.append(chip);
|
shotChips.append(chip);
|
||||||
});
|
});
|
||||||
panel.append(shotChips);
|
panel.append(shotChips);
|
||||||
const referenceLabel = el("div", "REFERENCE SLOTS"); referenceLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:7px 0 3px"; panel.append(referenceLabel);
|
const referenceLabel = el("div", "REFMOD SLOTS"); referenceLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:7px 0 3px"; panel.append(referenceLabel);
|
||||||
const referenceRow = el("div"); referenceRow.style.cssText = "display:flex;gap:7px;overflow:hidden;margin:3px 0 8px;padding:5px;background:#202020;border:1px solid #3f4742;border-radius:5px;align-items:center;flex-wrap:wrap;min-height:38px;box-sizing:border-box";
|
const referenceRow = el("div"); referenceRow.style.cssText = "display:flex;gap:7px;overflow:hidden;margin:3px 0 8px;padding:5px;background:#202020;border:1px solid #3f4742;border-radius:5px;align-items:center;flex-wrap:wrap;min-height:38px;box-sizing:border-box";
|
||||||
const refModDescriptors = refModDescriptorsForNode(node);
|
const connectedRefModSlots = Array.from({ length: 9 }, (_, offset) => offset + 1)
|
||||||
const connectedReferences = Array.from({ length: 9 }, (_, offset) => offset + 1)
|
.filter((index) => node.inputs?.some((input) => input.name === `ref_mod_${index}` && input.link != null));
|
||||||
.filter((index) => node.inputs?.some((input) => input.name === `reference_image_${index}` && input.link != null));
|
const refModDescriptors = connectedRefModSlots.flatMap((index) => refModDescriptorsForNode(node, `ref_mod_${index}`));
|
||||||
if (connectedReferences.length) {
|
const refModsConnected = connectedRefModSlots.length > 0;
|
||||||
connectedReferences.forEach((index) => {
|
|
||||||
const button = el("button"); button.type = "button";
|
|
||||||
button.title = `Insert reference image ${index} as @image${index}`;
|
|
||||||
button.style.cssText = "display:inline-flex;align-items:center;gap:7px;height:31px;padding:2px 11px 2px 3px;border:2px solid #49c9f5;border-radius:18px;background:#202b31;color:#70d8ff;font:16px monospace;cursor:pointer;white-space:nowrap";
|
|
||||||
const thumbnail = document.createElement("img");
|
|
||||||
thumbnail.alt = ""; thumbnail.draggable = false;
|
|
||||||
thumbnail.style.cssText = "width:25px;height:25px;object-fit:cover;border-radius:50%;background:#68727a;display:block";
|
|
||||||
const linkId = node.inputs?.find((input) => input.name === `reference_image_${index}`)?.link;
|
|
||||||
const link = linkId == null ? null : (app.graph?.links?.get?.(linkId) ?? app.graph?.links?.[linkId]);
|
|
||||||
const source = link?.origin_id == null ? null : app.graph?.getNodeById?.(link.origin_id);
|
|
||||||
const imageWidget = source?.widgets?.find((widget) => ["image", "filename", "file"].includes(widget.name));
|
|
||||||
const imageValue = imageWidget?.value;
|
|
||||||
if (imageValue && typeof imageValue === "object" && imageValue.filename) {
|
|
||||||
const params = new URLSearchParams({ filename: imageValue.filename, type: imageValue.type || "input", subfolder: imageValue.subfolder || "" });
|
|
||||||
thumbnail.src = `/view?${params.toString()}`;
|
|
||||||
} else if (typeof imageValue === "string" && imageValue) {
|
|
||||||
const params = new URLSearchParams({ filename: imageValue, type: "input", subfolder: "" });
|
|
||||||
thumbnail.src = `/view?${params.toString()}`;
|
|
||||||
} else {
|
|
||||||
thumbnail.src = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='25' height='25' viewBox='0 0 25 25'%3E%3Crect width='25' height='25' fill='%2368727a'/%3E%3Cpath d='M4 19l5-6 3 3 3-4 6 7' fill='none' stroke='%23dce8ed' stroke-width='2'/%3E%3Ccircle cx='17' cy='8' r='2' fill='%23dce8ed'/%3E%3C/svg%3E";
|
|
||||||
}
|
|
||||||
thumbnail.onerror = () => { thumbnail.style.opacity = "0.35"; };
|
|
||||||
button.append(thumbnail, el("span", `@image${index}`));
|
|
||||||
const rememberPromptSelection = () => {
|
|
||||||
if (!prompt) return;
|
|
||||||
promptSelectionStart = prompt.selectionStart ?? prompt.value.length;
|
|
||||||
promptSelectionEnd = prompt.selectionEnd ?? promptSelectionStart;
|
|
||||||
};
|
|
||||||
button.onpointerdown = (event) => {
|
|
||||||
rememberPromptSelection();
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
};
|
|
||||||
button.onmousedown = (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
};
|
|
||||||
button.onclick = (event) => {
|
|
||||||
event.preventDefault(); event.stopPropagation();
|
|
||||||
if (!prompt) return;
|
|
||||||
const start = Math.min(promptSelectionStart, prompt.value.length);
|
|
||||||
const end = Math.min(Math.max(start, promptSelectionEnd), prompt.value.length);
|
|
||||||
const token = `@R${index} `;
|
|
||||||
prompt.value = prompt.value.slice(0, start) + token + prompt.value.slice(end);
|
|
||||||
const caret = start + token.length;
|
|
||||||
focusPrompt(); prompt.setSelectionRange(caret, caret);
|
|
||||||
promptSelectionStart = caret; promptSelectionEnd = caret;
|
|
||||||
promptText = prompt.value; clip.prompt = prompt.value;
|
|
||||||
syncPrompt(clip, clip.prompt); persistState();
|
|
||||||
};
|
|
||||||
referenceRow.append(button);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const refModsConnected = node.inputs?.some((input) => input.name === "ref_mods" && input.link != null);
|
|
||||||
const firstRefModSlot = Math.max(0, ...connectedReferences);
|
|
||||||
const insertReferenceToken = (slot) => {
|
const insertReferenceToken = (slot) => {
|
||||||
if (!prompt) return;
|
if (!prompt) return;
|
||||||
const start = Math.min(promptSelectionStart, prompt.value.length);
|
const start = Math.min(promptSelectionStart, prompt.value.length);
|
||||||
@@ -515,7 +462,7 @@ function configure(node) {
|
|||||||
syncPrompt(clip, clip.prompt); persistState();
|
syncPrompt(clip, clip.prompt); persistState();
|
||||||
};
|
};
|
||||||
refModDescriptors.forEach((descriptor, offset) => {
|
refModDescriptors.forEach((descriptor, offset) => {
|
||||||
const slot = firstRefModSlot + offset + 1;
|
const slot = offset + 1;
|
||||||
const button = el("button"); button.type = "button";
|
const button = el("button"); button.type = "button";
|
||||||
button.title = `Insert ${descriptor.name} as @R${slot}`;
|
button.title = `Insert ${descriptor.name} as @R${slot}`;
|
||||||
button.style.cssText = "display:inline-flex;align-items:center;gap:7px;height:31px;padding:2px 11px 2px 3px;border:2px solid #b78cff;border-radius:18px;background:#2a2138;color:#d9c2ff;font:14px monospace;cursor:pointer;white-space:nowrap;max-width:260px;overflow:hidden;text-overflow:ellipsis";
|
button.style.cssText = "display:inline-flex;align-items:center;gap:7px;height:31px;padding:2px 11px 2px 3px;border:2px solid #b78cff;border-radius:18px;background:#2a2138;color:#d9c2ff;font:14px monospace;cursor:pointer;white-space:nowrap;max-width:260px;overflow:hidden;text-overflow:ellipsis";
|
||||||
@@ -531,14 +478,8 @@ function configure(node) {
|
|||||||
button.onclick = (event) => { event.preventDefault(); event.stopPropagation(); insertReferenceToken(slot); };
|
button.onclick = (event) => { event.preventDefault(); event.stopPropagation(); insertReferenceToken(slot); };
|
||||||
referenceRow.append(button);
|
referenceRow.append(button);
|
||||||
});
|
});
|
||||||
if (refModsConnected && !refModDescriptors.length) {
|
if (!refModsConnected) {
|
||||||
const status = el("div"); status.title = "RefMods are connected to the prompt builder and are assigned after image reference slots.";
|
const empty = el("span", "Connect RefMod sockets to populate this row."); empty.style.cssText = "color:#77817a;font:11px Arial;padding:3px 2px"; referenceRow.append(empty);
|
||||||
status.style.cssText = "display:inline-flex;align-items:center;gap:7px;height:31px;padding:2px 11px 2px 5px;border:2px solid #b78cff;border-radius:18px;background:#2a2138;color:#d9c2ff;font:13px monospace;white-space:nowrap";
|
|
||||||
const icon = el("span", "R"); icon.style.cssText = "display:grid;place-items:center;width:25px;height:25px;border-radius:50%;background:#7952a8;color:#fff;font-weight:bold;font-size:12px";
|
|
||||||
status.append(icon, el("span", `RefMods → @R${firstRefModSlot + 1}`)); referenceRow.append(status);
|
|
||||||
}
|
|
||||||
if (!connectedReferences.length && !refModsConnected) {
|
|
||||||
const empty = el("span", "Connect image references or RefMods to populate this row."); empty.style.cssText = "color:#77817a;font:11px Arial;padding:3px 2px"; referenceRow.append(empty);
|
|
||||||
}
|
}
|
||||||
panel.append(referenceRow);
|
panel.append(referenceRow);
|
||||||
const promptLabel = el("div", "PROMPT SCRIPT"); promptLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:4px 0 3px"; panel.append(promptLabel);
|
const promptLabel = el("div", "PROMPT SCRIPT"); promptLabel.style.cssText = "color:#8fa898;font-size:10px;letter-spacing:.08em;margin:4px 0 3px"; panel.append(promptLabel);
|
||||||
@@ -552,33 +493,12 @@ function configure(node) {
|
|||||||
autocomplete = null;
|
autocomplete = null;
|
||||||
autocompleteRange = null;
|
autocompleteRange = null;
|
||||||
};
|
};
|
||||||
const sourceThumbnail = (index) => {
|
|
||||||
const thumbnail = document.createElement("img");
|
|
||||||
thumbnail.alt = ""; thumbnail.draggable = false;
|
|
||||||
thumbnail.style.cssText = "width:24px;height:24px;object-fit:cover;border-radius:50%;background:#68727a;display:block;flex:none";
|
|
||||||
const linkId = node.inputs?.find((input) => input.name === `reference_image_${index}`)?.link;
|
|
||||||
const link = linkId == null ? null : (app.graph?.links?.get?.(linkId) ?? app.graph?.links?.[linkId]);
|
|
||||||
const source = link?.origin_id == null ? null : app.graph?.getNodeById?.(link.origin_id);
|
|
||||||
const imageWidget = source?.widgets?.find((widget) => ["image", "filename", "file"].includes(widget.name));
|
|
||||||
const imageValue = imageWidget?.value;
|
|
||||||
if (imageValue && typeof imageValue === "object" && imageValue.filename) {
|
|
||||||
const params = new URLSearchParams({ filename: imageValue.filename, type: imageValue.type || "input", subfolder: imageValue.subfolder || "" });
|
|
||||||
thumbnail.src = `/view?${params.toString()}`;
|
|
||||||
} else if (typeof imageValue === "string" && imageValue) {
|
|
||||||
const params = new URLSearchParams({ filename: imageValue, type: "input", subfolder: "" });
|
|
||||||
thumbnail.src = `/view?${params.toString()}`;
|
|
||||||
}
|
|
||||||
thumbnail.onerror = () => { thumbnail.style.opacity = "0.35"; };
|
|
||||||
return thumbnail;
|
|
||||||
};
|
|
||||||
const openAutocomplete = (at) => {
|
const openAutocomplete = (at) => {
|
||||||
closeAutocomplete();
|
closeAutocomplete();
|
||||||
autocompleteRange = { start: at, end: at + 1 };
|
autocompleteRange = { start: at, end: at + 1 };
|
||||||
const menu = el("div");
|
const menu = el("div");
|
||||||
menu.style.cssText = "display:block;visibility:visible;opacity:1;position:absolute;z-index:100;left:4px;min-width:220px;max-width:310px;padding:5px;background:#25282b;border:1px solid #4b5960;border-radius:8px;box-shadow:0 8px 24px #000b;color:#e7edf0;pointer-events:auto";
|
menu.style.cssText = "display:block;visibility:visible;opacity:1;position:absolute;z-index:100;left:4px;min-width:220px;max-width:310px;padding:5px;background:#25282b;border:1px solid #4b5960;border-radius:8px;box-shadow:0 8px 24px #000b;color:#e7edf0;pointer-events:auto";
|
||||||
menu.style.top = "0px";
|
menu.style.top = "0px";
|
||||||
const connected = Array.from({ length: 9 }, (_, offset) => offset + 1)
|
|
||||||
.filter((index) => node.inputs?.some((input) => input.name === `reference_image_${index}` && input.link != null));
|
|
||||||
const addOption = (content, title, action) => {
|
const addOption = (content, title, action) => {
|
||||||
const option = el("button"); option.type = "button"; option.title = title;
|
const option = el("button"); option.type = "button"; option.title = title;
|
||||||
option.style.cssText = "display:flex;align-items:center;gap:9px;width:100%;padding:6px 8px;border:0;border-radius:5px;background:transparent;color:#e7edf0;text-align:left;font:12px monospace;cursor:pointer";
|
option.style.cssText = "display:flex;align-items:center;gap:9px;width:100%;padding:6px 8px;border:0;border-radius:5px;background:transparent;color:#e7edf0;text-align:left;font:12px monospace;cursor:pointer";
|
||||||
@@ -588,23 +508,8 @@ function configure(node) {
|
|||||||
option.onclick = (event) => { event.preventDefault(); event.stopPropagation(); action(); };
|
option.onclick = (event) => { event.preventDefault(); event.stopPropagation(); action(); };
|
||||||
option.append(...content); menu.append(option);
|
option.append(...content); menu.append(option);
|
||||||
};
|
};
|
||||||
connected.forEach((index) => addOption([
|
|
||||||
sourceThumbnail(index),
|
|
||||||
el("span", `@image${index}`),
|
|
||||||
(() => { const hint = el("span", `<Picture ${index}>`); hint.style.cssText = "margin-left:auto;color:#84939a;font-size:10px"; return hint; })(),
|
|
||||||
], `Insert @R${index}`, () => {
|
|
||||||
const start = autocompleteRange?.start ?? prompt.value.length;
|
|
||||||
const end = autocompleteRange?.end ?? start;
|
|
||||||
const token = `@R${index} `;
|
|
||||||
prompt.value = prompt.value.slice(0, start) + token + prompt.value.slice(end);
|
|
||||||
const caret = start + token.length;
|
|
||||||
focusPrompt(); prompt.setSelectionRange(caret, caret);
|
|
||||||
promptSelectionStart = caret; promptSelectionEnd = caret;
|
|
||||||
promptText = prompt.value; clip.prompt = prompt.value;
|
|
||||||
syncPrompt(clip, clip.prompt); persistState(); closeAutocomplete();
|
|
||||||
}));
|
|
||||||
refModDescriptors.forEach((descriptor, offset) => {
|
refModDescriptors.forEach((descriptor, offset) => {
|
||||||
const slot = firstRefModSlot + offset + 1;
|
const slot = offset + 1;
|
||||||
addOption([
|
addOption([
|
||||||
(() => { const icon = el("span", "R"); icon.style.cssText = "display:grid;place-items:center;width:24px;height:24px;border-radius:50%;background:#7952a8;color:#fff;font-weight:bold"; return icon; })(),
|
(() => { const icon = el("span", "R"); icon.style.cssText = "display:grid;place-items:center;width:24px;height:24px;border-radius:50%;background:#7952a8;color:#fff;font-weight:bold"; return icon; })(),
|
||||||
el("span", `@R${slot} ${descriptor.name}`),
|
el("span", `@R${slot} ${descriptor.name}`),
|
||||||
|
|||||||
@@ -64,9 +64,11 @@ class FakeReferenceBundle:
|
|||||||
|
|
||||||
class FakeRefMod:
|
class FakeRefMod:
|
||||||
kind = "video"
|
kind = "video"
|
||||||
name = "hero_ref"
|
|
||||||
path = ""
|
path = ""
|
||||||
|
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
|
||||||
class H3NodeTests(unittest.TestCase):
|
class H3NodeTests(unittest.TestCase):
|
||||||
def test_prompt_schema_and_full_chunk_reference_routing(self):
|
def test_prompt_schema_and_full_chunk_reference_routing(self):
|
||||||
@@ -74,6 +76,10 @@ class H3NodeTests(unittest.TestCase):
|
|||||||
PROMPT.DumasH3SequencePromptBuilder.CATEGORY,
|
PROMPT.DumasH3SequencePromptBuilder.CATEGORY,
|
||||||
"Dumas/MiniMax H3/Prompt",
|
"Dumas/MiniMax H3/Prompt",
|
||||||
)
|
)
|
||||||
|
optional = PROMPT.DumasH3SequencePromptBuilder.INPUT_TYPES()["optional"]
|
||||||
|
self.assertEqual(optional["ref_mod_1"][0], "H3_REF_MODS")
|
||||||
|
self.assertEqual(optional["ref_mod_9"][0], "H3_REF_MODS")
|
||||||
|
self.assertNotIn("reference_image_1", optional)
|
||||||
reference_module = types.ModuleType("upstream.v3.reference_images_v39")
|
reference_module = types.ModuleType("upstream.v3.reference_images_v39")
|
||||||
reference_module.ReferenceImagesV39Bundle = FakeReferenceBundle
|
reference_module.ReferenceImagesV39Bundle = FakeReferenceBundle
|
||||||
sys.modules[reference_module.__name__] = reference_module
|
sys.modules[reference_module.__name__] = reference_module
|
||||||
@@ -84,7 +90,8 @@ class H3NodeTests(unittest.TestCase):
|
|||||||
'{"clips":[{"slots":[{"start":0,"end":4,"text":"Walk."}]},'
|
'{"clips":[{"slots":[{"start":0,"end":4,"text":"Walk."}]},'
|
||||||
'{"slots":[{"start":0,"end":4,"text":"Turn."}]}]}',
|
'{"slots":[{"start":0,"end":4,"text":"Turn."}]}]}',
|
||||||
"Use @R2 ambience.", "Music.",
|
"Use @R2 ambience.", "Music.",
|
||||||
reference_image_1=object(), reference_image_2=object(),
|
ref_mod_1=[(FakeRefMod("environment"), 1.0)],
|
||||||
|
ref_mod_2=[(FakeRefMod("hero"), 1.0)],
|
||||||
)
|
)
|
||||||
self.assertEqual(result[1], 2)
|
self.assertEqual(result[1], 2)
|
||||||
self.assertEqual(result[2], 4.0)
|
self.assertEqual(result[2], 4.0)
|
||||||
@@ -102,7 +109,7 @@ class H3NodeTests(unittest.TestCase):
|
|||||||
result = PROMPT.DumasH3SequencePromptBuilder().build(
|
result = PROMPT.DumasH3SequencePromptBuilder().build(
|
||||||
2, 4, "", '{"clips":[{"slots":[{"start":0,"end":4,"text":"Use @R1."}]},'
|
2, 4, "", '{"clips":[{"slots":[{"start":0,"end":4,"text":"Use @R1."}]},'
|
||||||
'{"slots":[{"start":0,"end":4,"text":"Continue with @R1."}]}]}',
|
'{"slots":[{"start":0,"end":4,"text":"Continue with @R1."}]}]}',
|
||||||
"", "", ref_mods=[(FakeRefMod(), 1.0)],
|
"", "", ref_mod_1=[(FakeRefMod("hero_ref"), 1.0)],
|
||||||
)
|
)
|
||||||
self.assertEqual(result[4][0][0].name, "hero_ref")
|
self.assertEqual(result[4][0][0].name, "hero_ref")
|
||||||
self.assertEqual(result[5], 0)
|
self.assertEqual(result[5], 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user