Luong Huu Thanh commited on
Commit
1ad9b01
·
1 Parent(s): f063c68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +685 -76
app.py CHANGED
@@ -157,66 +157,611 @@ def create_qna_interface():
157
  chatbot = QnAChatbot()
158
  print("🎨 Setting up UI components...")
159
 
160
- # Custom CSS for better styling
161
  custom_css = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  .gradio-container {
163
- max-width: 1200px !important;
164
- margin: auto !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
- .chat-message {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  padding: 10px !important;
168
- margin: 5px 0 !important;
169
- border-radius: 10px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
- .user-message {
172
- background-color: #e3f2fd !important;
173
- margin-left: 20% !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
175
- .bot-message {
176
- background-color: #f5f5f5 !important;
177
- margin-right: 20% !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
  """
180
 
181
- with gr.Blocks(css=custom_css, title="GAIA Agent - Q&A Chatbot") as demo:
182
- gr.Markdown(
183
- """
184
- # 🤖 GAIA Agent - Q&A Chatbot
185
-
186
- Welcome to the GAIA Agent Q&A interface! Ask me anything and I'll help you find the answer using my various tools and capabilities.
187
-
188
- **What I can do:**
189
- - 🔍 Search the web, Wikipedia, and academic papers
190
- - 🧮 Perform mathematical calculations
191
- - 💻 Execute code in multiple languages (Python, Bash, SQL, C, Java)
192
- - 📊 Analyze CSV and Excel files
193
- - 🖼️ Process and analyze images (JPG, PNG, GIF, etc.)
194
- - 📄 Extract text from images (OCR)
195
- - 📁 Handle file uploads and processing (PDF, DOC, TXT, etc.)
196
- - 📈 Create visualizations and charts
197
- - 🔧 Multi-file analysis and comparison
198
- - And much more!
199
-
200
- ---
201
- """
202
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
 
204
- # Chat interface
205
- with gr.Row():
206
  with gr.Column(scale=1):
207
  chatbot_interface = gr.Chatbot(
208
- label="Conversation",
209
- height=500,
210
  show_label=True,
211
  container=True,
212
- bubble_full_width=False
 
213
  )
214
 
215
- # File upload section
216
- with gr.Row():
217
  with gr.Column():
218
  file_upload = gr.File(
219
- label="📁 Upload Files (Images, Documents, CSV, Excel, etc.)",
220
  file_count="multiple",
221
  file_types=[
222
  ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", # Images
@@ -224,29 +769,35 @@ def create_qna_interface():
224
  ".csv", ".xlsx", ".xls", # Data files
225
  ".pdf", ".doc", ".docx" # Documents
226
  ],
227
- height=100
 
228
  )
229
 
230
- with gr.Row():
 
231
  with gr.Column(scale=8):
232
  question_input = gr.Textbox(
233
- label="Ask a question",
234
  placeholder="Type your question here or upload files above... (e.g., 'What is the capital of France?', 'Analyze this image', 'Summarize this document')",
235
- lines=2,
236
- max_lines=5
 
237
  )
238
- with gr.Column(scale=1, min_width=100):
239
- submit_btn = gr.Button("Send", variant="primary", size="lg")
240
 
241
- with gr.Row():
242
- clear_btn = gr.Button("Clear History", variant="secondary")
243
- clear_files_btn = gr.Button("Clear Files", variant="secondary")
244
-
245
- # Example questions
246
- with gr.Row():
247
- gr.Markdown("### 💡 Example Questions:")
 
 
 
248
 
249
- with gr.Row():
250
  with gr.Column():
251
  gr.Examples(
252
  examples=[
@@ -257,7 +808,7 @@ def create_qna_interface():
257
  "Explain quantum computing in simple terms",
258
  ],
259
  inputs=question_input,
260
- label="General Questions"
261
  )
262
  with gr.Column():
263
  gr.Examples(
@@ -269,7 +820,7 @@ def create_qna_interface():
269
  "What are the benefits of renewable energy?",
270
  ],
271
  inputs=question_input,
272
- label="Research & Analysis"
273
  )
274
  with gr.Column():
275
  gr.Examples(
@@ -281,7 +832,7 @@ def create_qna_interface():
281
  "What insights can you find in this Excel file?",
282
  ],
283
  inputs=question_input,
284
- label="File Analysis"
285
  )
286
 
287
  # Event handlers
@@ -300,6 +851,47 @@ def create_qna_interface():
300
  def clear_files():
301
  print("🗑️ UI: Clear files button clicked")
302
  return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
  # Connect the events
305
  submit_btn.click(
@@ -328,23 +920,40 @@ def create_qna_interface():
328
  show_progress=False
329
  )
330
 
331
- # Footer
332
- gr.Markdown(
333
- """
334
- ---
335
-
336
- **Note:** This agent uses various tools and APIs to provide comprehensive answers.
337
- Processing complex questions and file analysis may take some time. Please be patient!
338
-
339
- **Supported file types:**
340
- - **Images:** JPG, PNG, GIF, BMP, WebP
341
- - **Documents:** PDF, DOC, DOCX, TXT, MD
342
- - **Data files:** CSV, Excel (XLS, XLSX)
343
- - **Code files:** Python, JavaScript, HTML, CSS, JSON, XML
344
-
345
- **Powered by:** LangGraph, Groq, and various specialized tools
346
- """
347
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
 
349
  return demo
350
 
 
157
  chatbot = QnAChatbot()
158
  print("🎨 Setting up UI components...")
159
 
160
+ # Enhanced Custom CSS for modern, professional styling
161
  custom_css = """
162
+ /* Import Google Fonts */
163
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');
164
+
165
+ /* CSS Variables for Theme Support */
166
+ :root {
167
+ --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
168
+ --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
169
+ --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
170
+ --warning-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
171
+ --glass-bg: rgba(255, 255, 255, 0.95);
172
+ --glass-border: rgba(255, 255, 255, 0.2);
173
+ --text-primary: #2d3748;
174
+ --text-secondary: #4a5568;
175
+ --text-light: #718096;
176
+ --bg-light: #f7fafc;
177
+ --bg-card: #ffffff;
178
+ --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
179
+ --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
180
+ --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
181
+ --border-radius: 12px;
182
+ --border-radius-lg: 20px;
183
+ --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
184
+ }
185
+
186
+ /* Global Styles */
187
+ * {
188
+ font-family: 'Inter', sans-serif !important;
189
+ box-sizing: border-box !important;
190
+ }
191
+
192
+ /* Main Container with Enhanced Background */
193
  .gradio-container {
194
+ max-width: 1400px !important;
195
+ margin: 0 auto !important;
196
+ background:
197
+ radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3), transparent 50%),
198
+ radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3), transparent 50%),
199
+ radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.3), transparent 50%),
200
+ var(--primary-gradient) !important;
201
+ min-height: 100vh !important;
202
+ padding: 20px !important;
203
+ position: relative !important;
204
+ overflow-x: hidden !important;
205
+ }
206
+
207
+ /* Animated Background Particles */
208
+ .gradio-container::before {
209
+ content: '' !important;
210
+ position: fixed !important;
211
+ top: 0 !important;
212
+ left: 0 !important;
213
+ width: 100% !important;
214
+ height: 100% !important;
215
+ background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='7' cy='7' r='1'/%3E%3Ccircle cx='53' cy='7' r='1'/%3E%3Ccircle cx='7' cy='53' r='1'/%3E%3Ccircle cx='53' cy='53' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") !important;
216
+ animation: float 20s ease-in-out infinite !important;
217
+ pointer-events: none !important;
218
+ z-index: 0 !important;
219
+ }
220
+
221
+ /* Main Content Area with Glass Effect */
222
+ .main-content {
223
+ background: var(--glass-bg) !important;
224
+ backdrop-filter: blur(20px) !important;
225
+ -webkit-backdrop-filter: blur(20px) !important;
226
+ border-radius: var(--border-radius-lg) !important;
227
+ box-shadow:
228
+ var(--shadow-lg),
229
+ inset 0 1px 0 var(--glass-border) !important;
230
+ padding: 40px !important;
231
+ margin: 20px 0 !important;
232
+ position: relative !important;
233
+ z-index: 1 !important;
234
+ border: 1px solid var(--glass-border) !important;
235
+ transition: var(--transition) !important;
236
+ }
237
+
238
+ .main-content:hover {
239
+ transform: translateY(-2px) !important;
240
+ box-shadow:
241
+ 0 25px 50px rgba(0, 0, 0, 0.15),
242
+ inset 0 1px 0 var(--glass-border) !important;
243
+ }
244
+
245
+ /* Enhanced Header with Animations */
246
+ .markdown h1 {
247
+ background: var(--primary-gradient) !important;
248
+ -webkit-background-clip: text !important;
249
+ -webkit-text-fill-color: transparent !important;
250
+ background-clip: text !important;
251
+ font-size: 3rem !important;
252
+ font-weight: 800 !important;
253
+ text-align: center !important;
254
+ margin-bottom: 1.5rem !important;
255
+ position: relative !important;
256
+ animation: titleGlow 3s ease-in-out infinite alternate !important;
257
+ }
258
+
259
+ .markdown h1::after {
260
+ content: '' !important;
261
+ position: absolute !important;
262
+ bottom: -10px !important;
263
+ left: 50% !important;
264
+ transform: translateX(-50%) !important;
265
+ width: 100px !important;
266
+ height: 4px !important;
267
+ background: var(--primary-gradient) !important;
268
+ border-radius: 2px !important;
269
+ animation: pulse 2s ease-in-out infinite !important;
270
+ }
271
+
272
+ /* Enhanced Chat Interface */
273
+ .chatbot {
274
+ border: none !important;
275
+ border-radius: var(--border-radius) !important;
276
+ box-shadow: var(--shadow-md) !important;
277
+ background: var(--bg-card) !important;
278
+ overflow: hidden !important;
279
+ position: relative !important;
280
+ }
281
+
282
+ /* Chat Messages with Better Styling */
283
+ .chatbot .message-wrap {
284
+ padding: 20px !important;
285
+ margin: 15px !important;
286
+ border-radius: 18px !important;
287
+ max-width: 85% !important;
288
+ animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
289
+ position: relative !important;
290
+ word-wrap: break-word !important;
291
+ }
292
+
293
+ .chatbot .message.user {
294
+ background: var(--primary-gradient) !important;
295
+ color: white !important;
296
+ margin-left: auto !important;
297
+ margin-right: 15px !important;
298
+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4) !important;
299
+ border-bottom-right-radius: 5px !important;
300
+ }
301
+
302
+ .chatbot .message.user::before {
303
+ content: '🧑‍💻' !important;
304
+ position: absolute !important;
305
+ top: -25px !important;
306
+ right: 10px !important;
307
+ font-size: 16px !important;
308
+ background: var(--bg-card) !important;
309
+ padding: 5px 8px !important;
310
+ border-radius: 20px !important;
311
+ box-shadow: var(--shadow-sm) !important;
312
+ }
313
+
314
+ .chatbot .message.bot {
315
+ background: linear-gradient(135deg, #f8f9ff 0%, #e8eeff 100%) !important;
316
+ color: var(--text-primary) !important;
317
+ margin-right: auto !important;
318
+ margin-left: 15px !important;
319
+ border: 1px solid #e2e8f0 !important;
320
+ box-shadow: var(--shadow-sm) !important;
321
+ border-bottom-left-radius: 5px !important;
322
+ }
323
+
324
+ .chatbot .message.bot::before {
325
+ content: '🤖' !important;
326
+ position: absolute !important;
327
+ top: -25px !important;
328
+ left: 10px !important;
329
+ font-size: 16px !important;
330
+ background: var(--bg-card) !important;
331
+ padding: 5px 8px !important;
332
+ border-radius: 20px !important;
333
+ box-shadow: var(--shadow-sm) !important;
334
+ }
335
+
336
+ /* Typing Indicator */
337
+ .typing-indicator {
338
+ display: flex !important;
339
+ align-items: center !important;
340
+ padding: 15px 20px !important;
341
+ margin: 15px !important;
342
+ background: linear-gradient(135deg, #f8f9ff 0%, #e8eeff 100%) !important;
343
+ border-radius: 18px !important;
344
+ max-width: 85% !important;
345
+ margin-right: auto !important;
346
+ margin-left: 15px !important;
347
+ border: 1px solid #e2e8f0 !important;
348
+ animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
349
+ }
350
+
351
+ .typing-dots {
352
+ display: flex !important;
353
+ align-items: center !important;
354
+ gap: 4px !important;
355
+ }
356
+
357
+ .typing-dots span {
358
+ width: 8px !important;
359
+ height: 8px !important;
360
+ border-radius: 50% !important;
361
+ background: var(--text-light) !important;
362
+ animation: typingDots 1.4s ease-in-out infinite both !important;
363
+ }
364
+
365
+ .typing-dots span:nth-child(1) { animation-delay: -0.32s !important; }
366
+ .typing-dots span:nth-child(2) { animation-delay: -0.16s !important; }
367
+ .typing-dots span:nth-child(3) { animation-delay: 0s !important; }
368
+
369
+ /* Enhanced Input Areas */
370
+ .textbox input, .textbox textarea {
371
+ border: 2px solid #e2e8f0 !important;
372
+ border-radius: var(--border-radius) !important;
373
+ padding: 18px 24px !important;
374
+ font-size: 16px !important;
375
+ line-height: 1.5 !important;
376
+ transition: var(--transition) !important;
377
+ background: var(--bg-card) !important;
378
+ box-shadow: var(--shadow-sm) !important;
379
+ font-family: 'Inter', sans-serif !important;
380
  }
381
+
382
+ .textbox input:focus, .textbox textarea:focus {
383
+ border-color: #667eea !important;
384
+ box-shadow:
385
+ 0 0 0 4px rgba(102, 126, 234, 0.1),
386
+ var(--shadow-md) !important;
387
+ outline: none !important;
388
+ transform: translateY(-1px) !important;
389
+ background: #ffffff !important;
390
+ }
391
+
392
+ /* Enhanced Buttons with Micro-interactions */
393
+ .btn {
394
+ border-radius: var(--border-radius) !important;
395
+ font-weight: 600 !important;
396
+ text-transform: none !important;
397
+ letter-spacing: 0.3px !important;
398
+ transition: var(--transition) !important;
399
+ border: none !important;
400
+ box-shadow: var(--shadow-sm) !important;
401
+ padding: 14px 28px !important;
402
+ font-size: 16px !important;
403
+ position: relative !important;
404
+ overflow: hidden !important;
405
+ cursor: pointer !important;
406
+ }
407
+
408
+ .btn::before {
409
+ content: '' !important;
410
+ position: absolute !important;
411
+ top: 0 !important;
412
+ left: -100% !important;
413
+ width: 100% !important;
414
+ height: 100% !important;
415
+ background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent) !important;
416
+ transition: left 0.5s !important;
417
+ }
418
+
419
+ .btn:hover::before {
420
+ left: 100% !important;
421
+ }
422
+
423
+ .btn-primary {
424
+ background: var(--primary-gradient) !important;
425
+ color: white !important;
426
+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3) !important;
427
+ }
428
+
429
+ .btn-primary:hover {
430
+ transform: translateY(-3px) scale(1.02) !important;
431
+ box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4) !important;
432
+ }
433
+
434
+ .btn-primary:active {
435
+ transform: translateY(-1px) scale(0.98) !important;
436
+ }
437
+
438
+ .btn-secondary {
439
+ background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%) !important;
440
+ color: var(--text-secondary) !important;
441
+ border: 1px solid #e2e8f0 !important;
442
+ }
443
+
444
+ .btn-secondary:hover {
445
+ transform: translateY(-2px) !important;
446
+ background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%) !important;
447
+ box-shadow: var(--shadow-md) !important;
448
+ }
449
+
450
+ /* Enhanced File Upload with Drag & Drop Animation */
451
+ .file-upload {
452
+ border: 3px dashed #cbd5e0 !important;
453
+ border-radius: var(--border-radius) !important;
454
+ background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%) !important;
455
+ padding: 40px !important;
456
+ text-align: center !important;
457
+ transition: var(--transition) !important;
458
+ position: relative !important;
459
+ overflow: hidden !important;
460
+ cursor: pointer !important;
461
+ }
462
+
463
+ .file-upload:hover {
464
+ border-color: #667eea !important;
465
+ background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%) !important;
466
+ transform: translateY(-2px) scale(1.01) !important;
467
+ box-shadow: var(--shadow-md) !important;
468
+ }
469
+
470
+ .file-upload::before {
471
+ content: '📁' !important;
472
+ font-size: 4rem !important;
473
+ display: block !important;
474
+ margin-bottom: 15px !important;
475
+ animation: fileFloat 3s ease-in-out infinite !important;
476
+ }
477
+
478
+ .file-upload::after {
479
+ content: 'Drag files here or click to browse' !important;
480
+ position: absolute !important;
481
+ bottom: 15px !important;
482
+ left: 50% !important;
483
+ transform: translateX(-50%) !important;
484
+ font-size: 14px !important;
485
+ color: var(--text-light) !important;
486
+ font-weight: 500 !important;
487
+ }
488
+
489
+ /* Enhanced Examples Section */
490
+ .examples {
491
+ background: linear-gradient(135deg, #f8f9ff 0%, #e8eeff 100%) !important;
492
+ border-radius: var(--border-radius) !important;
493
+ padding: 30px !important;
494
+ margin: 25px 0 !important;
495
+ border: 1px solid #e2e8f0 !important;
496
+ box-shadow: var(--shadow-sm) !important;
497
+ position: relative !important;
498
+ }
499
+
500
+ .examples::before {
501
+ content: '💡' !important;
502
+ position: absolute !important;
503
+ top: -15px !important;
504
+ left: 30px !important;
505
+ background: var(--bg-card) !important;
506
  padding: 10px !important;
507
+ border-radius: 50% !important;
508
+ font-size: 20px !important;
509
+ box-shadow: var(--shadow-sm) !important;
510
+ }
511
+
512
+ .examples h3 {
513
+ color: #667eea !important;
514
+ font-weight: 700 !important;
515
+ margin-bottom: 20px !important;
516
+ font-size: 1.3rem !important;
517
+ margin-left: 20px !important;
518
+ }
519
+
520
+ /* Feature Cards with Hover Effects */
521
+ .feature-card {
522
+ background: var(--bg-card) !important;
523
+ border-radius: var(--border-radius) !important;
524
+ padding: 25px !important;
525
+ margin: 15px 0 !important;
526
+ box-shadow: var(--shadow-sm) !important;
527
+ border-left: 4px solid transparent !important;
528
+ transition: var(--transition) !important;
529
+ cursor: pointer !important;
530
+ }
531
+
532
+ .feature-card:hover {
533
+ transform: translateY(-5px) translateX(5px) !important;
534
+ box-shadow: var(--shadow-md) !important;
535
  }
536
+
537
+ .feature-card.research {
538
+ border-left-color: #667eea !important;
539
+ }
540
+
541
+ .feature-card.code {
542
+ border-left-color: #48bb78 !important;
543
+ }
544
+
545
+ .feature-card.data {
546
+ border-left-color: #ed8936 !important;
547
+ }
548
+
549
+ .feature-card.image {
550
+ border-left-color: #dd6b20 !important;
551
+ }
552
+
553
+ /* Status Indicator with Pulse Animation */
554
+ .status-indicator {
555
+ display: inline-block !important;
556
+ width: 12px !important;
557
+ height: 12px !important;
558
+ border-radius: 50% !important;
559
+ background: radial-gradient(circle, #48bb78, #38a169) !important;
560
+ margin-right: 12px !important;
561
+ animation: statusPulse 2s ease-in-out infinite !important;
562
+ box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7) !important;
563
+ }
564
+
565
+ /* Enhanced Footer */
566
+ .footer {
567
+ background: var(--glass-bg) !important;
568
+ backdrop-filter: blur(10px) !important;
569
+ border-radius: var(--border-radius) !important;
570
+ padding: 30px !important;
571
+ margin-top: 40px !important;
572
+ text-align: center !important;
573
+ border: 1px solid var(--glass-border) !important;
574
+ box-shadow: var(--shadow-sm) !important;
575
+ }
576
+
577
+ /* Advanced Animations */
578
+ @keyframes titleGlow {
579
+ 0%, 100% { text-shadow: 0 0 20px rgba(102, 126, 234, 0.5); }
580
+ 50% { text-shadow: 0 0 30px rgba(102, 126, 234, 0.8), 0 0 40px rgba(118, 75, 162, 0.6); }
581
+ }
582
+
583
+ @keyframes messageSlideIn {
584
+ from {
585
+ opacity: 0;
586
+ transform: translateY(30px) scale(0.95);
587
+ }
588
+ to {
589
+ opacity: 1;
590
+ transform: translateY(0) scale(1);
591
+ }
592
+ }
593
+
594
+ @keyframes typingDots {
595
+ 0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
596
+ 40% { transform: scale(1.2); opacity: 1; }
597
+ }
598
+
599
+ @keyframes fileFloat {
600
+ 0%, 100% { transform: translateY(0px); }
601
+ 50% { transform: translateY(-10px); }
602
+ }
603
+
604
+ @keyframes statusPulse {
605
+ 0% {
606
+ transform: scale(0.95);
607
+ box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7);
608
+ }
609
+ 70% {
610
+ transform: scale(1);
611
+ box-shadow: 0 0 0 10px rgba(72, 187, 120, 0);
612
+ }
613
+ 100% {
614
+ transform: scale(0.95);
615
+ box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
616
+ }
617
+ }
618
+
619
+ @keyframes float {
620
+ 0%, 100% { transform: translateY(0px) rotate(0deg); }
621
+ 33% { transform: translateY(-10px) rotate(1deg); }
622
+ 66% { transform: translateY(-5px) rotate(-1deg); }
623
+ }
624
+
625
+ @keyframes pulse {
626
+ 0%, 100% { transform: scale(1) scaleX(1); }
627
+ 50% { transform: scale(1.05) scaleX(1.1); }
628
+ }
629
+
630
+ /* Responsive Design Enhancements */
631
+ @media (max-width: 1024px) {
632
+ .gradio-container { padding: 15px !important; }
633
+ .main-content { padding: 25px !important; margin: 15px 0 !important; }
634
+ .markdown h1 { font-size: 2.5rem !important; }
635
  }
