easy-media-track-gate: idempotent media-token prepending in prompt_override builder
The builder no longer prepends <Picture N>/<Audio N>/<Video N> tokens that the
fragment prompt already carries. The duplicated token still resolved to one
slot at runtime, but the model read it twice. Verified against the real
ComfyUI-Easy-Media utils/prompt_override.py parser: 3-segment payload builds,
image slot demand = {image}, durations 10/10/10.
This commit is contained in:
parent
8434bb4645
commit
fd874adbd3
@ -1026,12 +1026,20 @@ def build_prompt_override(outline: dict[str, Any], fragments: list[dict[str, Any
|
|||||||
text = content.get("user_prompt_b") if variant == "b" else content.get("user_prompt")
|
text = content.get("user_prompt_b") if variant == "b" else content.get("user_prompt")
|
||||||
if not isinstance(text, str) or not text.strip():
|
if not isinstance(text, str) or not text.strip():
|
||||||
raise Fail(f"fragment {frag.get('id', '?')}: no prompt text for the override payload")
|
raise Fail(f"fragment {frag.get('id', '?')}: no prompt text for the override payload")
|
||||||
|
# Idempotent prepending: a fragment prompt that already carries its approved
|
||||||
|
# <Picture N>/<Audio N>/<Video N> tokens must not get them duplicated — the
|
||||||
|
# duplicated text still resolves to one slot, but it reads wrong to the model.
|
||||||
|
present_pics = {int(m.group(1)) for m in _PICTURE_RE.finditer(text)}
|
||||||
|
present_audio = {int(m.group(1)) for m in _AUDIO_RE.finditer(text)}
|
||||||
|
present_video = {int(m.group(1)) for m in _VIDEO_RE.finditer(text)}
|
||||||
refs = ""
|
refs = ""
|
||||||
for img in row.get("images", []):
|
for img in row.get("images", []):
|
||||||
refs += f"<Picture {positions[img['key']]}> "
|
pos = positions[img["key"]]
|
||||||
if audio_pos is not None:
|
if pos not in present_pics:
|
||||||
|
refs += f"<Picture {pos}> "
|
||||||
|
if audio_pos is not None and audio_pos not in present_audio:
|
||||||
refs += f"<Audio {audio_pos}> "
|
refs += f"<Audio {audio_pos}> "
|
||||||
if video_pos is not None:
|
if video_pos is not None and video_pos not in present_video:
|
||||||
refs += f"<Video {video_pos}> "
|
refs += f"<Video {video_pos}> "
|
||||||
prompts.append(" ".join((refs + text).split()))
|
prompts.append(" ".join((refs + text).split()))
|
||||||
durations.append(f"{float(row['duration_seconds']):g}")
|
durations.append(f"{float(row['duration_seconds']):g}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user