More bugfixes in the glossary protection guard module
This commit is contained in:
@@ -70,6 +70,44 @@ def test_prompt_uses_simplified_segment_payload():
|
||||
assert "end" not in prompt_segments[0]
|
||||
|
||||
|
||||
def test_prompts_do_not_include_inferred_plurals():
|
||||
transcript = parse_transcript_json(
|
||||
"""
|
||||
[
|
||||
{"id": 1, "speaker": "Eric", "start": 0.0, "end": 1.0, "text": "The gestures are nearby."}
|
||||
]
|
||||
"""
|
||||
)
|
||||
glossary = parse_glossary_yaml(
|
||||
"""
|
||||
glossary:
|
||||
- name: "Godfrey"
|
||||
aliases:
|
||||
- "Jester"
|
||||
category: npc
|
||||
summary: "Godfrey is an NPC."
|
||||
"""
|
||||
)
|
||||
section = chunk_transcript(transcript, max_section_tokens=16000)[0]
|
||||
|
||||
glossary_messages = build_glossary_correction_messages(section, glossary)
|
||||
glossary_json = glossary_messages[1]["content"].split("Glossary:\n", maxsplit=1)[1].split(
|
||||
"\n\nTranscript section:",
|
||||
maxsplit=1,
|
||||
)[0]
|
||||
grammar_messages = build_grammar_correction_messages(section, glossary)
|
||||
grammar_json = grammar_messages[1]["content"].split("Protected glossary/context:\n", maxsplit=1)[1].split(
|
||||
"\n\nTranscript section:",
|
||||
maxsplit=1,
|
||||
)[0]
|
||||
|
||||
for prompt_glossary in (json.loads(glossary_json), json.loads(grammar_json)):
|
||||
entry = prompt_glossary["glossary"][0]
|
||||
assert "plural" not in entry
|
||||
assert "Godfreys" not in json.dumps(prompt_glossary)
|
||||
assert "Jesters" not in json.dumps(prompt_glossary)
|
||||
|
||||
|
||||
def test_grammar_prompt_limits_readability_corrections_and_protects_glossary():
|
||||
transcript = parse_transcript_json(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user