owenisas commited on
Commit
2816586
·
verified ·
1 Parent(s): 0db6652

UI/UX redesign: tap-to-play trap card grid, animated verdict banner, stat-tile scoreboard, fixed hero/tab contrast

Browse files
Files changed (1) hide show
  1. app.py +195 -110
app.py CHANGED
@@ -10,6 +10,7 @@ import tarfile
10
  import threading
11
  import time
12
  import urllib.request
 
13
  from pathlib import Path
14
  from typing import Any
15
 
@@ -544,13 +545,10 @@ def scoreboard_html(score: dict[str, int] | None) -> str:
544
  rank = _rank(caught, total)
545
  return f"""
546
  <div class="fp-score">
547
- <div class="fp-score-head">Scoreboard &middot; <span class="fp-rank">{rank}</span></div>
548
- <div class="fp-score-row">
549
- <span class="fp-pill fp-pill-good">✅ Caught {caught}</span>
550
- <span class="fp-pill fp-pill-bad">❌ Fooled {missed}</span>
551
- <span class="fp-pill fp-pill-meh">🤔 Unclear {unclear}</span>
552
- <span class="fp-pill">Traps run {total}</span>
553
- </div>
554
  </div>
555
  """
556
 
@@ -565,23 +563,38 @@ def trap_card_html(trap: dict[str, Any], revealed: bool = False) -> str:
565
  </div>
566
  """
567
  return f"""
568
- <div class="fp-card">
569
- <div class="fp-card-cat">{trap['emoji']} {trap['cat']}</div>
570
- <div class="fp-card-title">{trap['title']}</div>
571
- <div class="fp-card-q">&ldquo;{trap['prompt']}&rdquo;</div>
572
  {reveal}
573
  </div>
574
  """
575
 
576
 
577
- VERDICT_TEXT = {
578
- "caught": "## ✅ Caught the trap\nFirst-Principle AI reasoned past the decoy.",
579
- "missed": "## ❌ Fell for it\nLooks like the familiar/decoy answer slipped through.",
580
- "unclear": "## 🤔 You be the judge\nThe auto-check (a keyword heuristic) couldn't tell — read the answer.",
581
- "error": "## ⚠️ Runtime issue\nGeneration did not complete. See the answer for details.",
 
 
582
  }
583
 
584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  def _split_think(text: str) -> tuple[str, str]:
586
  """Split a reasoning model's output into (reasoning, final answer)."""
587
  text = (text or "").strip()
@@ -617,10 +630,8 @@ def _render_reasoning(reasoning: str, answer: str) -> str:
617
  return "".join(parts)
618
 
619
 
620
- def _answer_md(trap: dict[str, Any], reasoning: str, answer: str, verdict: str) -> str:
621
- head = VERDICT_TEXT.get(verdict, VERDICT_TEXT["unclear"])
622
- body = _render_reasoning(reasoning, answer)
623
- return f"{head}\n\n---\n\n**First-Principle AI says:**\n\n{body}"
624
 
625
 
626
  def _thinking_md() -> str:
@@ -690,6 +701,11 @@ def random_trap() -> str:
690
  return random.choice(TRAP_TITLES)
691
 
