Return ({step_num: action_text}, final_response).
(log_path: Path)
| 66 | |
| 67 | |
| 68 | def parse_log(log_path: Path) -> tuple[dict[int, str], str]: |
| 69 | """Return ({step_num: action_text}, final_response).""" |
| 70 | steps: dict[int, str] = {} |
| 71 | final = "" |
| 72 | if not log_path.exists(): |
| 73 | return steps, final |
| 74 | for raw in log_path.read_text(encoding="utf-8").splitlines(): |
| 75 | m = _STEP_LINE.match(raw.strip()) |
| 76 | if m: |
| 77 | steps[int(m.group(1))] = m.group(2).strip() |
| 78 | continue |
| 79 | f = _FINAL_LINE.match(raw.strip()) |
| 80 | if f: |
| 81 | final = f.group(1).strip() |
| 82 | return steps, final |
| 83 | |
| 84 | |
| 85 | def parse_steps_jsonl(path: Path) -> list[dict]: |