leninqwerty03@gmail.com commited on
Commit
d814bcd
·
1 Parent(s): ddccdbf

feat: Revamp UI with a professional eco-friendly theme and initialize RAG persistent storage.

Browse files
Files changed (1) hide show
  1. app.py +124 -211
app.py CHANGED
@@ -408,266 +408,176 @@ def assess_product_agentic(image, text_input: str, progress=gr.Progress()) -> st
408
  import traceback
409
  return f"**Error:**\n\n{str(e)}\n\n```\n{traceback.format_exc()}\n```"
410
 
411
- # ===== ECO-FRIENDLY GREEN THEME - IMPROVED CONTRAST =====
412
- # ===== ECO-FRIENDLY GREEN THEME - IMPROVED CONTRAST =====
413
  eco_green_css = """
414
- /* Eco-Friendly Green Theme - Mobile Optimized with Better Contrast */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  .gradio-container {
416
- background: linear-gradient(135deg, #0a3d29 0%, #1a5c42 100%) !important;
417
- max-width: 100% !important;
418
- margin: 0 auto;
419
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
420
  }
421
 
422
- /* Main elements */
423
  .block {
424
- background: rgba(255, 255, 255, 0.98) !important;
425
- border: 2px solid #2d8659 !important;
426
  border-radius: 12px !important;
427
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
 
 
428
  }
429
 
430
- /* Input fields */
431
- input, textarea {
432
  background: #ffffff !important;
433
- color: #1a1a1a !important;
434
- border: 2px solid #4caf50 !important;
435
  border-radius: 8px !important;
436
- font-size: 16px !important;
437
- padding: 12px !important;
438
- }
439
-
440
- input::placeholder, textarea::placeholder {
441
- color: #666666 !important;
442
  }
443
 
444
  input:focus, textarea:focus {
445
- border: 2px solid #2d8659 !important;
446
- box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2) !important;
447
  outline: none !important;
448
  }
449
 
450
- /* Button styling - Green gradient */
 
 
 
 
451
  #assess-btn {
452
- background: linear-gradient(135deg, #4caf50 0%, #2d8659 100%) !important;
453
- color: #ffffff !important;
454
- border: none !important;
 
 
 
455
  font-size: 1.1rem !important;
456
- font-weight: bold !important;
457
- padding: 16px 24px !important;
458
- border-radius: 12px !important;
459
- text-transform: uppercase;
460
- letter-spacing: 1px;
461
- box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4) !important;
462
- transition: all 0.3s ease;
463
  }
464
 
465
  #assess-btn:hover {
466
- background: linear-gradient(135deg, #45a049 0%, #26734a 100%) !important;
467
- box-shadow: 0 6px 16px rgba(76, 175, 80, 0.6) !important;
468
- transform: translateY(-2px);
469
  }
470
 
471
  #assess-btn:active {
472
- transform: translateY(0px);
473
- box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4) !important;
 
474
  }
475
 
476
- /* Result boxes */
477
  #result-box {
478
  background: #ffffff !important;
479
- color: #1a1a1a !important;
480
- border: 2px solid #e8f5e9 !important;
481
  border-radius: 12px !important;
482
- padding: 1.5rem !important;
483
- font-size: 1rem !important;
484
- line-height: 1.8 !important;
485
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
486
  }
487
 
488
- /* Markdown text styling - IMPROVED CONTRAST */
489
- .markdown-text {
490
- color: #1a1a1a !important;
 
491
  }
492
 
493
- .markdown-text h1 {
494
- color: #1a4d2e !important;
495
- font-weight: bold !important;
496
- margin-bottom: 1rem !important;
497
- font-size: 1.8rem !important;
498
- border-bottom: 3px solid #4caf50 !important;
499
- padding-bottom: 0.5rem !important;
 
500
  }
501
 
502
- .markdown-text h2 {
503
- color: #2d8659 !important;
 
504
  font-weight: 600 !important;
505
- margin-top: 1.5rem !important;
506
- margin-bottom: 0.5rem !important;
507
- font-size: 1.3rem !important;
508
  }
509
 
510
- .markdown-text strong {
511
- color: #1a4d2e !important;
512
- font-weight: 700 !important;
513
  }
514
 
515
- .markdown-text p {
516
- color: #333333 !important;
517
- margin: 0.5rem 0 !important;
518
  }
519
 
520
- .markdown-text hr {
521
- border: none !important;
522
- border-top: 2px solid #e8f5e9 !important;
523
- margin: 1.5rem 0 !important;
 
 
524
  }
525
 
526
- /* Labels */
527
- label {
528
- color: #e8f5e9 !important;
529
- font-weight: 600 !important;
530
- font-size: 0.95rem !important;
531
- margin-bottom: 8px !important;
532
- text-transform: uppercase;
533
- letter-spacing: 0.5px;
534
- text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
535
  }
536
 
537
- /* Image containers */
538
- .image-container {
539
- border: 3px solid #4caf50 !important;
540
- border-radius: 12px !important;
541
- overflow: hidden !important;
542
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
543
- background: #ffffff !important;
 
544
  }
545
 
546
- /* Progress bar */
547
  .progress-bar {
548
- background: linear-gradient(90deg, #4caf50 0%, #2d8659 100%) !important;
549
  }
550
 
551
- /* OR text divider */
552
- .gr-markdown p {
553
- color: #e8f5e9 !important;
 
554
  text-align: center !important;
555
- font-weight: bold !important;
556
  margin: 1rem 0 !important;
557
- text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
 
558
  }
559
 
560
  /* Footer */
561
- footer {
562
- text-align: center;
563
- padding: 1.5rem;
564
- color: #e8f5e9 !important;
565
- font-size: 0.9rem;
566
- }
567
-
568
- /* Info/Success messages */
569
- .gr-toast {
570
- background: #4caf50 !important;
571
- color: #ffffff !important;
572
- border-radius: 8px !important;
573
- }
574
-
575
- /* Mobile-first responsive design */
576
- @media (max-width: 768px) {
577
- .gradio-container {
578
- padding: 0.5rem !important;
579
- }
580
-
581
- #assess-btn {
582
- font-size: 1rem !important;
583
- padding: 14px 20px !important;
584
- width: 100% !important;
585
- }
586
-
587
- .markdown-text h1 {
588
- font-size: 1.5rem !important;
589
- }
590
-
591
- .markdown-text h2 {
592
- font-size: 1.2rem !important;
593
- }
594
-
595
- input, textarea {
596
- font-size: 16px !important; /* Prevents zoom on iOS */
597
- }
598
-
599
- .block {
600
- margin: 0.5rem 0 !important;
601
- padding: 1rem !important;
602
- }
603
-
604
- #result-box {
605
- padding: 1rem !important;
606
- }
607
- }
608
-
609
- /* Tablet screens */
610
- @media (min-width: 769px) and (max-width: 1024px) {
611
- .gradio-container {
612
- max-width: 95% !important;
613
- padding: 1rem !important;
614
- }
615
- }
616
-
617
- /* Large screens */
618
- @media (min-width: 1025px) {
619
- .gradio-container {
620
- max-width: 900px !important;
621
- }
622
- }
623
-
624
- /* Touch-friendly spacing */
625
- .gr-button {
626
- min-height: 48px !important;
627
- }
628
-
629
- /* Better focus indicators for accessibility */
630
- button:focus, input:focus, textarea:focus {
631
- outline: 3px solid #4caf50 !important;
632
- outline-offset: 2px !important;
633
- }
634
-
635
- /* Scrollbar styling */
636
- ::-webkit-scrollbar {
637
- width: 10px;
638
- }
639
-
640
- ::-webkit-scrollbar-track {
641
- background: #1a5c42;
642
- }
643
-
644
- ::-webkit-scrollbar-thumb {
645
- background: #4caf50;
646
- border-radius: 5px;
647
- }
648
-
649
- ::-webkit-scrollbar-thumb:hover {
650
- background: #45a049;
651
- }
652
-
653
- /* Loading animation */
654
- .progress-bar-wrap {
655
- background: rgba(76, 175, 80, 0.1) !important;
656
- border-radius: 4px !important;
657
- }
658
-
659
- /* Card-like sections within result */
660
- #result-box .markdown-text {
661
- line-height: 1.9 !important;
662
- }
663
-
664
- /* Better spacing for readability */
665
- #result-box h1 + h2 {
666
- margin-top: 0.5rem !important;
667
- }
668
-
669
- #result-box p + p {
670
- margin-top: 1rem !important;
671
  }
672
  """
