Simplified the json schema passed to the LLM, and implemented more forgiving error handling for LLM proposed corrections

This commit is contained in:
2026-04-21 11:14:56 -05:00
parent 8c80c942dd
commit 23532cade1
9 changed files with 216 additions and 97 deletions

View File

@@ -1,3 +1,5 @@
import json
from audita.chunking import chunk_transcript
from audita.prompts import build_glossary_correction_messages
from audita.schemas import parse_glossary_yaml, parse_transcript_json
@@ -32,3 +34,31 @@ def test_prompt_requires_acoustically_plausible_transcription_errors():
assert '"gestures" to "Jesters"' in prompt_text
assert '"Lyra" to "Jesters"' in prompt_text
assert "should be omitted" in prompt_text
def test_prompt_uses_simplified_segment_payload():
transcript = parse_transcript_json(
"""
[
{"speaker": "Eric", "start": 0.0, "end": 1.0, "text": "The gestures are nearby."}
]
"""
)
glossary = parse_glossary_yaml(
"""
glossary:
- name: "Jesters"
category: faction
summary: "The Jesters are a local faction."
"""
)
section = chunk_transcript(transcript, max_section_tokens=16000)[0]
messages = build_glossary_correction_messages(section, glossary)
transcript_json = messages[1]["content"].split("Transcript section:\n", maxsplit=1)[1]
prompt_segments = json.loads(transcript_json)
assert prompt_segments == [{"segment_id": 0, "original_text": "The gestures are nearby."}]
assert "speaker" not in prompt_segments[0]
assert "start" not in prompt_segments[0]
assert "end" not in prompt_segments[0]