realArceus commited on
Commit
b43b260
·
verified ·
1 Parent(s): 415770d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -278
app.py CHANGED
@@ -153,285 +153,11 @@ def build_trace(problem, displayed, first_fail, done=False):
153
  return f"{rows}{summary}"
154
 
155
 
156
- # ── CSS (SaaS / Modern Professional Upgrade) ──────────────────────────────────
157
  CSS = """
158
- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
159
 
160
- /* Globals */
161
  *, *::before, *::after { box-sizing: border-box; }
162
  body, .gradio-container, .gradio-container * {
163
- font-family: 'Inter', -apple-system, sans-serif !important;
164
- }
165
- .gradio-container {
166
- background-color: #f8fafc !important;
167
- max-width: 1280px !important;
168
- }
169
-
170
- /* Header */
171
- .twt-header {
172
- text-align: center;
173
- padding: 3rem 1rem 2rem;
174
- margin-bottom: 2.5rem;
175
- background: transparent;
176
- border-bottom: 1px solid #e2e8f0;
177
- }
178
- .twt-title {
179
- font-size: 2.75rem;
180
- font-weight: 800;
181
- letter-spacing: -0.04em;
182
- color: #0f172a;
183
- font-family: 'JetBrains Mono', monospace !important;
184
- margin-bottom: 0.5rem;
185
- }
186
- .twt-title span {
187
- background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
188
- -webkit-background-clip: text;
189
- -webkit-text-fill-color: transparent;
190
- }
191
- .twt-sub {
192
- font-size: 0.85rem;
193
- color: #64748b;
194
- letter-spacing: 0.05em;
195
- font-weight: 500;
196
- }
197
-
198
- /* Typography & Labels */
199
- .input-label, .panel-label {
200
- font-size: 0.75rem;
201
- font-weight: 700;
202
- color: #475569;
203
- letter-spacing: 0.1em;
204
- text-transform: uppercase;
205
- margin-bottom: 0.75rem;
206
- display: block;
207
- }
208
- .panel-label {
209
- padding-bottom: 0.5rem;
210
- border-bottom: 2px solid #e2e8f0;
211
- }
212
-
213
- /* Inputs & Forms */
214
- textarea {
215
- background: #ffffff !important;
216
- border: 1px solid #cbd5e1 !important;
217
- border-radius: 12px !important;
218
- color: #0f172a !important;
219
- font-size: 0.95rem !important;
220
- line-height: 1.6 !important;
221
- padding: 1rem !important;
222
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
223
- transition: all 0.2s ease-in-out !important;
224
- }
225
- textarea:focus {
226
- border-color: #7c3aed !important;
227
- box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15) !important;
228
- outline: none !important;
229
- }
230
- textarea::placeholder { color: #94a3b8 !important; }
231
-
232
- /* Primary Button */
233
- button.primary {
234
- background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
235
- color: #ffffff !important;
236
- font-weight: 600 !important;
237
- border: none !important;
238
- border-radius: 10px !important;
239
- padding: 0.75rem 1.5rem !important;
240
- font-size: 0.95rem !important;
241
- letter-spacing: 0.02em !important;
242
- box-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.3), 0 2px 4px -1px rgba(124, 58, 237, 0.2) !important;
243
- transition: all 0.2s ease !important;
244
- cursor: pointer !important;
245
- width: 100% !important;
246
- }
247
- button.primary:hover {
248
- transform: translateY(-2px) !important;
249
- box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.3), 0 4px 6px -2px rgba(124, 58, 237, 0.2) !important;
250
- }
251
- button.primary:active {
252
- transform: translateY(0) !important;
253
- }
254
-
255
- /* Step Cards */
256
- .step-card {
257
- display: flex;
258
- align-items: flex-start;
259
- gap: 1rem;
260
- padding: 1.25rem;
261
- margin-bottom: 0.75rem;
262
- background: #ffffff;
263
- border: 1px solid #e2e8f0;
264
- border-radius: 12px;
265
- font-size: 0.9rem;
266
- line-height: 1.6;
267
- animation: fadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
268
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
269
- transition: box-shadow 0.2s ease, border-color 0.2s ease;
270
- }
271
- .step-card:hover {
272
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
273
- border-color: #cbd5e1;
274
- }
275
- .step-card.step-fault {
276
- border: 1px solid #fecaca;
277
- background: #fff1f2;
278
- }
279
- .step-card.step-fault:hover {
280
- border-color: #fca5a5;
281
- }
282
-
283
- @keyframes fadeUp {
284
- from { opacity: 0; transform: translateY(12px); }
285
- to { opacity: 1; transform: translateY(0); }
286
- }
287
-
288
- .step-icon {
289
- font-size: 1.1rem;
290
- flex-shrink: 0;
291
- margin-top: 2px;
292
- }
293
- .step-text {
294
- flex: 1;
295
- color: #1e293b;
296
- }
297
-
298
- /* Badges */
299
- .badge {
300
- flex-shrink: 0;
301
- font-size: 0.65rem;
302
- font-weight: 700;
303
- font-family: 'JetBrains Mono', monospace !important;
304
- letter-spacing: 0.05em;
305
- padding: 0.25rem 0.75rem;
306
- border-radius: 999px; /* Pill shape */
307
- align-self: flex-start;
308
- margin-top: 2px;
309
- }
310
- .badge-ok { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
311
- .badge-fail { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
312
- .badge-final { background: #f3e8ff; color: #7c3aed; border: 1px solid #d8b4fe; }
313
-
314
- /* Trace Panel */
315
- .trace-row {
316
- display: flex;
317
- align-items: center;
318
- gap: 0.75rem;
319
- font-size: 0.8rem;
320
- color: #334155;
321
- font-family: 'JetBrains Mono', monospace !important;
322
- padding: 0.5rem 0;
323
- border-bottom: 1px solid #f1f5f9;
324
- }
325
- .trace-conf {
326
- color: #94a3b8;
327
- font-weight: 500;
328
- }
329
- .dot {
330
- width: 10px; height: 10px;
331
- border-radius: 50%;
332
- flex-shrink: 0;
333
- }
334
- .dot-ok { background: #10b981; box-shadow: 0 0 0 3px #d1fae5; }
335
- .dot-fail { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
336
- .dot-final { background: #8b5cf6; box-shadow: 0 0 0 3px #ede9fe; }
337
-
338
- .trace-summary {
339
- margin-top: 1.5rem;
340
- padding-top: 1rem;
341
- border-top: 1px solid #e2e8f0;
342
- }
343
- .trace-label {
344
- font-size: 0.7rem;
345
- font-weight: 700;
346
- color: #475569;
347
- text-transform: uppercase;
348
- letter-spacing: 0.1em;
349
- margin-bottom: 0.5rem;
350
- }
351
- .trace-bar-bg {
352
- background: #e2e8f0;
353
- border-radius: 999px;
354
- height: 8px;
355
- overflow: hidden;
356
- }
357
- .trace-bar {
358
- height: 100%;
359
- border-radius: 999px;
360
- transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
361
- }
362
- .trace-pct {
363
- font-size: 0.75rem;
364
- color: #334155;
365
- margin-top: 0.4rem;
366
- font-family: 'JetBrains Mono', monospace !important;
367
- font-weight: 600;
368
- }
369
-
370
- /* System Messages */
371
- .msg {
372
- padding: 1rem 1.25rem;
373
- border-radius: 10px;
374
- font-size: 0.85rem;
375
- font-weight: 500;
376
- }
377
- .msg.warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
378
- .msg.error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
379
- .msg.empty {
380
- color: #94a3b8;
381
- font-size: 0.85rem;
382
- font-family: 'JetBrains Mono', monospace !important;
383
- padding: 1.5rem 1rem;
384
- text-align: center;
385
- border: 1px dashed #cbd5e1;
386
- border-radius: 12px;
387
- }
388
-
389
- /* Gradio Overrides */
390
- .gradio-container .prose { color: #1e293b !important; }
391
- .gr-box, .gr-form { background: transparent !important; border: none !important; }
392
- """
393
-
394
- # ── Layout ────────────────────────────────────────────────────────────────────
395
- HEADER = """
396
- <div class='twt-header'>
397
- <div class='twt-title'>Think<span>While</span>Thinking</div>
398
- <div class='twt-sub'>Real-time reasoning failure detection · Step-level process supervision</div>
399
- </div>
400
- """
401
-
402
- EXAMPLES = [
403
- "If a bat and a ball cost $1.10 in total, and the bat costs $1 more than the ball, how much does the ball cost?",
404
- "A farmer has 17 sheep. All but 9 die. How many sheep are left?",
405
- "What is 15% of 80? Then add that to 25% of 60.",
406
- "If you have a 3-gallon jug and a 5-gallon jug, how do you measure exactly 4 gallons?",
407
- ]
408
-
409
- with gr.Blocks(css=CSS, title="ThinkWhileThinking") as demo:
410
- gr.HTML(HEADER)
411
- with gr.Row():
412
- with gr.Column(scale=2):
413
- gr.HTML("<div class='input-label'>Problem</div>")
414
- problem_input = gr.Textbox(
415
- placeholder="Enter a math, logic, or reasoning problem...",
416
- lines=5,
417
- show_label=False,
418
- )
419
- run_btn = gr.Button("▶ Analyze Reasoning", variant="primary")
420
- gr.Examples(examples=EXAMPLES, inputs=problem_input, label="Try an example")
421
- with gr.Column(scale=3):
422
- with gr.Row():
423
- with gr.Column(scale=3):
424
- gr.HTML("<div class='panel-label'>Chain of Thought · Step Scores</div>")
425
- cot_output = gr.HTML(
426
- value="<div class='msg empty'>// awaiting problem input</div>"
427
- )
428
- with gr.Column(scale=1):
429
- gr.HTML("<div class='panel-label'>Step Trace</div>")
430
- trace_output = gr.HTML(
431
- value="<div class='msg empty'>// trace</div>"
432
- )
433
- raw_output = gr.Textbox(visible=False)
434
- run_btn.click(fn=run_twt, inputs=[problem_input], outputs=[raw_output, cot_output, trace_output])
435
- problem_input.submit(fn=run_twt, inputs=[problem_input], outputs=[raw_output, cot_output, trace_output])
436
-
437
- demo.launch()
 
153
  return f"{rows}{summary}"
154
 
155
 
156
+ # ── CSS (Claude + Apple Aesthetic) ────────────────────────────────────────────
157
  CSS = """
158
+ @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');
159
 
160
+ /* Base System Typography & Resets */
161
  *, *::before, *::after { box-sizing: border-box; }
162
  body, .gradio-container, .gradio-container * {
163
+ font-family: -apple-