diff --git a/README.md b/README.md index 7edfc78..58ca21b 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,12 @@ Example output: Preserve the same character and environment. [0-4s] -The character walks forward and looks toward the light. +0-2s: The character walks forward and looks toward the light. +2-4s: The character stops and looks toward the light. [4-8s] -Continue seamlessly as the character raises one hand. +0-2s: Continue seamlessly as the character raises one hand. +2-4s: The character looks toward the camera. overall_soundscape: Quiet room tone and footsteps. non_diegetic_music: Low cinematic pulse. diff --git a/prompt_builder.py b/prompt_builder.py index 6af7116..2d96721 100644 --- a/prompt_builder.py +++ b/prompt_builder.py @@ -99,7 +99,12 @@ def format_sequence_prompt( soundscape: str = "", music: str = "", ) -> str: - """Flatten clip-local slots into the absolute H3 Timeline prompt format.""" + """Format uniform clips as chunk blocks with relative shot timings. + + Continuum treats square-bracket ranges as physical/logical chunk markers. + Shot timings belong inside each chunk and must therefore use plain + ``start-end s:`` lines rather than creating additional Timeline sections. + """ sections: list[str] = [] directive = str(shared_directive or "").strip() @@ -107,11 +112,14 @@ def format_sequence_prompt( sections.append(directive) cursor = 0.0 for clip in sequence["clips"]: + duration = float(clip["duration"]) + chunk_lines = [f"[{cursor:g}-{cursor + duration:g}s]"] for slot in clip["slots"]: - start = cursor + float(slot["start"]) - end = cursor + float(slot["end"]) - sections.append(f"[{start:g}-{end:g}s]\n{slot['text']}") - cursor += float(clip["duration"]) + start = float(slot["start"]) + end = float(slot["end"]) + chunk_lines.append(f"{start:g}-{end:g}s: {slot['text']}") + sections.append("\n".join(chunk_lines)) + cursor += duration sections.append(f"overall_soundscape: {str(soundscape or '').strip() or 'N/A'}") sections.append(f"non_diegetic_music: {str(music or '').strip() or 'N/A'}") return "\n\n".join(sections).strip() diff --git a/tests/test_sequence_prompt_builder.py b/tests/test_sequence_prompt_builder.py index 5e92805..0f6f87d 100644 --- a/tests/test_sequence_prompt_builder.py +++ b/tests/test_sequence_prompt_builder.py @@ -16,7 +16,7 @@ def test_builder_emits_one_absolute_timeline_prompt_from_clip_local_slots(): sequence = normalize_sequence( {"clips": [ {"duration": 4, "slots": [{"start": 0, "end": 2, "text": "Walk forward."}]}, - {"duration": 5, "slots": [{"start": 1, "end": 5, "text": "Turn toward the light."}]}, + {"duration": 5, "slots": [{"start": 1, "end": 4, "text": "Turn toward the light."}]}, ]}, clip_count=2, default_seconds=4, @@ -27,8 +27,10 @@ def test_builder_emits_one_absolute_timeline_prompt_from_clip_local_slots(): soundscape="Quiet street ambience.", music="Low cinematic pulse.", ) - assert "[0-2s]" in result - assert "[5-9s]" in result + assert "[0-4s]\n0-2s: First." in result + assert "[4-8s]\n1-4s: Turn toward the light." in result + assert "[0-2s]" not in result + assert "[5-9s]" not in result assert "overall_soundscape: Quiet street ambience." in result assert "non_diegetic_music: Low cinematic pulse." in result