File size: 978 Bytes
7f03c90
 
03d11a7
7f03c90
03d11a7
 
 
7f03c90
 
 
03d11a7
 
7f03c90
 
03d11a7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Precompute Auto-mode answers for the 5 one-click examples. Maintainer-only: run locally with
HF_TOKEN set; that token pays for this one-off build. Never runs on the Space."""
import json
import os
from datetime import datetime, timezone
import app

token = os.environ.get("HF_TOKEN")
if not token:
    raise SystemExit("Set HF_TOKEN (the maintainer's token) to build the cache.")
out = {}
for ex in app.EXAMPLES:
    status, plain, structured, *cards = app._run_live(ex, "Auto (LLM picks)", None, token)
    if "⚠️" in status + plain + structured or "💳" in status or "🔑" in status or "🚫" in status:
        raise SystemExit(f"inference failed for {ex!r}: {status} {plain[:100]}")
    out[ex] = {"status": status, "plain": plain, "structured": structured, "cards": cards,
               "model": app.MODEL_ID, "generated_at": datetime.now(timezone.utc).isoformat()}
    print("ok", status)
app.CACHE_FILE.write_text(json.dumps(out, indent=1, ensure_ascii=False))