""" MindRead HF Space — Clean modern UI (Linear/Vercel aesthetic) """ import json, random, threading, time import httpx import gradio as gr # ── Oracle patch ────────────────────────────────────────────────────────── import server.oracle as oracle_module EVASIVE = [ "That's an interesting angle — I'm not really in a position to say much about that right now.", "I'd rather not get into specifics. It's a bit sensitive at the moment.", "There's definitely some complexity there I can't go into detail about.", "Let's just say things are evolving. I'll leave it at that.", "You might want to read between the lines on that one.", "Some news will surprise people soon — I just can't say when.", "Things aren't quite as stable as they might appear from the outside.", "I've been told to keep that close to my chest, honestly.", ] def _mock_oracle(secret, conversation_history, question): q = question.lower() if any(kw.lower() in q for kw in secret.hint_keywords): return "There's more going on there than I can share right now. Let's just say it's on people's radar." for rh in secret.red_herrings: if any(w in q for w in rh.lower().split()[:3]): return f"Oh, that? Yeah — {rh.lower().rstrip('.')}. Interesting times." return random.choice(EVASIVE) oracle_module.LOCAL_ORACLE_FN = _mock_oracle # ── Server ──────────────────────────────────────────────────────────────── def _run_server(): import uvicorn uvicorn.run("server.main:app", host="0.0.0.0", port=7861, log_level="error") threading.Thread(target=_run_server, daemon=True).start() for _ in range(30): try: if httpx.get("http://localhost:7861/health", timeout=2).status_code == 200: break except Exception: pass time.sleep(1) client = httpx.Client(base_url="http://localhost:7861", timeout=30) TASKS = { "factual_easy": {"label": "Factual · Easy", "q": 8, "color": "#22c55e"}, "factual_hard": {"label": "Factual · Hard", "q": 6, "color": "#eab308"}, "belief_inference": {"label": "Belief Inference", "q": 8, "color": "#f97316"}, "goal_inference": {"label": "Goal Inference", "q": 8, "color": "#f97316"}, "second_order": {"label": "2nd-Order ToM", "q": 10, "color": "#ef4444"}, } # ── CSS — clean minimal dark, inspired by Linear/Vercel ────────────────── CSS = """ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap'); * { box-sizing: border-box; } body, .gradio-container { background: #09090b !important; font-family: 'Inter', -apple-system, sans-serif !important; } .gradio-container { max-width: 1080px !important; margin: 0 auto !important; padding-bottom: 60px !important; } footer { display: none !important; } /* Typography */ h1, h2, h3, h4 { color: #fafafa; font-weight: 600; } p { color: #a1a1aa; } /* Inputs */ input, textarea { background: #18181b !important; border: 1px solid #27272a !important; color: #fafafa !important; border-radius: 8px !important; font-family: 'Inter', sans-serif !important; font-size: 0.9em !important; transition: border-color 0.15s !important; } input:focus, textarea:focus { border-color: #52525b !important; outline: none !important; box-shadow: 0 0 0 2px rgba(255,255,255,0.04) !important; } label { color: #71717a !important; font-size: 0.8em !important; font-weight: 500 !important; } /* Buttons */ button.primary { background: #fafafa !important; color: #09090b !important; border: none !important; border-radius: 8px !important; font-weight: 600 !important; font-size: 0.88em !important; padding: 9px 18px !important; font-family: 'Inter', sans-serif !important; transition: opacity 0.15s !important; cursor: pointer !important; } button.primary:hover { opacity: 0.88 !important; } button.secondary { background: #18181b !important; color: #a1a1aa !important; border: 1px solid #27272a !important; border-radius: 8px !important; font-weight: 500 !important; font-size: 0.88em !important; padding: 9px 18px !important; font-family: 'Inter', sans-serif !important; transition: border-color 0.15s, color 0.15s !important; } button.secondary:hover { border-color: #3f3f46 !important; color: #fafafa !important; } button:disabled { opacity: 0.35 !important; cursor: not-allowed !important; } /* Dropdown */ .wrap { background: #18181b !important; border: 1px solid #27272a !important; border-radius: 8px !important; } .wrap:focus-within { border-color: #52525b !important; } ul.options { background: #18181b !important; border: 1px solid #27272a !important; border-radius: 8px !important; } ul.options li { color: #a1a1aa !important; } ul.options li:hover, ul.options li.selected { background: #27272a !important; color: #fafafa !important; } /* Tabs */ .tab-nav { border-bottom: 1px solid #18181b !important; background: transparent !important; margin-bottom: 24px !important; } .tab-nav button { color: #52525b !important; font-size: 0.85em !important; font-weight: 500 !important; padding: 8px 16px !important; background: transparent !important; border: none !important; border-bottom: 2px solid transparent !important; margin-bottom: -1px !important; font-family: 'Inter', sans-serif !important; transition: color 0.15s !important; } .tab-nav button.selected { color: #fafafa !important; border-bottom-color: #fafafa !important; } .tab-nav button:hover { color: #d4d4d8 !important; } .tabitem { background: transparent !important; border: none !important; padding: 0 !important; } /* Cards */ .card { background: #18181b; border: 1px solid #27272a; border-radius: 12px; padding: 20px 24px; } .card-sm { background: #18181b; border: 1px solid #27272a; border-radius: 10px; padding: 14px 18px; } /* Stats row */ .stats-row { display: flex; gap: 12px; margin: 20px 0; } .stat-card { flex: 1; background: #18181b; border: 1px solid #27272a; border-radius: 10px; padding: 16px 18px; } .stat-card .sv { font-size: 1.6em; font-weight: 700; color: #fafafa; line-height: 1; margin-bottom: 4px; } .stat-card .sl { font-size: 0.75em; color: #52525b; font-weight: 500; } /* Tag */ .tag { display: inline-block; background: #27272a; border: 1px solid #3f3f46; border-radius: 5px; padding: 2px 8px; font-size: 0.72em; color: #a1a1aa; font-weight: 500; font-family: 'JetBrains Mono', monospace; } /* Hero */ .hero { padding: 48px 0 32px; border-bottom: 1px solid #18181b; margin-bottom: 32px; } .hero-eyebrow { font-size: 0.75em; font-weight: 600; color: #52525b; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 14px; } .hero-title { font-size: 2.6em; font-weight: 700; color: #fafafa; line-height: 1.15; margin-bottom: 14px; } .hero-title span { color: #a1a1aa; font-weight: 400; } .hero-desc { font-size: 1em; color: #71717a; line-height: 1.65; max-width: 560px; margin-bottom: 24px; } .hero-tags { display: flex; gap: 8px; flex-wrap: wrap; } /* Chat */ .chat-outer { background: #18181b; border: 1px solid #27272a; border-radius: 12px; overflow: hidden; } .chat-header { padding: 12px 16px; border-bottom: 1px solid #27272a; font-size: 0.78em; color: #52525b; font-weight: 500; display: flex; align-items: center; gap: 8px; } .chat-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; } .chat-body { padding: 16px; min-height: 300px; max-height: 400px; overflow-y: auto; } .chat-body::-webkit-scrollbar { width: 3px; } .chat-body::-webkit-scrollbar-thumb { background: #27272a; border-radius: 2px; } .chat-empty { text-align: center; padding: 60px 20px; color: #3f3f46; font-size: 0.85em; } .msg-det { display: flex; justify-content: flex-end; margin: 8px 0; } .msg-det .b { background: #fafafa; color: #09090b; padding: 9px 14px; border-radius: 12px 12px 3px 12px; max-width: 70%; font-size: 0.87em; line-height: 1.5; font-weight: 500; } .msg-ora { display: flex; align-items: flex-start; gap: 9px; margin: 8px 0; } .msg-ora .av { width: 28px; height: 28px; border-radius: 6px; background: #27272a; border: 1px solid #3f3f46; display: flex; align-items: center; justify-content: center; font-size: 0.85em; flex-shrink: 0; margin-top: 2px; } .msg-ora .b { background: #27272a; color: #d4d4d8; border: 1px solid #3f3f46; padding: 9px 14px; border-radius: 12px 12px 12px 3px; max-width: 70%; font-size: 0.87em; line-height: 1.5; } .msg-sys { text-align: center; margin: 10px 0; } .msg-sys span { display: inline-block; background: #27272a; border: 1px solid #3f3f46; color: #52525b; font-size: 0.72em; padding: 3px 10px; border-radius: 20px; } /* Scene panel */ .scene { background: #18181b; border: 1px solid #27272a; border-radius: 12px; padding: 16px 18px; } .scene .s-key { font-size: 0.7em; font-weight: 600; color: #52525b; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; } .scene .s-val { font-size: 0.87em; color: #d4d4d8; line-height: 1.5; } .scene .divider { border: none; border-top: 1px solid #27272a; margin: 10px 0; } .q-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; } .q-track { flex: 1; height: 3px; background: #27272a; border-radius: 2px; } .q-fill { height: 100%; border-radius: 2px; background: #fafafa; transition: width 0.3s; } .q-label { font-size: 0.72em; color: #52525b; font-weight: 500; white-space: nowrap; } /* Score */ .score { background: #18181b; border: 1px solid #27272a; border-radius: 12px; padding: 24px; } .score .s-num { font-size: 3em; font-weight: 700; color: #fafafa; line-height: 1; } .score .s-sub { font-size: 0.8em; color: #52525b; margin-top: 2px; } .score .s-bar { height: 3px; background: #27272a; border-radius: 2px; margin: 16px 0; } .score .s-fill { height: 100%; border-radius: 2px; background: #fafafa; transition: width 0.6s; } .score .bd { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; } .score .bd-i { background: #09090b; border: 1px solid #27272a; border-radius: 8px; padding: 10px 12px; } .score .bd-k { font-size: 0.7em; color: #52525b; font-weight: 500; margin-bottom: 2px; } .score .bd-v { font-size: 1em; font-weight: 600; color: #fafafa; } .score .reveal { background: #09090b; border: 1px solid #27272a; border-radius: 8px; padding: 12px 14px; margin-top: 12px; } .score .reveal .rk { font-size: 0.7em; color: #52525b; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; } .score .reveal .rv { font-size: 0.87em; color: #d4d4d8; line-height: 1.5; } /* Demo status */ .demo-box { background: #18181b; border: 1px solid #27272a; border-radius: 10px; padding: 16px 18px; font-size: 0.87em; color: #a1a1aa; line-height: 1.65; min-height: 90px; } /* How it works grid */ .hiw { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; } .hiw-c { background: #18181b; border: 1px solid #27272a; border-radius: 10px; padding: 18px; } .hiw-c .ic { font-size: 1.3em; margin-bottom: 10px; } .hiw-c h4 { font-size: 0.9em; color: #fafafa; font-weight: 600; margin-bottom: 5px; } .hiw-c p { font-size: 0.82em; color: #71717a; line-height: 1.6; } /* Table */ .tbl { width: 100%; border-collapse: collapse; font-size: 0.84em; } .tbl th { padding: 8px 14px; text-align: left; color: #52525b; font-weight: 500; border-bottom: 1px solid #27272a; } .tbl td { padding: 10px 14px; color: #a1a1aa; border-bottom: 1px solid #18181b; } .tbl td:first-child { color: #fafafa; font-weight: 500; } .tbl code { font-family: 'JetBrains Mono', monospace; color: #a1a1aa; font-size: 0.9em; } /* Code */ .code { background: #09090b; border: 1px solid #27272a; border-radius: 8px; padding: 14px 16px; font-family: 'JetBrains Mono', monospace; font-size: 0.8em; color: #71717a; line-height: 1.8; overflow-x: auto; margin: 10px 0; } .code .kw { color: #a1a1aa; } /* Tip */ .tip { border-left: 2px solid #3f3f46; padding: 8px 12px; font-size: 0.82em; color: #71717a; line-height: 1.6; margin: 8px 0; } """ # ── Helpers ─────────────────────────────────────────────────────────────── def render_chat(history, label="Interrogation"): body = "" if not history: body = '
Holds a hidden secret. Cannot lie, but will never reveal it directly. Every evasive answer contains a signal.
Must infer the secret by asking strategic questions. Fewer questions = higher efficiency bonus. Think, don't fish.
reward = semantic_sim × efficiency
Closer guess + fewer questions = higher score.
After 300 GRPO steps, the detective asked 44% fewer questions. It stopped fishing and started thinking strategically.
| Task | What to infer | Max questions | Difficulty |
|---|---|---|---|
factual_easy | A hidden workplace fact | 8 | Easy |
factual_hard | A precise number or date | 6 | Medium |
belief_inference | What Oracle believes about someone | 8 | Hard |
goal_inference | Oracle's hidden ambition | 8 | Hard |
second_order | Belief about a belief (recursive) | 10 | Hardest |