"""Cached showcase — three pre-rendered personas behind "Try an Example". Judges get instant payoff (lyrics + agent trace + song, video when a headshot was used) with ZERO ZeroGPU quota: the bundles are rendered once by scripts/render_examples.py and committed under examples/. The three span the Sendability slider end to end — 1 (Sendable) · 5 (LinkedIn Risky) · 10 (HR Has Left the Chat) — so one click tells the whole "same résumé, one slider" story. These same renders double as demo-video footage. This module is pure (no gradio/model imports) so it stays import-cheap and testable; app.py wraps load_example() into component updates. """ import json import os _ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) EX_DIR = os.path.join(_ROOT, "examples") # Three personas pinned to a slider zone + a contrasting genre. EXAMPLES = [ { "id": "sde_sendable", "label": "💻 Software Engineer · Lv 1", "blurb": "Actually Sendable", "level": 1, "genre": "🎭 Broadway Ballad", "resume": """Devin Cho — Software Engineer 6 years building backend systems. Go, Python, Kubernetes, Postgres, gRPC. - Cut API p99 latency 38% by rewriting the hot path and killing 3 N+1 queries - Owned the on-call rotation nobody wanted; paged 200+ times, slept fine - Shipped a feature-flag service now used by all 14 product teams - Wrote the migration that moved 4B rows with zero downtime (and zero drama) B.S. Computer Science. Maintains a popular open-source CLI (2.1k stars).""", "jd": """Senior Software Engineer — Meridian Pay We process payments for 30k merchants and downtime is not an option. You'll own core services, mentor engineers, and make our platform faster and calmer. Must love clean code, pragmatic trade-offs, and writing the doc nobody asked for. Bonus: distributed-systems scars and a healthy fear of midnight deploys.""", }, { "id": "sales_risky", "label": "📈 Sales Manager · Lv 5", "blurb": "LinkedIn Risky", "level": 5, "genre": "📺 Corporate Jingle", "resume": """Priya Nair — Regional Sales Manager 9 years in B2B SaaS sales. President's Club x4. CRM whisperer. - Closed $4.2M in net-new ARR last year — 138% of quota - Built a 7-rep team from scratch; 5 promoted within 18 months - Turned a churned whale back into our biggest reference account - Once closed a deal from a hospital waiting room (don't ask) Runs the office "deal gong" with controversial enthusiasm.""", "jd": """Sales Manager — Northwind Cloud Lead a team of account executives selling our data platform to mid-market. Own the number, coach the pipeline, forecast like your life depends on it, and keep morale high through a brutal Q4. We want a closer who can also build people. Bonus: you've carried a bag yourself and still miss it a little.""", }, { "id": "datasci_unhinged", "label": "📊 Data Scientist · Lv 10", "blurb": "HR Has Left the Chat", "level": 10, "genre": "🎤 Drill", "resume": """Maya Iyer — Data Scientist 5 years experience. Python, SQL, dbt, Airflow, scikit-learn, XGBoost. - Cut churn 23% at a fintech by deploying a gradient-boosted retention model - Built the company's first A/B testing platform (40+ experiments/quarter) - Maintain a dashboard suite execs describe as "weirdly addictive" - Once found $1.2M in lost revenue hiding in a timezone bug Kaggle Expert. Gives internal talks titled "p-values are a vibe".""", "jd": """Senior Data Scientist — Loop Logistics We move 2M packages a day and our data should move faster. You'll own our demand-forecasting models, wrangle a 40TB warehouse, and convince ops folks that ML is not witchcraft. Must love SQL, ship pragmatic models, and explain uncertainty to people who hate uncertainty. Bonus: experience with churn.""", }, ] def _path(ex_id: str, suffix: str) -> str: return os.path.join(EX_DIR, f"{ex_id}.{suffix}") def load_example(index: int): """Return (example, lyrics|None, trace_html|None, song_path|None, video_path|None). trace is the PRE-RENDERED Producer-notes HTML (the live API returns HTML now, not a dict). Missing bundle files come back as None so the UI degrades gracefully.""" ex = EXAMPLES[index] eid = ex["id"] lyrics = trace = song = video = None lp = _path(eid, "lyrics.txt") if os.path.isfile(lp): with open(lp, encoding="utf-8") as f: lyrics = f.read() # prefer pre-rendered HTML (new bundles); fall back to the legacy dict json tp = _path(eid, "trace.html") if os.path.isfile(tp): try: with open(tp, encoding="utf-8") as f: trace = f.read() except Exception: trace = None else: jp = _path(eid, "trace.json") if os.path.isfile(jp): try: with open(jp, encoding="utf-8") as f: trace = json.load(f) except Exception: trace = None sp = _path(eid, "song.mp3") if os.path.isfile(sp): song = sp vp = _path(eid, "video.mp4") if os.path.isfile(vp): video = vp return ex, lyrics, trace, song, video def has_cache(index: int) -> bool: """True once an example has at least its lyrics bundle committed.""" return os.path.isfile(_path(EXAMPLES[index]["id"], "lyrics.txt"))