anotheruserishere commited on
Commit
9623bff
Β·
verified Β·
1 Parent(s): 6de4016

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +58 -23
app.py CHANGED
@@ -701,16 +701,54 @@ def initial_load(model_id: str, system_prompt: str, user_prompt: str, s: Session
701
 
702
  # ── Gradio UI ─────────────────────────────────────────────────────────────
703
  CSS = """
704
- .gradio-container { max-width: 100% !important; }
705
- /* Compact top control row */
706
- #topbar .gr-textbox textarea, #topbar .gr-textbox input { font-size: 12px !important; padding: 4px 6px !important; }
707
- #topbar label { font-size: 11px !important; }
708
- #topbar .gr-form { padding: 4px !important; }
709
- .pane { border: 1px solid #444; border-radius: 4px; background: #0d1117; color: #c9d1d9;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace; font-size: 12px; }
711
- .pane h3 { margin: 0; padding: 4px 8px; background: #161b22; border-bottom: 1px solid #30363d;
712
- font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; color: #8b949e; }
713
- .pane-body { padding: 6px 8px; max-height: 420px; overflow: auto; }
714
  .pane-body.scroll { overflow: auto; }
715
  .dim { color: #6e7681; }
716
  .context-text { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
@@ -735,19 +773,16 @@ pre.spark { margin: 0; font-size: 11px; line-height: 1.1; }
735
  .prompt { color: #64D32A; }
736
  """
737
 
738
- HELP = """\
739
- **Commands** (REPL-style):
740
- `1`–`N` commit future Β· `1,5` commit + keep 5 tokens Β· `i <text>` inject Β·
741
- `h * | h L | h L H` head-scan Β· `top R1,R2,...` rank-pick tokens Β·
742
- `rew N` rewind Β· `spark <tok> [lo:hi]` rank scatter Β· `w N` width Β· `l N` length Β·
743
- `mute L H` / `unmute L H` / `unmute all` / `muted` Β·
744
- `r` refresh futures Β· `s` save log Β· `q` (no-op)
745
- """
746
 
747
  def build_ui():
748
  with gr.Blocks(title="Cartogemma", css=CSS, theme=gr.themes.Base()) as demo:
749
- gr.Markdown("# Cartogemma \n*Mechanistic probe (logit lens Β· head map Β· futures Β· rank sparkline) "
750
- "on the Gemma-3 family. Layout faithful to `cartographer3.py`.*")
751
 
752
  session = gr.State(Session())
753
 
@@ -782,12 +817,12 @@ def build_ui():
782
  spark_pane = gr.HTML(value="<div class='pane'><h3>Sparkline</h3>"
783
  "<div class='pane-body'><i>Run <code>spark &lt;token&gt;</code>.</i></div></div>")
784
 
785
- gr.Markdown(HELP)
786
 
787
- with gr.Row():
788
  cmd = gr.Textbox(label="CMD", placeholder="1-N | h * | top 1000,3,1 | spark the | mute 5 2 | …",
789
- scale=8, autofocus=True, lines=1, max_lines=1)
790
- run_btn = gr.Button("Run", scale=1, variant="primary")
791
 
792
  status = gr.HTML(value="<div class='pane'><h3>Transcript</h3>"
793
  "<div class='pane-body dim'>Ready.</div></div>")
 
701
 
702
  # ── Gradio UI ─────────────────────────────────────────────────────────────
703
  CSS = """
704
+ /* ── Global tightening ── */
705
+ .gradio-container { max-width: 100% !important; padding: 8px 12px !important; }
706
+ .gradio-container .main { padding: 0 !important; gap: 6px !important; }
707
+ .gradio-container .gap, .gradio-container .form { gap: 6px !important; }
708
+ .gradio-container .block { padding: 4px !important; border-radius: 4px !important; }
709
+ .gradio-container .gr-block { padding: 0 !important; }
710
+
711
+ /* ── Header: kill the giant title margins ── */
712
+ #hdr h1 { font-size: 18px !important; margin: 0 !important; padding: 0 !important; line-height: 1.2 !important; }
713
+ #hdr p, #hdr em { font-size: 11px !important; margin: 0 !important; padding: 0 !important;
714
+ color: #8b949e !important; line-height: 1.2 !important; }
715
+ #hdr { margin: 0 !important; padding: 4px 0 !important; }
716
+
717
+ /* ── Top bar: compact textboxes ── */
718
+ #topbar { gap: 6px !important; }
719
+ #topbar > div { padding: 0 !important; }
720
+ #topbar textarea, #topbar input[type="text"] {
721
+ font-size: 12px !important; padding: 4px 6px !important; min-height: 28px !important;
722
+ line-height: 1.3 !important;
723
+ }
724
+ #topbar label, #topbar .gr-text-input label, #topbar span[data-testid="block-label"] {
725
+ font-size: 10px !important; padding: 0 0 2px 0 !important; margin: 0 !important;
726
+ text-transform: uppercase; letter-spacing: 0.5px; color: #8b949e !important;
727
+ }
728
+ #topbar button { min-height: 56px !important; align-self: stretch !important;
729
+ font-size: 13px !important; padding: 4px 8px !important; }
730
+
731
+ /* ── CMD bar tightening ── */
732
+ #cmdbar textarea, #cmdbar input[type="text"] {
733
+ font-size: 12px !important; padding: 4px 8px !important; min-height: 28px !important;
734
+ font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace !important;
735
+ }
736
+ #cmdbar label, #cmdbar span[data-testid="block-label"] {
737
+ font-size: 10px !important; color: #8b949e !important; margin: 0 !important; padding: 0 0 2px 0 !important;
738
+ }
739
+ #cmdbar button { min-height: 36px !important; font-size: 12px !important; }
740
+
741
+ /* ── Help line (small, dim) ── */
742
+ #help { font-size: 10.5px !important; color: #8b949e !important; margin: 2px 0 !important; padding: 0 !important; }
743
+ #help code { font-size: 10.5px !important; padding: 0 2px !important; background: #161b22 !important; }
744
+ #help p { margin: 0 !important; line-height: 1.5 !important; }
745
+
746
+ /* ── Panes ── */
747
+ .pane { border: 1px solid #30363d; border-radius: 4px; background: #0d1117; color: #c9d1d9;
748
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace; font-size: 12px; }
749
+ .pane h3 { margin: 0; padding: 3px 8px; background: #161b22; border-bottom: 1px solid #30363d;
750
+ font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; color: #8b949e; }
751
+ .pane-body { padding: 5px 8px; max-height: 440px; overflow: auto; }
752
  .pane-body.scroll { overflow: auto; }
753
  .dim { color: #6e7681; }
754
  .context-text { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
 
773
  .prompt { color: #64D32A; }
774
  """
775
 
776
+ HELP = (
777
+ "`1-N` commit Β· `1,5` commit+keep Β· `i <text>` inject Β· `h * | h L | h L H` scan Β· "
778
+ "`top R1,R2,…` rank-pick Β· `rew N` Β· `spark <tok> [lo:hi]` Β· `w N` width Β· `l N` len Β· "
779
+ "`mute L H` Β· `unmute L H` Β· `unmute all` Β· `muted` Β· `r` refresh Β· `s` save"
780
+ )
 
 
 
781
 
782
  def build_ui():
783
  with gr.Blocks(title="Cartogemma", css=CSS, theme=gr.themes.Base()) as demo:
784
+ gr.Markdown("# Cartogemma \n*Mechanistic probe β€” logit lens Β· head map Β· futures Β· rank sparkline β€” "
785
+ "on the Gemma-3 family.*", elem_id="hdr")
786
 
787
  session = gr.State(Session())
788
 
 
817
  spark_pane = gr.HTML(value="<div class='pane'><h3>Sparkline</h3>"
818
  "<div class='pane-body'><i>Run <code>spark &lt;token&gt;</code>.</i></div></div>")
819
 
820
+ gr.Markdown(HELP, elem_id="help")
821
 
822
+ with gr.Row(elem_id="cmdbar"):
823
  cmd = gr.Textbox(label="CMD", placeholder="1-N | h * | top 1000,3,1 | spark the | mute 5 2 | …",
824
+ scale=10, autofocus=True, lines=1, max_lines=1, container=True)
825
+ run_btn = gr.Button("Run", scale=1, variant="primary", min_width=70)
826
 
827
  status = gr.HTML(value="<div class='pane'><h3>Transcript</h3>"
828
  "<div class='pane-body dim'>Ready.</div></div>")