"""Long dialogues of follow-up questions about Lumi's own answers and of questions Lumi has no fact for (tests/dialogues_followup_en.py, _ko.py), through the same turn as tests/dialogue_check.py, keeping the context. .venv/bin/python tests/followup_check.py # every dialogue -> logs/followup_check.md / .json .venv/bin/python tests/followup_check.py ko # only dialogues whose persona or topic contains this .venv/bin/python tests/followup_check.py 3,17 # only these dialogues .venv/bin/python tests/followup_check.py --failed # only the dialogues that failed in the saved .json .venv/bin/python tests/followup_check.py --blind 4 # the writer's blind train set (tests/blind/train/ # followup_dialogues.py), every 4th dialogue -> logs/followup_blind.* .venv/bin/python tests/followup_check.py --unknowns 2 # tests/blind/train/unknowns.py, every 2nd case .venv/bin/python tests/followup_check.py --blind 6 --r2 # the same from round 2 (tests/blind/r2/train/) A turn made with S(say, said) is answered by code in lumi.py (a refusal, a seeing answer, a fixed line): its line goes into the talk through lumi.keep_said, the way Lumi.talk_turn keeps it, and the next turn ("why?", "really?", "μ™œμš”?") must go on from it. Every other turn is dialogue_check.run_turn (rules, then the model) and is checked with dialogue_check.problems and its judge. """ import importlib import json import re import sys from assistant import brain, lumi from tests import dialogue_check as dc from tests.conversation_check import markers from tests.dialogues_followup_en import DIALOGUES_FOLLOWUP_EN from tests.dialogues_followup_ko import DIALOGUES_FOLLOWUP_KO DIALOGUES = DIALOGUES_FOLLOWUP_EN + DIALOGUES_FOLLOWUP_KO ROUND = "r2." if "--r2" in sys.argv else "" # --r2: round 2's train sets (tests/blind/r2/train/) dc.OUT_JSON, dc.OUT_MD = dc.ROOT / "logs" / "followup_check.json", dc.ROOT / "logs" / "followup_check.md" def blind(step): """The blind train set in this file's format: a setup turn (its "reply") is said by code, an unscored turn is answered but not checked (expect_action "-").""" B = importlib.import_module(f"tests.blind.{ROUND}train.followup_dialogues").DIALOGUES out = [] for d in B[::step]: turns = [] for t in d["turns"]: if "reply" in t: turns.append({"say": t["say"], "said": t["reply"], "expect_action": "none"}) else: turns.append({"say": t["say"], "expect_action": t.get("expect_action", "none") if t.get("scored") else "-", "must": t.get("must", []) if t.get("scored") else [], "must_not": t.get("must_not", []) if t.get("scored") else [], "check": t.get("check")}) out.append({"who": d["who"], "topic": d["topic"], "lang": d["lang"], "turns": turns}) return out def unknowns(step): """tests/blind/train/unknowns.py as one-question dialogues after their context; the people in view are never the answer about the company.""" CASES = importlib.import_module(f"tests.blind.{ROUND}train.unknowns").CASES out = [] for c in CASES[::step]: no = list(c["must_not"]) if c["kind"] == "unknown" and c.get("people_in_view"): no.append(rf"(? " f"{reply[:90]!r} {probs}", flush=True) dc.OUT_JSON.write_text(json.dumps(rows, ensure_ascii=False, indent=1)) dc.report([r for r in rows if r["got"] != "code"]) if __name__ == "__main__": args = [a for a in sys.argv[1:] if not a.startswith("--")] for flag, make in (("--blind", blind), ("--unknowns", unknowns)): if flag in sys.argv: DIALOGUES = make(int(args.pop(0)) if args else 1) name = ("followup_blind" if flag == "--blind" else "unknowns_check") + ("_r2" if ROUND else "") dc.OUT_JSON, dc.OUT_MD = dc.ROOT / "logs" / f"{name}.json", dc.ROOT / "logs" / f"{name}.md" main(args[0] if args else None, failed="--failed" in sys.argv)