Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
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 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 710 |
font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace; font-size: 12px; }
|
| 711 |
-
.pane h3 { margin: 0; padding:
|
| 712 |
-
font-size:
|
| 713 |
-
.pane-body { padding:
|
| 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 |
-
*
|
| 740 |
-
`
|
| 741 |
-
`
|
| 742 |
-
|
| 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
|
| 750 |
-
"on the Gemma-3 family.
|
| 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 <token></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=
|
| 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 <token></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>")
|