Route references found in full chunk prompts
tests / test (push) Canceled after 0s
tests / windows-storage (push) Canceled after 0s

This commit is contained in:
2026-10-15 20:59:33 +00:00
parent 92ed0cfc31
commit 6aae047401
2 changed files with 33 additions and 1 deletions
+11 -1
View File
@@ -181,10 +181,20 @@ class DumasH3SequencePromptBuilder:
default_seconds=float(default_chunk_seconds),
)
selectors = []
directive = str(shared_directive or "").strip()
sound = str(soundscape or "").strip() or "N/A"
music_text = str(music or "").strip() or "N/A"
for reference_index in range(1, 10):
chunks = []
for chunk_index, clip in enumerate(sequence["clips"], start=1):
text = "\n".join(str(slot.get("text", "")) for slot in clip["slots"])
# Match against the same per-chunk content emitted by
# format_sequence_prompt, not only the editable shot lines.
text = "\n".join([
directive,
*(str(slot.get("text", "")) for slot in clip["slots"]),
f"overall_soundscape: {sound}",
f"non_diegetic_music: {music_text}",
])
if kwargs.get(f"reference_image_{reference_index}") is not None and re.search(
rf"@(R{reference_index}|image{reference_index})(?![A-Za-z0-9_])",
text,
+22
View File
@@ -100,3 +100,25 @@ def test_builder_routes_connected_references_only_to_mentioning_chunks():
assert bundle.reference_use == "Per chunk"
assert bundle.selectors == ("1", "1,2", "off", "off", "off", "off", "off", "off", "off")
assert bundle.images[0] is not None and bundle.images[1] is not None
def test_builder_routes_references_mentioned_anywhere_in_each_chunk_prompt():
value = {
"clips": [
{"slots": [{"start": 0, "end": 4, "text": "The subject walks."}]},
{"slots": [{"start": 0, "end": 4, "text": "The subject stops."}]},
]
}
result = DumasH3SequencePromptBuilder().build(
2,
4,
"Preserve the environment from @R1.",
json.dumps(value),
"Use ambience from @R2.",
"Music follows @R3.",
reference_image_1=object(),
reference_image_2=object(),
reference_image_3=object(),
)
assert result[3].selectors[:3] == ("1,2", "1,2", "1,2")