673
 
@@ -677,9 +587,12 @@ with gr.Blocks(title="Future Earth - Eco Advisor") as app:
677
  <style>
678
  {eco_green_css}
679
  </style>
680
- <div style="text-align: center; padding: 2rem 1rem; background: linear-gradient(135deg, #4caf50 0%, #2d8659 100%); border-radius: 16px; margin-bottom: 1.5rem; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);">
681
- <h1 style="margin: 0; font-size: 2.2rem; color: #ffffff; font-weight: bold; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); letter-spacing: 1px;">🌍 FUTURE EARTH</h1>
682
- <p style="color: #ffffff; margin-top: 0.5rem; font-size: 1rem; letter-spacing: 1px; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);">Your AI-Powered Eco Advisor</p>
 
 
 
683
  </div>
684
  """)
685
 
@@ -692,7 +605,7 @@ with gr.Blocks(title="Future Earth - Eco Advisor") as app:
692
  height=300,
693
  elem_classes="image-container"
694
  )
695
- gr.Markdown("**OR**")
696
  text_input = gr.Textbox(
697
  label="✏️ Type Product Name",
698
  placeholder="e.g., wireless headphones, plastic bottle, laptop...",
@@ -711,9 +624,9 @@ with gr.Blocks(title="Future Earth - Eco Advisor") as app:
711
  )
712
 
713
  gr.HTML("""
