Route references found in full chunk prompts
This commit is contained in:
+11
-1
@@ -181,10 +181,20 @@ class DumasH3SequencePromptBuilder:
|
|||||||
default_seconds=float(default_chunk_seconds),
|
default_seconds=float(default_chunk_seconds),
|
||||||
)
|
)
|
||||||
selectors = []
|
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):
|
for reference_index in range(1, 10):
|
||||||
chunks = []
|
chunks = []
|
||||||
for chunk_index, clip in enumerate(sequence["clips"], start=1):
|
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(
|
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_])",
|
rf"@(R{reference_index}|image{reference_index})(?![A-Za-z0-9_])",
|
||||||
text,
|
text,
|
||||||
|
|||||||
@@ -100,3 +100,25 @@ def test_builder_routes_connected_references_only_to_mentioning_chunks():
|
|||||||
assert bundle.reference_use == "Per chunk"
|
assert bundle.reference_use == "Per chunk"
|
||||||
assert bundle.selectors == ("1", "1,2", "off", "off", "off", "off", "off", "off", "off")
|
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
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user