AlokBharadwaj commited on
Commit
f2d1c33
Β·
1 Parent(s): 54b4fa6

Font color visible

Browse files
Files changed (1) hide show
  1. app.py +30 -26
app.py CHANGED
@@ -61,28 +61,33 @@ def _render_view(view, token_logprobs, semantic_result, answer):
61
  # Status banners
62
  # ---------------------------------------------------------------------------
63
 
64
- _STATUS_BASE = (
65
- "display:flex; align-items:center; gap:10px; padding:8px 12px; "
66
- "border-radius:6px; font-size:0.9em; color:{fg};"
67
- )
68
- _STATUS_COMPUTING = (
69
- f"<div style='{_STATUS_BASE.format(fg='#5d4a00')} background:#fff8e1; border:1px solid #f0c040;'>"
70
- "<span style='font-size:1.3em;'>⏳</span>"
71
- "<span>Computing semantic entropy in the background β€” this may take 30–120 s. "
72
- "Please wait, or view <strong>Token probability</strong> below.</span>"
73
- "</div>"
 
 
 
 
 
 
 
74
  )
75
- _STATUS_READY = (
76
- f"<div style='{_STATUS_BASE.format(fg='#14532d')} background:#e6f4ea; border:1px solid #34a853;'>"
77
- "<span style='font-size:1.3em;'>βœ…</span>"
78
- "<span>Semantic entropy ready β€” click <strong>Show probabilities</strong> to view.</span>"
79
- "</div>"
80
  )
81
- _STATUS_FAILED = (
82
- f"<div style='{_STATUS_BASE.format(fg='#8a1c1c')} background:#fdecea; border:1px solid #e08080;'>"
83
- "<span style='font-size:1.3em;'>⚠️</span>"
84
- "<span>Semantic entropy computation failed. Token probability view is still available.</span>"
85
- "</div>"
86
  )
87
 
88
 
@@ -293,12 +298,11 @@ with gr.Blocks(title="Probabot") as demo:
293
  user_input.submit(fn=None, inputs=None, outputs=None, cancels=_running_pipelines)
294
 
295
  # Manual cancel button: abort the running pipeline and reset the UI.
296
- _STATUS_CANCELLED = (
297
- "<div style='display:flex; align-items:center; gap:10px; padding:8px 12px; "
298
- "background:#f3f3f3; border:1px solid #bbb; border-radius:6px; font-size:0.9em;'>"
299
- "<span style='font-size:1.3em;'>πŸ›‘</span>"
300
- "<span>Semantic entropy computation cancelled. Token probability is still "
301
- "available via the toggle.</span></div>"
302
  )
303
 
304
  def _on_cancel():
 
61
  # Status banners
62
  # ---------------------------------------------------------------------------
63
 
64
+ def _status_banner(icon, text, bg, border, fg):
65
+ # Set the color directly on the text span with !important so Gradio's theme
66
+ # CSS can't override it to a light color.
67
+ return (
68
+ f"<div style='display:flex; align-items:center; gap:10px; padding:8px 12px; "
69
+ f"border-radius:6px; font-size:0.95em; background:{bg}; border:1px solid {border};'>"
70
+ f"<span style='font-size:1.3em;'>{icon}</span>"
71
+ f"<span style='color:{fg} !important; font-weight:500;'>{text}</span>"
72
+ "</div>"
73
+ )
74
+
75
+
76
+ _STATUS_COMPUTING = _status_banner(
77
+ "⏳",
78
+ "Computing semantic entropy in the background β€” this may take 30–120 s. "
79
+ "Please wait, or view <strong style='color:#3a2e00 !important;'>Token probability</strong> below.",
80
+ bg="#fff8e1", border="#e0a800", fg="#3a2e00",
81
  )
82
+ _STATUS_READY = _status_banner(
83
+ "βœ…",
84
+ "Semantic entropy ready β€” click <strong style='color:#0b3d1a !important;'>Show probabilities</strong> to view.",
85
+ bg="#e6f4ea", border="#2e7d32", fg="#0b3d1a",
 
86
  )
87
+ _STATUS_FAILED = _status_banner(
88
+ "⚠️",
89
+ "Semantic entropy computation failed. Token probability view is still available.",
90
+ bg="#fdecea", border="#c62828", fg="#5c1010",
 
91
  )
92
 
93
 
 
298
  user_input.submit(fn=None, inputs=None, outputs=None, cancels=_running_pipelines)
299
 
300
  # Manual cancel button: abort the running pipeline and reset the UI.
301
+ _STATUS_CANCELLED = _status_banner(
302
+ "πŸ›‘",
303
+ "Semantic entropy computation cancelled. Token probability is still "
304
+ "available via the toggle.",
305
+ bg="#f0f0f0", border="#888", fg="#222",
 
306
  )
307
 
308
  def _on_cancel():