714
- <footer style="background: rgba(0, 0, 0, 0.15); border-top: 2px solid #4caf50; margin-top: 2rem; padding: 1.5rem 1rem; border-radius: 8px;">
715
- <p style="color: #ffffff; letter-spacing: 1px; font-size: 0.95rem; margin: 0; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);">♻️ Powered by AI • MCP • RAG Technology</p>
716
- <p style="color: #c8e6c9; font-size: 0.85rem; margin-top: 0.5rem; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);">Building a sustainable future, one assessment at a time</p>
717
  </footer>
718
  """)
719
 
 
408
  import traceback
409
  return f"**Error:**\n\n{str(e)}\n\n```\n{traceback.format_exc()}\n```"
410
 
411
+ # ===== ECO-FRIENDLY GREEN THEME - PROFESSIONAL & MODERN =====
 
412
  eco_green_css = """
413
+ /* Professional Eco Theme - Clean, Modern, Sustainable */
414
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
415
+
416
+ :root {
417
+ --primary-color: #059669; /* Emerald 600 */
418
+ --primary-dark: #047857; /* Emerald 700 */
419
+ --primary-light: #d1fae5; /* Emerald 100 */
420
+ --accent-color: #10b981; /* Emerald 500 */
421
+ --text-main: #1e293b; /* Slate 800 */
422
+ --text-muted: #64748b; /* Slate 500 */
423
+ --bg-color: #f8fafc; /* Slate 50 */
424
+ --card-bg: #ffffff;
425
+ --border-color: #e2e8f0; /* Slate 200 */
426
+ }
427
+
428
+ body {
429
+ background-color: var(--bg-color);
430
+ color: var(--text-main);
431
+ }
432
+
433
  .gradio-container {
434
+ max-width: 1000px !important;
435
+ margin: 0 auto !important;
436
+ padding: 2rem 1rem !important;
437
+ font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
438
  }
439
 
440
+ /* Blocks/Cards - Clean & Professional */
441
  .block {
442
+ background: var(--card-bg) !important;
443
+ border: 1px solid var(--border-color) !important;
444
  border-radius: 12px !important;
445
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
446
+ padding: 0 !important;
447
+ overflow: hidden !important;
448
  }
449
 
450
+ /* Input Fields - Modern & Accessible */
451
+ input, textarea, .gr-input {
452
  background: #ffffff !important;
453
+ border: 1px solid #cbd5e1 !important;
 
454
  border-radius: 8px !important;
455
+ padding: 12px 16px !important;
456
+ font-size: 1rem !important;
457
+ color: var(--text-main) !important;
458
+ transition: all 0.2s ease;
 
 
459
  }
460
 
461
  input:focus, textarea:focus {
462
+ border-color: var(--primary-color) !important;
463
+ box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15) !important;
464
  outline: none !important;
465
  }
466
 
467
+ input::placeholder, textarea::placeholder {
468
+ color: #94a3b8 !important;
469
+ }
470
+
471
+ /* Primary Action Button - TACTILE & 3D */
472
  #assess-btn {
473
+ background: linear-gradient(180deg, #10b981 0%, #059669 100%) !important;
474
+ color: white !important;
475
+ border: 1px solid #047857 !important;
476
+ border-radius: 8px !important;
477
+ padding: 14px 28px !important;
478
+ font-weight: 600 !important;
479
  font-size: 1.1rem !important;
480
+ letter-spacing: 0.01em;
481
+ cursor: pointer !important;
482
+ transition: all 0.2s ease;
483
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
484
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
 
 
485
  }
486
 
487
  #assess-btn:hover {
488
+ background: linear-gradient(180deg, #059669 0%, #047857 100%) !important;
489
+ transform: translateY(-1px);
490
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
491
  }
492
 
493
  #assess-btn:active {