636
+
637
+ @media (max-width: 768px) {
638
+ .gradio-container { padding: 10px !important; }
639
+ .main-content { padding: 20px !important; margin: 10px 0 !important; }
640
+ .chatbot .message-wrap { max-width: 90% !important; margin: 10px !important; padding: 15px !important; }
641
+ .markdown h1 { font-size: 2rem !important; }
642
+ .btn { padding: 12px 20px !important; font-size: 14px !important; }
643
+ .file-upload { padding: 30px 20px !important; }
644
+ }
645
+
646
+ @media (max-width: 480px) {
647
+ .markdown h1 { font-size: 1.8rem !important; }
648
+ .chatbot .message-wrap { margin: 8px !important; padding: 12px !important; }
649
+ .main-content { padding: 15px !important; }
650
+ }
651
+
652
+ /* Custom Scrollbar Enhancement */
653
+ ::-webkit-scrollbar { width: 12px; }
654
+ ::-webkit-scrollbar-track {
655
+ background: rgba(241, 241, 241, 0.5);
656
+ border-radius: 6px;
657
+ }
658
+ ::-webkit-scrollbar-thumb {
659
+ background: var(--primary-gradient);
660
+ border-radius: 6px;
661
+ border: 2px solid rgba(255, 255, 255, 0.2);
662
+ }
663
+ ::-webkit-scrollbar-thumb:hover {
664
+ background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
665
+ }
666
+
667
+ /* Loading States */
668
+ .loading { animation: pulse 2s infinite !important; }
669
+ .processing {
670
+ position: relative !important;
671
+ overflow: hidden !important;
672
+ }
673
+ .processing::after {
674
+ content: '' !important;
675
+ position: absolute !important;
676
+ top: 0 !important;
677
+ left: -100% !important;
678
+ width: 100% !important;
679
+ height: 100% !important;
680
+ background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent) !important;
681
+ animation: shimmer 2s infinite !important;
682
+ }
683
+
684
+ @keyframes shimmer {
685
+ 0% { left: -100%; }
686
+ 100% { left: 100%; }
687
+ }
688
+
689
+ /* Dark mode support (future enhancement) */
690
+ @media (prefers-color-scheme: dark) {
691
+ :root {
692
+ --glass-bg: rgba(26, 32, 44, 0.95);
693
+ --text-primary: #e2e8f0;
694
+ --text-secondary: #cbd5e0;
695
+ --text-light: #a0aec0;
696
+ --bg-card: #2d3748;
697
+ --bg-light: #1a202c;
698
+ }
699
  }
