17 lines
773 B
Python
17 lines
773 B
Python
from buddhagpt.datagen import build_messages, parse_pairs, dedupe
|
|
|
|
def test_build_messages_varies_templates():
|
|
sutta = {"uid": "mn21", "title": "T", "text": "x" * 900}
|
|
prompts = {build_messages(sutta, v)[1]["content"] for v in range(6)}
|
|
assert len(prompts) == 6 # rotating templates, not one fixed prompt
|
|
|
|
def test_parse_pairs_extracts_json_lines():
|
|
out = '{"question": "Q1?", "answer": "A1"}\n{"question": "Q2?", "answer": "A2"}'
|
|
assert len(parse_pairs(out, uid="mn21")) == 2
|
|
|
|
def test_dedupe_drops_near_duplicates():
|
|
pairs = [{"question": "What is craving?", "answer": "a"},
|
|
{"question": "What is craving?", "answer": "b"},
|
|
{"question": "How does one practice metta?", "answer": "c"}]
|
|
assert len(dedupe(pairs)) == 2
|