494
+ transform: translateY(1px);
495
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(0, 0, 0, 0.1) !important;
496
+ background: #047857 !important;
497
  }
498
 
499
+ /* Result Box - Typography & Spacing */
500
  #result-box {
501
  background: #ffffff !important;
502
+ border: 1px solid var(--border-color) !important;
 
503
  border-radius: 12px !important;
504
+ padding: 2.5rem !important;
 
 
 
505
  }
506
 
507
+ #result-box .markdown-text {
508
+ font-size: 1.05rem !important;
509
+ line-height: 1.7 !important;
510
+ color: var(--text-main) !important;
511
  }
512
 
513
+ #result-box h1 {
514
+ color: var(--primary-dark) !important;
515
+ font-size: 2rem !important;
516
+ font-weight: 700 !important;
517
+ border-bottom: 2px solid var(--primary-light) !important;
518
+ padding-bottom: 0.75rem !important;
519
+ margin-bottom: 1.5rem !important;
520
+ letter-spacing: -0.02em !important;
521
  }
522
 
523
+ #result-box h2 {
524
+ color: var(--primary-color) !important;
525
+ font-size: 1.5rem !important;
526
  font-weight: 600 !important;
527
+ margin-top: 2.5rem !important;
528
+ margin-bottom: 1rem !important;
529
+ letter-spacing: -0.01em !important;
530
  }
531
 
532
+ #result-box strong {
533
+ color: var(--primary-dark) !important;
534
+ font-weight: 600 !important;
535
  }
536
 
537
+ #result-box p {
538
+ margin-bottom: 1rem !important;
 
539
  }
540
 
541
+ /* Image Upload Area */
542
+ .image-container {
543
+ border: 2px dashed #cbd5e1 !important;
544
+ border-radius: 12px !important;
545
+ background: #f8fafc !important;
546
+ transition: border-color 0.2s ease;
547
  }
548
 
549
+ .image-container:hover {
550
+ border-color: var(--primary-color) !important;
 
 
 
 
 
 
 
551
  }
552
 
553
+ /* Labels */
554
+ label span {
555
+ color: var(--text-muted) !important;
556
+ font-weight: 500 !important;
557
+ font-size: 0.9rem !important;
558
+ text-transform: uppercase !important;
559
+ letter-spacing: 0.05em !important;
560
+ margin-bottom: 0.5rem !important;
561
  }
562
 
563
+ /* Progress Bar */
564
  .progress-bar {
565
+ background: var(--primary-color) !important;
566
  }
567
 
568
+ /* OR Divider */
569
+ .or-text p {
570
+ color: var(--text-muted) !important;
571
+ font-weight: 600 !important;
572
  text-align: center !important;
 
573
  margin: 1rem 0 !important;
574
+ font-size: 1.1rem !important;
575
+ position: relative;
576
  }
577
 
578
  /* Footer */
579
+ footer p {
580
+ color: var(--text-muted) !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581
  }
582
  """
583
 
 
587
  <style>
588
  {eco_green_css}
589
  </style>
590
+ <div style="text-align: center; margin-bottom: 2.5rem; padding-top: 1rem;">
591
+ <div style="display: inline-flex; align-items: center; justify-content: center; background: #ecfdf5; padding: 16px; border-radius: 20px; margin-bottom: 1.2rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);">
592
+ <span style="font-size: 3rem;">🌍</span>
593
+ </div>
594
+ <h1 style="color: #064e3b; font-size: 2.5rem; font-weight: 800; margin: 0; letter-spacing: -0.03em; font-family: 'Inter', sans-serif;">Future Earth</h1>
595
+ <p style="color: #64748b; font-size: 1.1rem; margin-top: 0.75rem; font-weight: 400;">AI-Powered Environmental Assessment & Advisor</p>
596
  </div>
597
  """)
598
 
 
605
  height=300,
606
  elem_classes="image-container"
607
  )
608
+ gr.Markdown("**OR**", elem_classes="or-text")
609
  text_input = gr.Textbox(
610
  label="✏️ Type Product Name",
611
  placeholder="e.g., wireless headphones, plastic bottle, laptop...",
 
624
  )
625
 
626
  gr.HTML("""
627
+ <footer style="text-align: center; margin-top: 4rem; padding: 2.5rem 0; color: #94a3b8; border-top: 1px solid #e2e8f0;">
628
+ <p style="margin: 0; font-weight: 500; color: #64748b;">Powered by Advanced Agentic AI • MCP • RAG</p>
629
+ <p style="margin-top: 0.75rem; font-size: 0.9rem; opacity: 0.8;">Building a sustainable future through intelligent analysis</p>
630
  </footer>
631
  """)
632