700
  """
701
 
702
+ with gr.Blocks(css=custom_css, title="GAIA Agent - Q&A Chatbot", theme=gr.themes.Soft()) as demo:
703
+ # Header with enhanced styling
704
+ with gr.Row(elem_classes="main-content"):
705
+ gr.Markdown(
706
+ """
707
+ <h1 align="center">🤖 GAIA Agent - Advanced Q&A Chatbot</h1>
708
+
709
+ Welcome to the **GAIA Agent Q&A interface**! Ask me anything and I'll help you find the answer using my various tools and capabilities.
710
+
711
+ ### 🌟 **What I can do:**
712
+
713
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin: 20px 0;">
714
+ <div class="feature-card research" style="background: linear-gradient(135deg, #f8f9ff 0%, #e8eeff 100%); padding: 25px; border-radius: 12px; border-left: 4px solid #667eea; cursor: pointer; transition: all 0.3s ease;">
715
+ <div style="display: flex; align-items: center; margin-bottom: 10px;">
716
+ <span style="font-size: 2rem; margin-right: 15px;">🔍</span>
717
+ <strong style="font-size: 1.1rem; color: #667eea;">Research & Search</strong>
718
+ </div>
719
+ <p style="margin: 0; color: #718096; font-size: 14px; line-height: 1.5;">Web search, Wikipedia, academic papers, arXiv research</p>
720
+ </div>
721
+ <div class="feature-card code" style="background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%); padding: 25px; border-radius: 12px; border-left: 4px solid #48bb78; cursor: pointer; transition: all 0.3s ease;">
722
+ <div style="display: flex; align-items: center; margin-bottom: 10px;">
723
+ <span style="font-size: 2rem; margin-right: 15px;">💻</span>
724
+ <strong style="font-size: 1.1rem; color: #48bb78;">Code Execution</strong>
725
+ </div>
726
+ <p style="margin: 0; color: #718096; font-size: 14px; line-height: 1.5;">Python, Bash, SQL, C, Java with real-time results</p>
727
+ </div>
728
+ <div class="feature-card data" style="background: linear-gradient(135deg, #fffaf0 0%, #fbd38d 100%); padding: 25px; border-radius: 12px; border-left: 4px solid #ed8936; cursor: pointer; transition: all 0.3s ease;">
729
+ <div style="display: flex; align-items: center; margin-bottom: 10px;">
730
+ <span style="font-size: 2rem; margin-right: 15px;">📊</span>
731
+ <strong style="font-size: 1.1rem; color: #ed8936;">Data Analysis</strong>
732
+ </div>
733
+ <p style="margin: 0; color: #718096; font-size: 14px; line-height: 1.5;">CSV, Excel, visualizations, statistical analysis</p>
734
+ </div>
735
+ <div class="feature-card image" style="background: linear-gradient(135deg, #fef5e7 0%, #f6ad55 100%); padding: 25px; border-radius: 12px; border-left: 4px solid #dd6b20; cursor: pointer; transition: all 0.3s ease;">
736
+ <div style="display: flex; align-items: center; margin-bottom: 10px;">
737
+ <span style="font-size: 2rem; margin-right: 15px;">🖼️</span>
738
+ <strong style="font-size: 1.1rem; color: #dd6b20;">Image Processing</strong>
739
+ </div>
740
+ <p style="margin: 0; color: #718096; font-size: 14px; line-height: 1.5;">Analysis, OCR, transformations, generation</p>
741
+ </div>
742
+ </div>
743
+
744
+ ---
745
+ """
746
+ )
747
 
748
+ # Chat interface with enhanced styling
749
+ with gr.Row(elem_classes="main-content"):
750
  with gr.Column(scale=1):
751
  chatbot_interface = gr.Chatbot(
752
+ label="💬 Conversation",
753
+ height=600,
754
  show_label=True,
755
  container=True,
756
+ bubble_full_width=False,
757
+ elem_classes="chatbot"
758
  )
759
 
760
+ # File upload section with enhanced styling
761
+ with gr.Row(elem_classes="main-content"):
762
  with gr.Column():
763
  file_upload = gr.File(
764
+ label="📁 Upload Files - Drag & drop or click to upload images, documents, CSV, Excel files, etc.",
765
  file_count="multiple",
766
  file_types=[
767
  ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", # Images
 
769
  ".csv", ".xlsx", ".xls", # Data files
770
  ".pdf", ".doc", ".docx" # Documents
771
  ],
772
+ height=120,
773
+ elem_classes="file-upload"
774
  )
775
 
776
+ # Input and buttons with enhanced styling
777
+ with gr.Row(elem_classes="main-content"):
778
  with gr.Column(scale=8):
779
  question_input = gr.Textbox(
780
+ label="💭 Ask a question",
781
  placeholder="Type your question here or upload files above... (e.g., 'What is the capital of France?', 'Analyze this image', 'Summarize this document')",
782
+ lines=3,
783
+ max_lines=5,
784
+ elem_classes="textbox"
785
  )
786
+ with gr.Column(scale=2, min_width=120):
787
+ submit_btn = gr.Button("🚀 Send", variant="primary", size="lg", elem_classes="btn btn-primary")
788
 
789
+ with gr.Row(elem_classes="main-content"):
790
+ with gr.Column(scale=1):
791
+ clear_btn = gr.Button("🧹 Clear History", variant="secondary", elem_classes="btn btn-secondary")
792
+ with gr.Column(scale=1):
793
+ clear_files_btn = gr.Button("🗑️ Clear Files", variant="secondary", elem_classes="btn btn-secondary")
794
+ with gr.Column(scale=1):
795
+ export_btn = gr.Button("💾 Export Chat", variant="secondary", elem_classes="btn btn-secondary")
796
+
797
+ # Hidden download component for chat export
798
+ download_file = gr.File(visible=False)
799
 
800
+ with gr.Row(elem_classes="main-content"):
801
  with gr.Column():
802
  gr.Examples(
803
  examples=[
 
808
  "Explain quantum computing in simple terms",
809
  ],
810
  inputs=question_input,
811
+ label="🌐 General Questions"
812
  )
813
  with gr.Column():
814
  gr.Examples(
 
820
  "What are the benefits of renewable energy?",
821
  ],
822
  inputs=question_input,
823
+ label="🔬 Research & Analysis"
824
  )
825
  with gr.Column():
826
  gr.Examples(
 
832
  "What insights can you find in this Excel file?",
833
  ],
834
  inputs=question_input,
835
+ label="📁 File Analysis"
836
  )
837
 
838
  # Event handlers
 
851
  def clear_files():
852
  print("🗑️ UI: Clear files button clicked")
853
  return None
854
+
855
+ def export_conversation(history):
856
+ """Export conversation history to a text file"""
857
+ print("💾 UI: Export conversation button clicked")
858
+ if not history:
859
+ print("⚠️ No conversation to export")
860
+ return None
861
+
862
+ try:
863
+ import tempfile
864
+ import datetime
865
+
866
+ # Create export content
867
+ timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
868
+ export_content = f"# GAIA Agent Conversation Export\n"
869
+ export_content += f"Export Date: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
870
+ export_content += f"Total Messages: {len(history)}\n\n"
871
+ export_content += "=" * 50 + "\n\n"
872
+
873
+ for i, (user_msg, bot_msg) in enumerate(history, 1):
874
+ export_content += f"## Message {i}\n\n"
875
+ export_content += f"**User:** {user_msg}\n\n"
876
+ export_content += f"**Assistant:** {bot_msg}\n\n"
877
+ export_content += "-" * 30 + "\n\n"
878
+
879
+ # Save to temporary file
880
+ temp_file = tempfile.NamedTemporaryFile(
881
+ mode='w',
882
+ suffix=f'_gaia_chat_export_{timestamp}.md',
883
+ delete=False,
884
+ encoding='utf-8'
885
+ )
886
+ temp_file.write(export_content)
887
+ temp_file.close()
888
+
889
+ print(f"📄 Conversation exported to: {temp_file.name}")
890
+ return temp_file.name
891
+
892
+ except Exception as e:
893
+ print(f"❌ Error exporting conversation: {e}")
894
+ return None
895
 
896
  # Connect the events
897
  submit_btn.click(
 
920
  show_progress=False
921
  )
922
 
923
+ export_btn.click(
924
+ fn=export_conversation,
925
+ inputs=[chatbot_interface],
926
+ outputs=[download_file],
927
+ show_progress=True
 
 
 
 
 
 
 
 
 
 
 
928
  )
929
+
930
+ # Enhanced Footer with better styling
931
+ with gr.Row(elem_classes="footer"):
932
+ gr.Markdown(
933
+ """
934
+ ### 📋 **Important Information**
935
+
936
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin: 20px 0;">
937
+ <div style="text-align: left;">
938
+ <strong>⏱️ Processing Time</strong><br>
939
+ <small>Complex questions may take time. Please be patient!</small>
940
+ </div>
941
+ <div style="text-align: left;">
942
+ <strong>📁 Supported Files</strong><br>
943
+ <small>Images, Documents, CSV, Excel, Code files</small>
944
+ </div>
945
+ <div style="text-align: left;">
946
+ <strong>🔧 Powered By</strong><br>
947
+ <small>LangGraph, Groq, and specialized AI tools</small>
948
+ </div>
949
+ </div>
950
+
951
+ <div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid #e2e8f0; text-align: center;">
952
+ <span style="color: #667eea; font-weight: 600;">🤖 GAIA Agent</span> -
953
+ <span style="color: #718096;">Advanced AI Assistant for Complex Tasks</span>
954
+ </div>
955
+ """
956
+ )
957
 
958
  return demo
959