ZhouChuYue commited on
Commit
1d93c0f
ยท
1 Parent(s): 7fd2561

feat: UI overhaul with glassmorphism and modern styling

Browse files
Files changed (1) hide show
  1. app.py +219 -111
app.py CHANGED
@@ -172,77 +172,174 @@ def textbook_exercise(knowledge_point: str, difficulty: str):
172
  # ============================================================================
173
 
174
  custom_css = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  .gradio-container {
176
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
177
- background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
 
178
  }
179
 
 
180
  .main-title {
181
- font-weight: 700 !important;
182
- font-size: 2.2rem !important;
183
- background: linear-gradient(90deg, #e94560, #f39c12, #00d9ff) !important;
 
184
  -webkit-background-clip: text !important;
185
  -webkit-text-fill-color: transparent !important;
186
- background-clip: text !important;
187
  text-align: center !important;
 
 
188
  }
189
 
190
  .subtitle {
191
  text-align: center !important;
192
- color: #94a3b8 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  font-size: 1rem !important;
194
- margin-bottom: 1.5rem !important;
 
 
 
 
 
 
195
  }
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  .gr-button-primary {
198
- background: linear-gradient(135deg, #e94560 0%, #f39c12 100%) !important;
199
  border: none !important;
 
200
  font-weight: 600 !important;
 
 
201
  }
202
 
203
  .gr-button-primary:hover {
204
- transform: translateY(-2px) !important;
205
- box-shadow: 0 8px 25px rgba(233, 69, 96, 0.4) !important;
206
  }
207
 
208
  .gr-button-secondary {
209
- background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%) !important;
210
- border: none !important;
211
- color: white !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  }
213
 
214
- footer {
215
- display: none !important;
 
 
 
 
 
 
216
  }
217
  """
218
 
219
- with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css) as demo:
220
  gr.HTML('<h1 class="main-title">๐Ÿงฎ UltraData-Math L3 Generator</h1>')
221
- gr.HTML('<p class="subtitle">LLM-based Mathematical Data Synthesis Tool</p>')
222
 
223
  with gr.Tabs():
224
  # Q&A Synthesis Tab
225
  with gr.TabItem("๐Ÿ“ Q&A Synthesis"):
226
- gr.Markdown("ๆ นๆฎๆ•ฐๅญฆๅ†…ๅฎน็”Ÿๆˆ้—ฎ็ญ”ๅฏน๏ผŒๆŒ‰ๆ•™่‚ฒ้šพๅบฆๅˆ†็บงใ€‚")
227
- with gr.Row():
228
- with gr.Column():
229
- qa_input = gr.Textbox(
230
- label="Input Mathematical Content",
231
- placeholder="Enter mathematical content here...",
232
- lines=8,
233
- )
234
- qa_level = gr.Radio(
235
- choices=list(QA_PROMPTS.keys()),
236
- value="high_school",
237
- label="Difficulty Level",
238
- )
239
- with gr.Row():
240
- qa_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
241
- qa_btn = gr.Button("๐Ÿš€ Generate Q&A", variant="primary")
242
- with gr.Column():
243
- qa_problem = gr.Textbox(label="Generated Problem", lines=4)
244
- qa_solution = gr.Textbox(label="Generated Solution", lines=8)
245
- qa_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
 
 
 
246
 
247
  qa_example_btn.click(
248
  lambda: EXAMPLE_MATH_CONTENT,
@@ -256,25 +353,28 @@ with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css) as demo:
256
 
257
  # Conversation Synthesis Tab
258
  with gr.TabItem("๐Ÿ’ฌ Conversation Synthesis"):
259
- gr.Markdown("ๅฐ†ๆ•ฐๅญฆๅ†…ๅฎน่ฝฌๆขไธบๅคš่ฝฎๅฏน่ฏๆ ผๅผใ€‚")
260
- with gr.Row():
261
- with gr.Column():
262
- conv_input = gr.Textbox(
263
- label="Input Mathematical Content",
264
- placeholder="Enter mathematical content here...",
265
- lines=8,
266
- )
267
- conv_style = gr.Radio(
268
- choices=list(CONVERSATION_PROMPTS.keys()),
269
- value="teacher_student",
270
- label="Conversation Style",
271
- )
272
- with gr.Row():
273
- conv_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
274
- conv_btn = gr.Button("๐Ÿš€ Generate Conversation", variant="primary")
275
- with gr.Column():
276
- conv_output = gr.Textbox(label="Generated Conversation", lines=15)
277
- conv_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
 
 
 
278
 
279
  conv_example_btn.click(
280
  lambda: EXAMPLE_MATH_CONTENT,
@@ -288,25 +388,28 @@ with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css) as demo:
288
 
289
  # Rewrite Tab
290
  with gr.TabItem("โœจ Multi-style Rewrite"):
291
- gr.Markdown("ๅฐ†ๆ•ฐๅญฆๅ†…ๅฎนๆ”นๅ†™ไธบไธๅŒ้ฃŽๆ ผใ€‚")
292
- with gr.Row():
293
- with gr.Column():
294
- rewrite_input = gr.Textbox(
295
- label="Input Mathematical Content",
296
- placeholder="Enter mathematical content here...",
297
- lines=8,
298
- )
299
- rewrite_style = gr.Radio(
300
- choices=list(MULTISTYLE_PROMPTS.keys()),
301
- value="textbook",
302
- label="Rewrite Style",
303
- )
304
- with gr.Row():
305
- rewrite_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
306
- rewrite_btn = gr.Button("๐Ÿš€ Rewrite", variant="primary")
307
- with gr.Column():
308
- rewrite_output = gr.Textbox(label="Rewritten Content", lines=15)
309
- rewrite_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
 
 
 
310
 
311
  rewrite_example_btn.click(
312
  lambda: EXAMPLE_MATH_CONTENT,
@@ -320,20 +423,22 @@ with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css) as demo:
320
 
321
  # Knowledge Extraction Tab
322
  with gr.TabItem("๐Ÿ“š Knowledge Extraction"):
323
- gr.Markdown("ไปŽๆ•ฐๅญฆๅ†…ๅฎนไธญๆๅ–ๅฎšไน‰ใ€ๅฎš็†ใ€ๆ€ง่ดจ็ญ‰็Ÿฅ่ฏ†็‚นใ€‚")
324
- with gr.Row():
325
- with gr.Column():
326
- know_input = gr.Textbox(
327
- label="Input Mathematical Content",
328
- placeholder="Enter mathematical content here...",
329
- lines=10,
330
- )
331
- with gr.Row():
332
- know_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
333
- know_btn = gr.Button("๐Ÿš€ Extract Knowledge", variant="primary")
334
- with gr.Column():
335
- know_output = gr.Textbox(label="Extracted Knowledge Points", lines=15)
336
- know_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
 
 
337
 
338
  know_example_btn.click(
339
  lambda: EXAMPLE_MATH_CONTENT,
@@ -347,25 +452,28 @@ with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css) as demo:
347
 
348
  # Textbook Exercise Tab
349
  with gr.TabItem("๐Ÿ“– Textbook Exercise"):
350
- gr.Markdown("ๅŸบไบŽ็Ÿฅ่ฏ†็‚น็”ŸๆˆไธๅŒ้šพๅบฆ็š„ๆ•™ๆๅผ็ปƒไน ใ€‚")
351
- with gr.Row():
352
- with gr.Column():
353
- textbook_input = gr.Textbox(
354
- label="Input Knowledge Point",
355
- placeholder="Enter a mathematical knowledge point...",
356
- lines=6,
357
- )
358
- textbook_diff = gr.Radio(
359
- choices=list(TEXTBOOK_EXERCISE_PROMPTS.keys()),
360
- value="easy",
361
- label="Difficulty",
362
- )
363
- with gr.Row():
364
- textbook_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
365
- textbook_btn = gr.Button("๐Ÿš€ Generate Exercise", variant="primary")
366
- with gr.Column():
367
- textbook_output = gr.Textbox(label="Generated Exercise Material", lines=15)
368
- textbook_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
 
 
 
369
 
370
  textbook_example_btn.click(
371
  lambda: EXAMPLE_KNOWLEDGE_POINT,
@@ -378,9 +486,9 @@ with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css) as demo:
378
  )
379
 
380
  gr.HTML("""
381
- <div style="text-align: center; margin-top: 2rem; padding: 1rem; color: #64748b; font-size: 0.85rem;">
382
  <p>๐Ÿ”ฌ <strong>UltraData-Math L3 Generator</strong> - Part of the UltraData-Math Project</p>
383
- <p>LLM-based data synthesis for Q&A, conversations, rewriting, and more.</p>
384
  </div>
385
  """)
386
 
 
172
  # ============================================================================
173
 
174
  custom_css = """
175
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
176
+
177
+ :root {
178
+ --primary-color: #6366f1;
179
+ --secondary-color: #ec4899;
180
+ --background-dark: #0f172a;
181
+ --panel-bg: rgba(30, 41, 59, 0.7);
182
+ --text-light: #f8fafc;
183
+ --text-gray: #94a3b8;
184
+ }
185
+
186
+ body {
187
+ background-color: var(--background-dark);
188
+ color: var(--text-light);
189
+ }
190
+
191
  .gradio-container {
192
+ font-family: 'Inter', sans-serif !important;
193
+ background: radial-gradient(circle at top left, #1e1b4b, #0f172a) !important;
194
+ max-width: 1200px !important;
195
  }
196
 
197
+ /* Title & Header */
198
  .main-title {
199
+ font-family: 'Inter', sans-serif !important;
200
+ font-weight: 800 !important;
201
+ font-size: 3rem !important;
202
+ background: linear-gradient(to right, #818cf8, #c084fc, #f472b6) !important;
203
  -webkit-background-clip: text !important;
204
  -webkit-text-fill-color: transparent !important;
 
205
  text-align: center !important;
206
+ margin-bottom: 0.5rem !important;
207
+ letter-spacing: -0.02em !important;
208
  }
209
 
210
  .subtitle {
211
  text-align: center !important;
212
+ color: var(--text-gray) !important;
213
+ font-size: 1.1rem !important;
214
+ margin-bottom: 3rem !important;
215
+ font-weight: 300 !important;
216
+ }
217
+
218
+ /* Tabs */
219
+ .tabs {
220
+ border: none !important;
221
+ background: transparent !important;
222
+ margin-bottom: 2rem !important;
223
+ }
224
+
225
+ .tab-nav {
226
+ border-bottom: 1px solid rgba(148, 163, 184, 0.2) !important;
227
+ justify-content: center !important;
228
+ }
229
+
230
+ .tab-nav button {
231
+ font-weight: 600 !important;
232
  font-size: 1rem !important;
233
+ color: var(--text-gray) !important;
234
+ transition: all 0.3s ease !important;
235
+ }
236
+
237
+ .tab-nav button.selected {
238
+ color: #818cf8 !important;
239
+ border-bottom: 2px solid #818cf8 !important;
240
  }
241
 
242
+ /* Panels & Cards */
243
+ .glass-panel {
244
+ background: var(--panel-bg) !important;
245
+ backdrop-filter: blur(12px) !important;
246
+ border: 1px solid rgba(255, 255, 255, 0.1) !important;
247
+ border-radius: 16px !important;
248
+ padding: 24px !important;
249
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
250
+ }
251
+
252
+ /* Inputs */
253
+ textarea, input {
254
+ font-family: 'JetBrains Mono', monospace !important;
255
+ background: rgba(15, 23, 42, 0.6) !important;
256
+ border: 1px solid rgba(148, 163, 184, 0.2) !important;
257
+ color: var(--text-light) !important;
258
+ border-radius: 8px !important;
259
+ transition: border-color 0.2s !important;
260
+ }
261
+
262
+ textarea:focus, input:focus {
263
+ border-color: var(--primary-color) !important;
264
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
265
+ }
266
+
267
+ /* Buttons */
268
  .gr-button-primary {
269
+ background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
270
  border: none !important;
271
+ color: white !important;
272
  font-weight: 600 !important;
273
+ border-radius: 8px !important;
274
+ transition: transform 0.2s, box-shadow 0.2s !important;
275
  }
276
 
277
  .gr-button-primary:hover {
278
+ transform: translateY(-1px) !important;
279
+ box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3) !important;
280
  }
281
 
282
  .gr-button-secondary {
283
+ background: rgba(30, 41, 59, 0.8) !important;
284
+ border: 1px solid rgba(148, 163, 184, 0.3) !important;
285
+ color: var(--text-gray) !important;
286
+ border-radius: 8px !important;
287
+ }
288
+
289
+ .gr-button-secondary:hover {
290
+ background: rgba(51, 65, 85, 0.8) !important;
291
+ color: var(--text-light) !important;
292
+ }
293
+
294
+ /* Labels */
295
+ label span {
296
+ color: #cbd5e1 !important;
297
+ font-weight: 500 !important;
298
+ font-size: 0.9rem !important;
299
+ margin-bottom: 0.5rem !important;
300
  }
301
 
302
+ /* Footer */
303
+ .footer-text {
304
+ text-align: center;
305
+ margin-top: 4rem;
306
+ padding: 2rem;
307
+ color: var(--text-gray);
308
+ font-size: 0.9rem;
309
+ border-top: 1px solid rgba(148, 163, 184, 0.1);
310
  }
311
  """
312
 
313
+ with gr.Blocks(title="UltraData-Math L3 Generator", css=custom_css, theme=gr.themes.Soft()) as demo:
314
  gr.HTML('<h1 class="main-title">๐Ÿงฎ UltraData-Math L3 Generator</h1>')
315
+ gr.HTML('<p class="subtitle">โœจ Next-Gen Mathematical Data Synthesis Powered by LLM โœจ</p>')
316
 
317
  with gr.Tabs():
318
  # Q&A Synthesis Tab
319
  with gr.TabItem("๐Ÿ“ Q&A Synthesis"):
320
+ with gr.Column(elem_classes=["glass-panel"]):
321
+ gr.Markdown("### ๐Ÿ’ก Transform Text into Q&A Pairs\nGenerate high-quality question-answer pairs from mathematical content, tailored to different educational levels.")
322
+ with gr.Row():
323
+ with gr.Column(scale=1):
324
+ qa_input = gr.Textbox(
325
+ label="Input Mathematical Content",
326
+ placeholder="Paste your mathematical text here (e.g., definitions, theorems, proofs)...",
327
+ lines=10,
328
+ )
329
+ qa_level = gr.Radio(
330
+ choices=list(QA_PROMPTS.keys()),
331
+ value="high_school",
332
+ label="Difficulty Level",
333
+ info="Select the target audience level"
334
+ )
335
+ with gr.Row():
336
+ qa_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
337
+ qa_btn = gr.Button("๐Ÿš€ Generate Q&A", variant="primary")
338
+
339
+ with gr.Column(scale=1):
340
+ qa_problem = gr.Textbox(label="Generated Problem", lines=5, show_copy_button=True)
341
+ qa_solution = gr.Textbox(label="Generated Solution", lines=12, show_copy_button=True)
342
+ qa_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
343
 
344
  qa_example_btn.click(
345
  lambda: EXAMPLE_MATH_CONTENT,
 
353
 
354
  # Conversation Synthesis Tab
355
  with gr.TabItem("๐Ÿ’ฌ Conversation Synthesis"):
356
+ with gr.Column(elem_classes=["glass-panel"]):
357
+ gr.Markdown("### ๐Ÿ—ฃ๏ธ Create Multi-turn Dialogues\nConvert static mathematical text into dynamic, engaging multi-turn conversations between students and teachers.")
358
+ with gr.Row():
359
+ with gr.Column(scale=1):
360
+ conv_input = gr.Textbox(
361
+ label="Input Mathematical Content",
362
+ placeholder="Paste your mathematical text here...",
363
+ lines=10,
364
+ )
365
+ conv_style = gr.Radio(
366
+ choices=list(CONVERSATION_PROMPTS.keys()),
367
+ value="teacher_student",
368
+ label="Conversation Style",
369
+ info="Choose the persona and tone of the conversation"
370
+ )
371
+ with gr.Row():
372
+ conv_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
373
+ conv_btn = gr.Button("๐Ÿš€ Generate Conversation", variant="primary")
374
+
375
+ with gr.Column(scale=1):
376
+ conv_output = gr.Textbox(label="Generated Conversation", lines=20, show_copy_button=True)
377
+ conv_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
378
 
379
  conv_example_btn.click(
380
  lambda: EXAMPLE_MATH_CONTENT,
 
388
 
389
  # Rewrite Tab
390
  with gr.TabItem("โœจ Multi-style Rewrite"):
391
+ with gr.Column(elem_classes=["glass-panel"]):
392
+ gr.Markdown("### ๐ŸŽจ Style Transfer\nRewrite mathematical content into various styles, from rigorous textbooks to engaging blog posts.")
393
+ with gr.Row():
394
+ with gr.Column(scale=1):
395
+ rewrite_input = gr.Textbox(
396
+ label="Input Mathematical Content",
397
+ placeholder="Paste your mathematical text here...",
398
+ lines=10,
399
+ )
400
+ rewrite_style = gr.Radio(
401
+ choices=list(MULTISTYLE_PROMPTS.keys()),
402
+ value="textbook",
403
+ label="Target Style",
404
+ info="Select the desired output style"
405
+ )
406
+ with gr.Row():
407
+ rewrite_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
408
+ rewrite_btn = gr.Button("๐Ÿš€ Rewrite Content", variant="primary")
409
+
410
+ with gr.Column(scale=1):
411
+ rewrite_output = gr.Textbox(label="Rewritten Content", lines=20, show_copy_button=True)
412
+ rewrite_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
413
 
414
  rewrite_example_btn.click(
415
  lambda: EXAMPLE_MATH_CONTENT,
 
423
 
424
  # Knowledge Extraction Tab
425
  with gr.TabItem("๐Ÿ“š Knowledge Extraction"):
426
+ with gr.Column(elem_classes=["glass-panel"]):
427
+ gr.Markdown("### ๐Ÿง  Extract Core Knowledge\nAutomatically identify and extract key definitions, theorems, and properties from unstructured text.")
428
+ with gr.Row():
429
+ with gr.Column(scale=1):
430
+ know_input = gr.Textbox(
431
+ label="Input Mathematical Content",
432
+ placeholder="Paste your mathematical text here...",
433
+ lines=12,
434
+ )
435
+ with gr.Row():
436
+ know_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
437
+ know_btn = gr.Button("๐Ÿš€ Extract Knowledge", variant="primary")
438
+
439
+ with gr.Column(scale=1):
440
+ know_output = gr.Textbox(label="Extracted Knowledge Points", lines=20, show_copy_button=True)
441
+ know_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
442
 
443
  know_example_btn.click(
444
  lambda: EXAMPLE_MATH_CONTENT,
 
452
 
453
  # Textbook Exercise Tab
454
  with gr.TabItem("๐Ÿ“– Textbook Exercise"):
455
+ with gr.Column(elem_classes=["glass-panel"]):
456
+ gr.Markdown("### ๐Ÿ“ Generate Exercises\nCreate comprehensive textbook-style exercises and problems based on specific knowledge points.")
457
+ with gr.Row():
458
+ with gr.Column(scale=1):
459
+ textbook_input = gr.Textbox(
460
+ label="Input Knowledge Point",
461
+ placeholder="Enter a specific mathematical concept or theorem...",
462
+ lines=8,
463
+ )
464
+ textbook_diff = gr.Radio(
465
+ choices=list(TEXTBOOK_EXERCISE_PROMPTS.keys()),
466
+ value="easy",
467
+ label="Difficulty",
468
+ info="Select the problem difficulty"
469
+ )
470
+ with gr.Row():
471
+ textbook_example_btn = gr.Button("๐Ÿ“‹ Load Example", variant="secondary")
472
+ textbook_btn = gr.Button("๐Ÿš€ Generate Exercise", variant="primary")
473
+
474
+ with gr.Column(scale=1):
475
+ textbook_output = gr.Textbox(label="Generated Exercise Material", lines=20, show_copy_button=True)
476
+ textbook_raw = gr.Textbox(label="Raw Response", lines=4, visible=False)
477
 
478
  textbook_example_btn.click(
479
  lambda: EXAMPLE_KNOWLEDGE_POINT,
 
486
  )
487
 
488
  gr.HTML("""
489
+ <div class="footer-text">
490
  <p>๐Ÿ”ฌ <strong>UltraData-Math L3 Generator</strong> - Part of the UltraData-Math Project</p>
491
+ <p>Powered by OpenBMB & ModelBest โ€ข <a href="https://huggingface.co/spaces/openbmb/UltraData-Math-L3-Generator" target="_blank" style="color: #818cf8; text-decoration: none;">View on Hugging Face</a></p>
492
  </div>
493
  """)
494