File size: 1,115 Bytes
1138ff6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Show submitted answers next to expected answers for calibration episodes.

Usage: python scripts/inspect_calibration.py reports/calibration/<run>/episodes.jsonl [task-prefix]
"""

import json
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
sys.path.insert(0, str(Path(__file__).resolve().parent))

from calibrate import first_json_object  # noqa: E402
from five_desks.tasks import build  # noqa: E402

path = sys.argv[1]
prefix = sys.argv[2] if len(sys.argv) > 2 else ""
for line in open(path):
    ep = json.loads(line)
    if not ep["task_id"].startswith(prefix) or "seed" not in ep:
        continue
    inst = build(ep["task_id"], ep["seed"])
    want = {p.key: p.expected for p in inst.parts}
    got = first_json_object(ep["turns"][-1]["reply"]) if ep["turns"] else None
    got = (got or {}).get("answer", got)
    tools = [(first_json_object(t["reply"]) or {}).get("tool", "?") for t in ep["turns"]]
    print(f"{ep['task_id']} seed={ep['seed']} reward={ep['reward']} end={ep['end']} tools={tools}")
    print(f"    expected {want}\n    got      {got}")