Implement support for segments with an optional categories key

This commit is contained in:
2026-04-28 22:41:16 -05:00
parent 177e45f1fd
commit db6004fadc
10 changed files with 115 additions and 9 deletions

View File

@@ -25,3 +25,19 @@ def test_chunk_transcript_batches_sections_by_token_limit():
assert len(sections) == 2
assert [segment.segment.id for segment in sections[0].segments] == [1, 2]
assert [segment.segment.id for segment in sections[1].segments] == [3]
def test_chunk_transcript_prompt_payload_includes_categories_when_present():
transcript = parse_transcript_json(
"""
[
{"id": 1, "speaker": "A", "start": 0.0, "end": 1.0, "text": "one", "categories": ["intro", "aside"]}
]
"""
)
sections = chunk_transcript(transcript, max_section_tokens=8, estimator=FakeEstimator())
assert sections[0].prompt_payload() == [
{"id": 1, "original_text": "one", "categories": ["intro", "aside"]}
]