File size: 1,163 Bytes
ec66703
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from __future__ import annotations

import json
from pathlib import Path

import gradio as gr

import generate_evidence


ROOT = Path(__file__).resolve().parent
BUNDLE_PATH = ROOT / "evidence" / "bundle.json"


def _load_bundle() -> dict:
    if not BUNDLE_PATH.exists():
        return generate_evidence.build_evidence(ROOT)
    return json.loads(BUNDLE_PATH.read_text())


def _markdown() -> str:
    bundle = _load_bundle()
    rows = []
    for claim in bundle["claims"]:
        rows.append(
            f"- `{claim['status']}` `{claim['claim_sha256'][:12]}`: {claim['claim']}"
        )
    return "\n".join(
        [
            "# MemoryBench Reproduction",
            "",
            f"Attempt: `{bundle['attempt_id']}`",
            f"Snapshot: `{bundle['snapshot_id']}`",
            f"API cost: `${bundle['api_cost_usd']:.2f}`",
            "",
            "## Claims",
            "",
            *rows,
            "",
            "Full machine-readable evidence is in `evidence/bundle.json`.",
        ]
    )


with gr.Blocks(title="MemoryBench Reproduction") as demo:
    gr.Markdown(_markdown())


if __name__ == "__main__":
    demo.launch()