692
 
 
 
 
 
 
693
  def run_trap(
694
  title: str,
695
  score: dict[str, int] | None,
@@ -701,10 +717,17 @@ def run_trap(
701
  ):
702
  trap = TRAP_BY_TITLE.get(title)
703
  if not trap:
704
- yield "", "Pick a trap first.", scoreboard_html(score), _metrics_markdown(), score
705
  return
706
 
707
- yield trap_card_html(trap, revealed=False), _thinking_md(), scoreboard_html(score), "Queued.", score
 
 
 
 
 
 
 
708
 
709
  try:
710
  text, meta = _generate(trap["prompt"], system_prompt, max_tokens, temperature, top_p, repeat_penalty)
@@ -724,13 +747,26 @@ def run_trap(
724
 
725
  yield (
726
  trap_card_html(trap, revealed=True),
727
- _answer_md(trap, reasoning, answer, verdict),
 
728
  scoreboard_html(score),
729
  _metrics_markdown(meta),
730
  score,
731
  )
732
 
733
 
 
 
 
 
 
 
 
 
 
 
 
 
734
  def reset_score():
735
  s = _new_score()
736
  return scoreboard_html(s), s
@@ -767,81 +803,131 @@ def ask_own(
767
  # ---------------------------------------------------------------------------
768
  CSS = """
769
  :root {
770
- --fp-bg: #f5f7fb;
771
- --fp-panel: #ffffff;
772
- --fp-border: #dbe2ec;
773
- --fp-text: #111827;
774
- --fp-muted: #5b6675;
775
- --fp-accent: #4f46e5;
776
- --fp-accent-dark: #4338ca;
777
- --fp-good: #16a34a;
778
- --fp-bad: #dc2626;
779
- --fp-meh: #d97706;
780
  }
781
  .gradio-container {
782
- background: var(--fp-bg) !important;
783
- color: var(--fp-text) !important;
 
 
 
784
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif !important;
785
  }
786
- .fp-shell { max-width: 1160px; margin: 0 auto; padding: 18px 16px 40px; }
 
 
787
  .fp-hero {
788
- border: 1px solid var(--fp-border);
789
- background: linear-gradient(135deg, #eef2ff 0%, #ffffff 55%, #ecfdf5 100%);
790
- border-radius: 16px;
791
- padding: 26px 28px;
792
- margin-bottom: 18px;
793
- box-shadow: 0 18px 40px rgba(31, 41, 55, 0.08);
794
  }
795
- .fp-hero h1 { margin: 0 0 6px; font-size: 32px; line-height: 1.1; letter-spacing: -0.5px; }
796
- .fp-hero .fp-tag { color: var(--fp-muted); font-size: 16px; margin: 0 0 14px; max-width: 760px; }
 
 
797
  .fp-badges { display: flex; flex-wrap: wrap; gap: 8px; }
798
- .fp-badge {
799
- border: 1px solid var(--fp-border); background: #fff; color: var(--fp-muted);
800
- border-radius: 999px; padding: 5px 12px; font-size: 12px;
801
- }
802
- .fp-badge strong { color: var(--fp-text); font-weight: 650; }
803
- .fp-card {
804
- border: 1px solid var(--fp-border); background: var(--fp-panel);
805
- border-radius: 14px; padding: 18px 20px; margin: 4px 0 10px;
806
- box-shadow: 0 6px 18px rgba(31,41,55,0.05);
807
- }
808
- .fp-card-cat { font-size: 12px; font-weight: 650; color: var(--fp-accent); text-transform: uppercase; letter-spacing: 0.4px; }
809
- .fp-card-title { font-size: 21px; font-weight: 750; margin: 4px 0 10px; }
810
- .fp-card-q { font-size: 17px; line-height: 1.45; color: var(--fp-text); font-style: italic; }
811
- .fp-reveal { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--fp-border); font-size: 14px; color: var(--fp-muted); line-height: 1.5; }
812
- .fp-reveal .fp-wrong { margin-top: 6px; color: var(--fp-bad); }
813
- .fp-score { border: 1px solid var(--fp-border); background: var(--fp-panel); border-radius: 12px; padding: 12px 16px; }
814
- .fp-score-head { font-size: 13px; color: var(--fp-muted); margin-bottom: 8px; font-weight: 600; }
815
- .fp-rank { color: var(--fp-text); font-weight: 750; }
816
- .fp-score-row { display: flex; flex-wrap: wrap; gap: 8px; }
817
- .fp-pill { border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 650; background: #eef2f7; color: var(--fp-muted); }
818
- .fp-pill-good { background: #dcfce7; color: var(--fp-good); }
819
- .fp-pill-bad { background: #fee2e2; color: var(--fp-bad); }
820
- .fp-pill-meh { background: #fef3c7; color: var(--fp-meh); }
821
- .gradio-container .block { border-color: var(--fp-border) !important; border-radius: 12px !important; box-shadow: none !important; }
822
- button.primary { background: var(--fp-accent) !important; border-color: var(--fp-accent) !important; color: #fff !important; }
823
- button.primary:hover { background: var(--fp-accent-dark) !important; }
824
- textarea, input { background: #fff !important; color: var(--fp-text) !important; border-color: var(--fp-border) !important; }
825
- .gradio-container code { background: #eef2f7 !important; color: #111827 !important; border-radius: 4px; padding: 1px 4px; }
826
- .fp-note { border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3; border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.5; margin-bottom: 10px; }
827
- @media (max-width: 900px) { .fp-hero h1 { font-size: 26px; } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
828
  """
829
 
830
  HERO = """
831
  <div class="fp-hero">
832
- <h1>🎯 First-Principle AI · Gotcha Arena</h1>
833
- <p class="fp-tag">A small reasoning model that reads the question, not the pattern.
834
  Throw it the trick questions that fool the big models — and watch it catch the catch.</p>
835
  <div class="fp-badges">
836
- <span class="fp-badge"><strong>Model</strong> build-small-hackathon/phase-3-gguf</span>
837
- <span class="fp-badge"><strong>~31.6B</strong> Q8 MoE (Nemotron-H)</span>
838
- <span class="fp-badge"><strong>Context</strong> up to 1M</span>
839
- <span class="fp-badge"><strong>Runtime</strong> llama.cpp on ZeroGPU</span>
840
- <span class="fp-badge"><strong>Build Small Hackathon</strong></span>
841
  </div>
842
  </div>
843
  """
844
 
 
 
 
 
 
 
 
 
 
 
 
 
845
  with gr.Blocks(title="First-Principle AI · Gotcha Arena", fill_width=True) as demo:
846
  with gr.Column(elem_classes=["fp-shell"]):
847
  gr.HTML(HERO)
@@ -852,29 +938,31 @@ with gr.Blocks(title="First-Principle AI · Gotcha Arena", fill_width=True) as d
852
  # ---------------- Tab 1: The Gauntlet ----------------
853
  with gr.Tab("🎯 The Gauntlet"):
854
  gr.HTML(
855
- '<div class="fp-note">Pick a trick question (or hit <strong>Surprise me</strong>), '
856
- 'run it, and see if the small model reasons past the trap. The verdict is an automatic '
857
- 'keyword check — the real proof is reading the answer.</div>'
858
  )
859
- with gr.Row():
860
- trap_dd = gr.Dropdown(
861
- choices=TRAP_TITLES,
862
- value=TRAP_TITLES[0],
863
- label="Trap deck",
864
- scale=4,
865
- )
866
- surprise = gr.Button("🎲 Surprise me", scale=1)
867
- with gr.Row():
868
- run_btn = gr.Button("▶ Run this trap", variant="primary", scale=2)
869
- reset_btn = gr.Button("Reset score", scale=1)
870
-
871
  scoreboard = gr.HTML(scoreboard_html(_new_score()))
872
-
873
  with gr.Row(equal_height=False):
874
- with gr.Column(scale=5, min_width=320):
 
 
 
 
 
 
 
 
 
 
 
 
 
875
  trap_card = gr.HTML(trap_card_html(TRAPS[0], revealed=False))
876
- with gr.Column(scale=6, min_width=360):
877
- answer_md = gr.Markdown("Run a trap to see how First-Principle AI handles it.")
 
 
878
  gauntlet_metrics = gr.Markdown(_metrics_markdown())
879
 
880
  # ---------------- Tab 2: Trap It Yourself ----------------
@@ -882,7 +970,7 @@ with gr.Blocks(title="First-Principle AI · Gotcha Arena", fill_width=True) as d
882
  gr.HTML(
883
  '<div class="fp-note"><strong>Two ways to play:</strong> '
884
  '<em>Trap the AI</em> — write your own trick question and try to fool it. '
885
- '<em>Blind-Spot Check</em> — paste any real plan or "should I X or Y?" decision and the '
886
  'model surfaces the hidden assumption you might be missing.</div>'
887
  )
888
  mode = gr.Radio(
@@ -908,7 +996,7 @@ with gr.Blocks(title="First-Principle AI · Gotcha Arena", fill_width=True) as d
908
  inputs=[own_input, mode],
909
  label="Try one",
910
  )
911
- own_answer = gr.Markdown("Your answer will appear here.")
912
  own_metrics = gr.Markdown(_metrics_markdown())
913
 
914
  # ---------------- Tab 3: Engine Room ----------------
@@ -932,14 +1020,11 @@ with gr.Blocks(title="First-Principle AI · Gotcha Arena", fill_width=True) as d
932
  status = gr.Markdown(_status_markdown())
933
 
934
  # ----- wiring -----
935
- trap_dd.change(fn=preview_trap, inputs=trap_dd, outputs=trap_card)
936
- surprise.click(fn=random_trap, inputs=None, outputs=trap_dd)
937
- run_btn.click(
938
- fn=run_trap,
939
- inputs=[trap_dd, score_state, max_tokens, temperature, top_p, repeat_penalty, system_prompt],
940
- outputs=[trap_card, answer_md, scoreboard, gauntlet_metrics, score_state],
941
- show_progress="minimal",
942
- )
943
  reset_btn.click(fn=reset_score, inputs=None, outputs=[scoreboard, score_state])
944
  ask_btn.click(
945
  fn=ask_own,
 
10
  import threading
11
  import time
12
  import urllib.request
13
+ from functools import partial
14
  from pathlib import Path
15
  from typing import Any
16
 
 
545
  rank = _rank(caught, total)
546
  return f"""
547
  <div class="fp-score">
548
+ <div class="fp-stat fp-stat-good"><div class="fp-stat-n">{caught}</div><div class="fp-stat-l">✅ Caught</div></div>
549
+ <div class="fp-stat fp-stat-bad"><div class="fp-stat-n">{missed}</div><div class="fp-stat-l">❌ Fooled</div></div>
550
+ <div class="fp-stat fp-stat-meh"><div class="fp-stat-n">{unclear}</div><div class="fp-stat-l">🤔 Unclear</div></div>
551
+ <div class="fp-stat fp-stat-rank"><div class="fp-stat-rank-n">{rank}</div><div class="fp-stat-l">{total} trap(s) run</div></div>
 
 
 
552
  </div>
553
  """
554
 
 
563
  </div>
564
  """
565
  return f"""
566
+ <div class="fp-qcard">
567
+ <div class="fp-qcat">{trap['emoji']} {trap['cat']}</div>
568
+ <div class="fp-qtitle">{trap['title']}</div>
569
+ <div class="fp-qtext">&ldquo;{trap['prompt']}&rdquo;</div>
570
  {reveal}
571
  </div>
572
  """
573
 
574
 
575
+ _BANNER = {
576
+ "idle": ("🎯", "Pick a trap", "Tap a card to challenge the model.", "fp-bn-idle"),
577
+ "thinking": ("⏳", "Reasoning…", "First run loads the model (~1–2 min); then it's quick.", "fp-bn-think"),
578
+ "caught": ("✅", "Caught the trap!", "First-Principle AI reasoned past the decoy.", "fp-bn-good"),
579
+ "missed": ("❌", "Fell for it", "The familiar decoy answer slipped through.", "fp-bn-bad"),
580
+ "unclear": ("🤔", "You be the judge", "Auto-check couldn't tell — read the answer.", "fp-bn-meh"),
581
+ "error": ("⚠️", "Runtime issue", "Generation didn't complete — details below.", "fp-bn-meh"),
582
  }
583
 
584
 
585
+ def verdict_banner_html(kind: str) -> str:
586
+ icon, label, sub, cls = _BANNER.get(kind, _BANNER["idle"])
587
+ return f"""
588
+ <div class="fp-banner {cls}">
589
+ <div class="fp-banner-ic">{icon}</div>
590
+ <div class="fp-banner-tx">
591
+ <div class="fp-banner-label">{label}</div>
592
+ <div class="fp-banner-sub">{sub}</div>
593
+ </div>
594
+ </div>
595
+ """
596
+
597
+
598
  def _split_think(text: str) -> tuple[str, str]:
599
  """Split a reasoning model's output into (reasoning, final answer)."""
600
  text = (text or "").strip()
 
630
  return "".join(parts)
631
 
632
 
633
+ def _answer_md(reasoning: str, answer: str) -> str:
634
+ return f"**First-Principle AI says:**\n\n{_render_reasoning(reasoning, answer)}"
 
 
635
 
636
 
637
  def _thinking_md() -> str:
 
701
  return random.choice(TRAP_TITLES)
702
 
703
 
704
+ def _pick_title(title: str) -> str:
705
+ """Zero-input helper: each trap button binds its own title via functools.partial."""
706
+ return title
707
+
708
+
709
  def run_trap(
710
  title: str,
711
  score: dict[str, int] | None,
 
717
  ):
718
  trap = TRAP_BY_TITLE.get(title)
719
  if not trap:
720
+ yield "", verdict_banner_html("idle"), "Pick a trap to begin.", scoreboard_html(score), _metrics_markdown(), score
721
  return
722
 
723
+ yield (
724
+ trap_card_html(trap, revealed=False),
725
+ verdict_banner_html("thinking"),
726
+ _thinking_md(),
727
+ scoreboard_html(score),
728
+ "Queued.",
729
+ score,
730
+ )
731
 
732
  try:
733
  text, meta = _generate(trap["prompt"], system_prompt, max_tokens, temperature, top_p, repeat_penalty)
 
747
 
748
  yield (
749
  trap_card_html(trap, revealed=True),
750
+ verdict_banner_html(verdict),
751
+ _answer_md(reasoning, answer),
752
  scoreboard_html(score),
753
  _metrics_markdown(meta),
754
  score,
755
  )
756
 
757
 
758
+ def run_random(
759
+ score: dict[str, int] | None,
760
+ max_tokens: int,
761
+ temperature: float,
762
+ top_p: float,
763
+ repeat_penalty: float,
764
+ system_prompt: str,
765
+ ):
766
+ title = random.choice(TRAP_TITLES)
767
+ yield from run_trap(title, score, max_tokens, temperature, top_p, repeat_penalty, system_prompt)
768
+
769
+
770
  def reset_score():
771
  s = _new_score()
772
  return scoreboard_html(s), s
 
803
  # ---------------------------------------------------------------------------
804
  CSS = """
805
  :root {
806
+ --fp-bg: #f3f4fb; --fp-panel: #ffffff; --fp-ink: #0f1222; --fp-muted: #5b6478;
807
+ --fp-line: #e3e7f0; --fp-accent: #5b4be6; --fp-accent2: #7c3aed; --fp-accent-d: #4338ca;
808
+ --fp-good: #15a34a; --fp-good-bg: #e7f9ee; --fp-bad: #dc2626; --fp-bad-bg: #fdecec;
809
+ --fp-meh: #c2700a; --fp-meh-bg: #fef3c7;
 
 
 
 
 
 
810
  }
811
  .gradio-container {
812
+ background:
813
+ radial-gradient(900px 360px at 100% -10%, #ece9ff 0%, transparent 55%),
814
+ radial-gradient(800px 300px at -10% 0%, #e6fbf1 0%, transparent 50%),
815
+ var(--fp-bg) !important;
816
+ color: var(--fp-ink) !important;
817
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif !important;
818
  }
819
+ .fp-shell { max-width: 1180px; margin: 0 auto; padding: 14px 14px 48px; }
820
+
821
+ /* hero */
822
  .fp-hero {
823
+ position: relative; overflow: hidden; border: 1px solid var(--fp-line);
824
+ background: linear-gradient(180deg, #ffffff, #f7f7ff);
825
+ border-radius: 20px; padding: 30px 30px 26px; margin-bottom: 16px;
826
+ box-shadow: 0 20px 50px rgba(20,20,60,.10);
 
 
827
  }
828
+ .fp-hero h1 { margin: 0 0 8px; font-size: 36px; line-height: 1.05; letter-spacing: -1px; font-weight: 850; color: var(--fp-ink) !important; }
829
+ .fp-hero h1 .fp-grad { color: var(--fp-accent) !important; }
830
+ .fp-hero .fp-tag { color: var(--fp-muted); font-size: 16.5px; line-height: 1.5; margin: 0 0 16px; max-width: 800px; }
831
+ .fp-hero .fp-tag strong { color: var(--fp-ink); font-weight: 800; }
832
  .fp-badges { display: flex; flex-wrap: wrap; gap: 8px; }
833
+ .fp-badge { border: 1px solid var(--fp-line); background: rgba(255,255,255,.85); color: var(--fp-muted); border-radius: 999px; padding: 6px 13px; font-size: 12.5px; }
834
+ .fp-badge strong { color: var(--fp-ink); font-weight: 700; }
835
+
836
+ /* tabs (fix invisible labels) */
837
+ .gradio-container .tab-nav { border-bottom: 1px solid var(--fp-line) !important; gap: 2px; }
838
+ .gradio-container .tab-nav button { color: var(--fp-muted) !important; font-weight: 650 !important; font-size: 15px !important; background: transparent !important; border: none !important; }
839
+ .gradio-container .tab-nav button.selected { color: var(--fp-accent) !important; border-bottom: 2px solid var(--fp-accent) !important; }
840
+
841
+ /* generic cleanup */
842
+ .gradio-container .block { border-color: var(--fp-line) !important; border-radius: 14px !important; box-shadow: none !important; background: transparent !important; }
843
+ .gradio-container .gr-group, .gradio-container .form { background: transparent !important; border: none !important; }
844
+ textarea, input { background: #fff !important; color: var(--fp-ink) !important; border-color: var(--fp-line) !important; }
845
+ .gradio-container code { background: #eef0f8 !important; color: #1c2030 !important; border-radius: 5px; padding: 1px 5px; }
846
+ .fp-note { border: 1px solid #d6dbff; background: #eef0ff; color: #3b3a8c; border-radius: 12px; padding: 11px 15px; font-size: 13.5px; line-height: 1.55; margin: 2px 0 14px; }
847
+ button.primary { background: linear-gradient(90deg, var(--fp-accent), var(--fp-accent2)) !important; border: none !important; color: #fff !important; font-weight: 700 !important; border-radius: 12px !important; }
848
+ button.primary:hover { filter: brightness(1.06); }
849
+
850
+ /* scoreboard stat tiles */
851
+ .fp-score { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 2px 0 14px; }
852
+ .fp-stat { border: 1px solid var(--fp-line); background: var(--fp-panel); border-radius: 14px; padding: 12px 14px; box-shadow: 0 6px 16px rgba(20,20,60,.05); }
853
+ .fp-stat-n { font-size: 26px; font-weight: 850; line-height: 1; }
854
+ .fp-stat-l { font-size: 12px; color: var(--fp-muted); margin-top: 6px; font-weight: 600; }
855
+ .fp-stat-good .fp-stat-n { color: var(--fp-good); }
856
+ .fp-stat-bad .fp-stat-n { color: var(--fp-bad); }
857
+ .fp-stat-meh .fp-stat-n { color: var(--fp-meh); }
858
+ .fp-stat-rank-n { font-size: 15.5px; font-weight: 800; color: var(--fp-ink); line-height: 1.18; }
859
+
860
+ /* trap card grid (buttons) */
861
+ .fp-deck-title { font-size: 12.5px; font-weight: 700; color: var(--fp-muted); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0 6px; }
862
+ .fp-trapcard { min-height: 58px !important; white-space: normal !important; text-align: left !important; line-height: 1.25 !important;
863
+ border: 1px solid var(--fp-line) !important; background: var(--fp-panel) !important; color: var(--fp-ink) !important;
864
+ border-radius: 14px !important; font-weight: 650 !important; font-size: 14px !important; padding: 12px 14px !important;
865
+ box-shadow: 0 4px 12px rgba(20,20,60,.05) !important;
866
+ transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease !important; }
867
+ .fp-trapcard:hover { transform: translateY(-2px) !important; border-color: var(--fp-accent) !important; box-shadow: 0 12px 24px rgba(91,75,230,.18) !important; }
868
+ .fp-ghost { background: #fff !important; border: 1px solid var(--fp-line) !important; color: var(--fp-ink) !important; border-radius: 12px !important; font-weight: 650 !important; }
869
+ .fp-ghost:hover { border-color: var(--fp-accent) !important; color: var(--fp-accent) !important; }
870
+
871
+ /* verdict banner */
872
+ .fp-banner { display: flex; align-items: center; gap: 14px; border-radius: 16px; padding: 16px 18px; margin: 2px 0 12px;
873
+ border: 1px solid var(--fp-line); animation: fpPop .28s cubic-bezier(.2,.8,.2,1); }
874
+ @keyframes fpPop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
875
+ .fp-banner-ic { font-size: 30px; line-height: 1; }
876
+ .fp-banner-label { font-size: 19px; font-weight: 800; line-height: 1.15; }
877
+ .fp-banner-sub { font-size: 13.5px; color: var(--fp-muted); margin-top: 2px; }
878
+ .fp-bn-idle { background: #f3f4fb; }
879
+ .fp-bn-think { background: #eef0ff; border-color: #d6dbff; }
880
+ .fp-bn-good { background: var(--fp-good-bg); border-color: #bbedce; }
881
+ .fp-bn-good .fp-banner-label { color: var(--fp-good); }
882
+ .fp-bn-bad { background: var(--fp-bad-bg); border-color: #f6c9c9; }
883
+ .fp-bn-bad .fp-banner-label { color: var(--fp-bad); }
884
+ .fp-bn-meh { background: var(--fp-meh-bg); border-color: #f5dfa0; }
885
+ .fp-bn-meh .fp-banner-label { color: var(--fp-meh); }
886
+
887
+ /* active question card */
888
+ .fp-qcard { border: 1px solid var(--fp-line); background: var(--fp-panel); border-radius: 16px; padding: 18px 20px; box-shadow: 0 8px 22px rgba(20,20,60,.06); }
889
+ .fp-qcat { font-size: 12px; font-weight: 700; color: var(--fp-accent); text-transform: uppercase; letter-spacing: .5px; }
890
+ .fp-qtitle { font-size: 22px; font-weight: 800; margin: 5px 0 10px; letter-spacing: -.3px; }
891
+ .fp-qtext { font-size: 17px; line-height: 1.5; color: var(--fp-ink); font-style: italic; }
892
+ .fp-reveal { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--fp-line); font-size: 13.5px; color: var(--fp-muted); line-height: 1.55; }
893
+ .fp-reveal strong { color: var(--fp-accent); }
894
+ .fp-reveal .fp-wrong { margin-top: 7px; }
895
+ .fp-reveal .fp-wrong strong { color: var(--fp-bad); }
896
+
897
+ /* answer panel */
898
+ .fp-answer { border: 1px solid var(--fp-line); background: var(--fp-panel); border-radius: 16px; padding: 4px 18px; box-shadow: 0 8px 22px rgba(20,20,60,.06); }
899
+ .fp-answer details summary { cursor: pointer; color: var(--fp-accent); font-weight: 650; margin: 8px 0; }
900
+ .fp-answer details { border-top: 1px dashed var(--fp-line); margin-top: 10px; padding-top: 6px; }
901
+
902
+ @media (max-width: 920px) { .fp-hero h1 { font-size: 27px; } .fp-score { grid-template-columns: repeat(2, 1fr); } }
903
  """
904
 
905
  HERO = """
906
  <div class="fp-hero">
907
+ <h1>🎯 First-Principle AI <span class="fp-grad">· Gotcha Arena</span></h1>
908
+ <p class="fp-tag">A <strong>small</strong> reasoning model that reads the question, not the pattern.
909
  Throw it the trick questions that fool the big models — and watch it catch the catch.</p>
910
  <div class="fp-badges">
911
+ <span class="fp-badge"><strong>~31.6B</strong> Q8 MoE · Nemotron-H</span>
912
+ <span class="fp-badge"><strong>Runs local</strong> · llama.cpp on ZeroGPU</span>
913
+ <span class="fp-badge"><strong>1M</strong> context</span>
914
+ <span class="fp-badge">🌲 Thousand Token Wood</span>
 
915
  </div>
916
  </div>
917
  """
918
 
919
+ SHORT_LABELS = {
920
+ "carwash": "🚗 The 50-Meter Car Wash",
921
+ "ev": "🔌 The Almost-Empty EV",
922
+ "feathers": "🪶 Feathers vs. Steel",
923
+ "moses": "🛶 Moses & the Ark",
924
+ "batball": "⚾ The Bat and the Ball",
925
+ "survivors": "✈️ Bury the Survivors",
926
+ "sally": "👧 Sally's Sisters",
927
+ "brain": "🧠 The 10% Brain Myth",
928
+ "sheep": "🐑 All But Nine",
929
+ }
930
+
931
  with gr.Blocks(title="First-Principle AI · Gotcha Arena", fill_width=True) as demo:
932
  with gr.Column(elem_classes=["fp-shell"]):
933
  gr.HTML(HERO)
 
938
  # ---------------- Tab 1: The Gauntlet ----------------
939
  with gr.Tab("🎯 The Gauntlet"):
940
  gr.HTML(
941
+ '<div class="fp-note">Tap a trap card to throw it at the model — or hit '
942
+ '<strong>🎲 Surprise me</strong>. The banner shows a quick auto-verdict; '
943
+ 'the real proof is the answer underneath.</div>'
944
  )
 
 
 
 
 
 
 
 
 
 
 
 
945
  scoreboard = gr.HTML(scoreboard_html(_new_score()))
 
946
  with gr.Row(equal_height=False):
947
+ with gr.Column(scale=5, min_width=300):
948
+ gr.HTML('<div class="fp-deck-title">The trap deck — tap to play</div>')
949
+ trap_events = []
950
+ for _row in range(0, len(TRAPS), 2):
951
+ with gr.Row():
952
+ for _trap in TRAPS[_row:_row + 2]:
953
+ _b = gr.Button(SHORT_LABELS[_trap["id"]], elem_classes=["fp-trapcard"])
954
+ _ts = gr.State(_trap["title"])
955
+ trap_events.append((_ts, _b))
956
+ with gr.Row():
957
+ surprise = gr.Button("🎲 Surprise me", elem_classes=["fp-ghost"])
958
+ reset_btn = gr.Button("↺ Reset score", elem_classes=["fp-ghost"])
959
+ with gr.Column(scale=7, min_width=360):
960
+ verdict_banner = gr.HTML(verdict_banner_html("idle"))
961
  trap_card = gr.HTML(trap_card_html(TRAPS[0], revealed=False))
962
+ answer_md = gr.Markdown(
963
+ "Tap a trap card to see how First-Principle AI handles it.",
964
+ elem_classes=["fp-answer"],
965
+ )
966
  gauntlet_metrics = gr.Markdown(_metrics_markdown())
967
 
968
  # ---------------- Tab 2: Trap It Yourself ----------------
 
970
  gr.HTML(
971
  '<div class="fp-note"><strong>Two ways to play:</strong> '
972
  '<em>Trap the AI</em> — write your own trick question and try to fool it. '
973
+ '<em>Blind-Spot Check</em> — paste a real plan or "should I X or Y?" decision and the '
974
  'model surfaces the hidden assumption you might be missing.</div>'
975
  )
976
  mode = gr.Radio(
 
996
  inputs=[own_input, mode],
997
  label="Try one",
998
  )
999
+ own_answer = gr.Markdown("Your answer will appear here.", elem_classes=["fp-answer"])
1000
  own_metrics = gr.Markdown(_metrics_markdown())
1001
 
1002
  # ---------------- Tab 3: Engine Room ----------------
 
1020
  status = gr.Markdown(_status_markdown())
1021
 
1022
  # ----- wiring -----
1023
+ run_outputs = [trap_card, verdict_banner, answer_md, scoreboard, gauntlet_metrics, score_state]
1024
+ _shared = [score_state, max_tokens, temperature, top_p, repeat_penalty, system_prompt]
1025
+ for _ts, _btn in trap_events:
1026
+ _btn.click(fn=run_trap, inputs=[_ts, *_shared], outputs=run_outputs, show_progress="minimal")
1027
+ surprise.click(fn=run_random, inputs=_shared, outputs=run_outputs, show_progress="minimal")
 
 
 
1028
  reset_btn.click(fn=reset_score, inputs=None, outputs=[scoreboard, score_state])
1029
  ask_btn.click(
1030
  fn=ask_own,