anfasmhsnn commited on
Commit
a4076c0
·
verified ·
1 Parent(s): 6e00d80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +104 -112
app.py CHANGED
@@ -628,31 +628,42 @@ def greet():
628
  def create_interface():
629
  with gr.Blocks(
630
  title="🌾 AgriBot - AI Agricultural Assistant",
631
- theme=gr.themes.Base(
632
  primary_hue="green",
633
  secondary_hue="emerald",
634
- neutral_hue="gray",
635
- font=[gr.themes.GoogleFont("Inter"), "Arial", "sans-serif"]
636
  ),
637
  css="""
 
 
 
 
 
 
 
 
 
 
 
638
  /* Main Container Styling */
639
  .gradio-container {
640
  max-width: 1400px !important;
641
  margin: 0 auto !important;
642
  padding: 20px !important;
643
- background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%) !important;
 
644
  }
645
 
646
  /* Header Styling */
647
  .main-header {
648
  text-align: center;
649
  padding: 30px 20px;
650
- background: linear-gradient(135deg, #2d5016 0%, #4a7c3c 50%, #5d8b4a 100%);
651
  border-radius: 15px;
652
  margin-bottom: 25px;
653
  color: white !important;
654
- box-shadow: 0 8px 32px rgba(45, 80, 22, 0.3);
655
- border: 1px solid rgba(255, 255, 255, 0.2);
656
  }
657
 
658
  .main-header h1 {
@@ -664,7 +675,7 @@ def create_interface():
664
  }
665
 
666
  .main-header p {
667
- color: #e8f5e8 !important;
668
  font-size: 1.2rem !important;
669
  margin: 0 !important;
670
  font-weight: 400 !important;
@@ -679,29 +690,29 @@ def create_interface():
679
  }
680
 
681
  .feature-card {
682
- background: white !important;
683
  padding: 25px !important;
684
  border-radius: 12px !important;
685
- border-left: 5px solid #4CAF50 !important;
686
- box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
687
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
688
- color: #2d5016 !important;
689
  }
690
 
691
  .feature-card:hover {
692
  transform: translateY(-5px) !important;
693
- box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
694
  }
695
 
696
  .feature-card h3 {
697
- color: #2d5016 !important;
698
  font-size: 1.3rem !important;
699
  font-weight: 600 !important;
700
  margin-bottom: 10px !important;
701
  }
702
 
703
  .feature-card p {
704
- color: #4a7c3c !important;
705
  font-size: 1rem !important;
706
  line-height: 1.5 !important;
707
  margin: 0 !important;
@@ -709,18 +720,18 @@ def create_interface():
709
 
710
  /* Chat Container */
711
  .chat-container {
712
- background: white !important;
713
  border-radius: 15px !important;
714
  padding: 25px !important;
715
- box-shadow: 0 8px 32px rgba(0,0,0,0.1) !important;
716
  margin-bottom: 20px !important;
717
  }
718
 
719
  /* Chatbot Styling */
720
  .chatbot-container {
721
- border: 2px solid #e8f5e8 !important;
722
  border-radius: 12px !important;
723
- background: #fafffe !important;
724
  }
725
 
726
  /* Override Gradio's default message styling */
@@ -729,86 +740,66 @@ def create_interface():
729
  }
730
 
731
  .chatbot .message.user {
732
- background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
733
- color: #0d47a1 !important;
734
- border: 1px solid #90caf9 !important;
735
  margin-left: 15% !important;
736
  padding: 15px 20px !important;
737
  border-radius: 15px 15px 5px 15px !important;
738
- box-shadow: 0 2px 8px rgba(13, 71, 161, 0.2) !important;
739
  font-weight: 500 !important;
740
  }
741
 
742
  .chatbot .message.bot {
743
- background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%) !important;
744
- color: #1b5e20 !important;
745
- border: 1px solid #a5d6a7 !important;
746
  margin-right: 15% !important;
747
  padding: 15px 20px !important;
748
  border-radius: 15px 15px 15px 5px !important;
749
- box-shadow: 0 2px 8px rgba(27, 94, 32, 0.2) !important;
750
  font-weight: 500 !important;
751
  }
752
 
753
  /* Force text color in chat messages */
754
  .chatbot .message.user * {
755
- color: #0d47a1 !important;
756
  }
757
 
758
  .chatbot .message.bot * {
759
- color: #1b5e20 !important;
760
  }
761
 
762
  /* Ensure chat text is always visible */
763
  .gradio-chatbot .chatbot .message {
764
- color: inherit !important;
765
  }
766
 
767
  .gradio-chatbot .chatbot .message p {
768
- color: inherit !important;
769
  margin: 5px 0 !important;
770
  line-height: 1.5 !important;
771
  }
772
 
773
- /* User message styling */
774
- .gradio-chatbot .user {
775
- background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
776
- color: #0d47a1 !important;
777
- border: 1px solid #90caf9 !important;
778
- border-radius: 15px 15px 5px 15px !important;
779
- margin-left: 15% !important;
780
- margin-right: 5% !important;
781
- }
782
-
783
- /* Bot message styling */
784
- .gradio-chatbot .bot {
785
- background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%) !important;
786
- color: #1b5e20 !important;
787
- border: 1px solid #a5d6a7 !important;
788
- border-radius: 15px 15px 15px 5px !important;
789
- margin-right: 15% !important;
790
- margin-left: 5% !important;
791
- }
792
-
793
  /* Input Styling */
794
  .input-container {
795
- background: white !important;
796
  border-radius: 12px !important;
797
- border: 2px solid #e8f5e8 !important;
798
  padding: 5px !important;
799
  margin-top: 15px !important;
800
  }
801
 
802
  .input-container:focus-within {
803
- border-color: #4CAF50 !important;
804
- box-shadow: 0 0 10px rgba(76, 175, 80, 0.2) !important;
805
  }
806
 
807
  /* Input text styling */
808
  .input-container textarea,
809
  .input-container input {
810
- color: #2d5016 !important;
811
- background: white !important;
812
  border: none !important;
813
  font-size: 1rem !important;
814
  font-weight: 500 !important;
@@ -816,33 +807,33 @@ def create_interface():
816
 
817
  .input-container textarea::placeholder,
818
  .input-container input::placeholder {
819
- color: #6b7280 !important;
820
  opacity: 0.8 !important;
821
  }
822
 
823
  /* Override any Gradio input styling */
824
  .gradio-textbox {
825
- background: white !important;
826
  }
827
 
828
  .gradio-textbox textarea {
829
- color: #2d5016 !important;
830
- background: white !important;
831
- border: 2px solid #e8f5e8 !important;
832
  border-radius: 8px !important;
833
  padding: 12px !important;
834
  font-size: 1rem !important;
835
  }
836
 
837
  .gradio-textbox textarea:focus {
838
- border-color: #4CAF50 !important;
839
- box-shadow: 0 0 10px rgba(76, 175, 80, 0.2) !important;
840
  outline: none !important;
841
  }
842
 
843
  /* Button Styling */
844
  .btn-primary {
845
- background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%) !important;
846
  color: white !important;
847
  border: none !important;
848
  border-radius: 8px !important;
@@ -850,17 +841,17 @@ def create_interface():
850
  font-weight: 600 !important;
851
  font-size: 1rem !important;
852
  transition: all 0.3s ease !important;
853
- box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3) !important;
854
  }
855
 
856
  .btn-primary:hover {
857
- background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%) !important;
858
  transform: translateY(-2px) !important;
859
- box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4) !important;
860
  }
861
 
862
  .btn-secondary {
863
- background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%) !important;
864
  color: white !important;
865
  border: none !important;
866
  border-radius: 8px !important;
@@ -870,26 +861,26 @@ def create_interface():
870
  }
871
 
872
  .btn-secondary:hover {
873
- background: linear-gradient(135deg, #5a6268 0%, #495057 100%) !important;
874
  transform: translateY(-2px) !important;
875
  }
876
 
877
  /* Sidebar Styling */
878
  .sidebar {
879
- background: white !important;
880
  border-radius: 15px !important;
881
  padding: 25px !important;
882
- box-shadow: 0 8px 32px rgba(0,0,0,0.1) !important;
883
  height: fit-content !important;
884
  }
885
 
886
  .sidebar h3 {
887
- color: #2d5016 !important;
888
  font-size: 1.4rem !important;
889
  font-weight: 600 !important;
890
  margin-bottom: 15px !important;
891
  padding-bottom: 10px !important;
892
- border-bottom: 2px solid #e8f5e8 !important;
893
  }
894
 
895
  .sidebar ul {
@@ -899,36 +890,36 @@ def create_interface():
899
  }
900
 
901
  .sidebar li {
902
- color: #4a7c3c !important;
903
  padding: 8px 0 !important;
904
- border-bottom: 1px solid #f0f8f0 !important;
905
  font-size: 0.95rem !important;
906
  line-height: 1.4 !important;
907
  }
908
 
909
  .sidebar strong {
910
- color: #2d5016 !important;
911
  font-weight: 600 !important;
912
  }
913
 
914
  /* Examples Section */
915
  .examples-section {
916
- background: #f8fffe !important;
917
  padding: 20px !important;
918
  border-radius: 10px !important;
919
  margin-top: 20px !important;
920
- border: 1px solid #e8f5e8 !important;
921
  }
922
 
923
  /* Footer Styling */
924
  .footer {
925
  text-align: center;
926
  padding: 25px;
927
- background: linear-gradient(135deg, #2d5016 0%, #4a7c3c 100%);
928
  border-radius: 15px;
929
  margin-top: 30px;
930
  color: white !important;
931
- box-shadow: 0 8px 32px rgba(45, 80, 22, 0.3);
932
  }
933
 
934
  .footer p {
@@ -938,10 +929,31 @@ def create_interface():
938
  }
939
 
940
  .footer strong {
941
- color: #e8f5e8 !important;
942
  font-size: 1.2rem !important;
943
  }
944
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
945
  /* Responsive Design */
946
  @media (max-width: 768px) {
947
  .gradio-container {
@@ -968,32 +980,12 @@ def create_interface():
968
  .feature-card {
969
  padding: 20px !important;
970
  }
971
- }
972
-
973
- /* Text Visibility Fixes */
974
- .gr-textbox textarea {
975
- color: #2d5016 !important;
976
- background: white !important;
977
- }
978
-
979
- .gr-textbox label {
980
- color: #2d5016 !important;
981
- font-weight: 600 !important;
982
- }
983
-
984
- /* Loading Animation */
985
- .loading {
986
- display: inline-block;
987
- width: 20px;
988
- height: 20px;
989
- border: 3px solid #e8f5e8;
990
- border-radius: 50%;
991
- border-top-color: #4CAF50;
992
- animation: spin 1s ease-in-out infinite;
993
- }
994
-
995
- @keyframes spin {
996
- to { transform: rotate(360deg); }
997
  }
998
  """
999
  ) as iface:
@@ -1087,9 +1079,9 @@ def create_interface():
1087
  </ul>
1088
  </div>
1089
 
1090
- <div style="margin-top: 20px; padding: 15px; background: #f0f8f0; border-radius: 8px; text-align: center;">
1091
- <p style="margin: 0; color: #2d5016; font-weight: 600;">🤖 AI Status</p>
1092
- <p style="margin: 5px 0 0 0; color: #4a7c3c; font-size: 0.9rem;">Ready to help!</p>
1093
  </div>
1094
  </div>
1095
  """)
@@ -1097,7 +1089,7 @@ def create_interface():
1097
  # Quick action buttons
1098
  gr.HTML("""
1099
  <div style="margin: 20px 0; text-align: center;">
1100
- <h3 style="color: #2d5016; margin-bottom: 15px;">🚀 Quick Start Topics</h3>
1101
  </div>
1102
  """)
1103
 
 
628
  def create_interface():
629
  with gr.Blocks(
630
  title="🌾 AgriBot - AI Agricultural Assistant",
631
+ theme=gr.themes.Default(
632
  primary_hue="green",
633
  secondary_hue="emerald",
634
+ neutral_hue="slate",
 
635
  ),
636
  css="""
637
+ /* Dark Theme Variables */
638
+ :root {
639
+ --dark-bg: #0f172a;
640
+ --dark-card: #1e293b;
641
+ --dark-border: #334155;
642
+ --dark-text: #f1f5f9;
643
+ --dark-accent: #10b981;
644
+ --dark-hover: #2dd4bf;
645
+ --dark-shadow: rgba(0, 0, 0, 0.5);
646
+ }
647
+
648
  /* Main Container Styling */
649
  .gradio-container {
650
  max-width: 1400px !important;
651
  margin: 0 auto !important;
652
  padding: 20px !important;
653
+ background: var(--dark-bg) !important;
654
+ color: var(--dark-text) !important;
655
  }
656
 
657
  /* Header Styling */
658
  .main-header {
659
  text-align: center;
660
  padding: 30px 20px;
661
+ background: linear-gradient(135deg, #0d9488 0%, #059669 50%, #047857 100%);
662
  border-radius: 15px;
663
  margin-bottom: 25px;
664
  color: white !important;
665
+ box-shadow: 0 8px 32px rgba(13, 148, 136, 0.3);
666
+ border: 1px solid rgba(255, 255, 255, 0.1);
667
  }
668
 
669
  .main-header h1 {
 
675
  }
676
 
677
  .main-header p {
678
+ color: #d1fae5 !important;
679
  font-size: 1.2rem !important;
680
  margin: 0 !important;
681
  font-weight: 400 !important;
 
690
  }
691
 
692
  .feature-card {
693
+ background: var(--dark-card) !important;
694
  padding: 25px !important;
695
  border-radius: 12px !important;
696
+ border-left: 5px solid var(--dark-accent) !important;
697
+ box-shadow: 0 4px 15px var(--dark-shadow) !important;
698
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
699
+ color: var(--dark-text) !important;
700
  }
701
 
702
  .feature-card:hover {
703
  transform: translateY(-5px) !important;
704
+ box-shadow: 0 8px 25px rgba(16, 185, 129, 0.2) !important;
705
  }
706
 
707
  .feature-card h3 {
708
+ color: var(--dark-accent) !important;
709
  font-size: 1.3rem !important;
710
  font-weight: 600 !important;
711
  margin-bottom: 10px !important;
712
  }
713
 
714
  .feature-card p {
715
+ color: #cbd5e1 !important;
716
  font-size: 1rem !important;
717
  line-height: 1.5 !important;
718
  margin: 0 !important;
 
720
 
721
  /* Chat Container */
722
  .chat-container {
723
+ background: var(--dark-card) !important;
724
  border-radius: 15px !important;
725
  padding: 25px !important;
726
+ box-shadow: 0 8px 32px var(--dark-shadow) !important;
727
  margin-bottom: 20px !important;
728
  }
729
 
730
  /* Chatbot Styling */
731
  .chatbot-container {
732
+ border: 2px solid var(--dark-border) !important;
733
  border-radius: 12px !important;
734
+ background: var(--dark-card) !important;
735
  }
736
 
737
  /* Override Gradio's default message styling */
 
740
  }
741
 
742
  .chatbot .message.user {
743
+ background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
744
+ color: white !important;
745
+ border: 1px solid #3b82f6 !important;
746
  margin-left: 15% !important;
747
  padding: 15px 20px !important;
748
  border-radius: 15px 15px 5px 15px !important;
749
+ box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3) !important;
750
  font-weight: 500 !important;
751
  }
752
 
753
  .chatbot .message.bot {
754
+ background: linear-gradient(135deg, #065f46 0%, #064e3b 100%) !important;
755
+ color: white !important;
756
+ border: 1px solid #10b981 !important;
757
  margin-right: 15% !important;
758
  padding: 15px 20px !important;
759
  border-radius: 15px 15px 15px 5px !important;
760
+ box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
761
  font-weight: 500 !important;
762
  }
763
 
764
  /* Force text color in chat messages */
765
  .chatbot .message.user * {
766
+ color: white !important;
767
  }
768
 
769
  .chatbot .message.bot * {
770
+ color: white !important;
771
  }
772
 
773
  /* Ensure chat text is always visible */
774
  .gradio-chatbot .chatbot .message {
775
+ color: white !important;
776
  }
777
 
778
  .gradio-chatbot .chatbot .message p {
779
+ color: white !important;
780
  margin: 5px 0 !important;
781
  line-height: 1.5 !important;
782
  }
783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
784
  /* Input Styling */
785
  .input-container {
786
+ background: var(--dark-card) !important;
787
  border-radius: 12px !important;
788
+ border: 2px solid var(--dark-border) !important;
789
  padding: 5px !important;
790
  margin-top: 15px !important;
791
  }
792
 
793
  .input-container:focus-within {
794
+ border-color: var(--dark-accent) !important;
795
+ box-shadow: 0 0 10px rgba(16, 185, 129, 0.3) !important;
796
  }
797
 
798
  /* Input text styling */
799
  .input-container textarea,
800
  .input-container input {
801
+ color: white !important;
802
+ background: var(--dark-card) !important;
803
  border: none !important;
804
  font-size: 1rem !important;
805
  font-weight: 500 !important;
 
807
 
808
  .input-container textarea::placeholder,
809
  .input-container input::placeholder {
810
+ color: #94a3b8 !important;
811
  opacity: 0.8 !important;
812
  }
813
 
814
  /* Override any Gradio input styling */
815
  .gradio-textbox {
816
+ background: var(--dark-card) !important;
817
  }
818
 
819
  .gradio-textbox textarea {
820
+ color: white !important;
821
+ background: var(--dark-card) !important;
822
+ border: 2px solid var(--dark-border) !important;
823
  border-radius: 8px !important;
824
  padding: 12px !important;
825
  font-size: 1rem !important;
826
  }
827
 
828
  .gradio-textbox textarea:focus {
829
+ border-color: var(--dark-accent) !important;
830
+ box-shadow: 0 0 10px rgba(16, 185, 129, 0.3) !important;
831
  outline: none !important;
832
  }
833
 
834
  /* Button Styling */
835
  .btn-primary {
836
+ background: linear-gradient(135deg, var(--dark-accent) 0%, #059669 100%) !important;
837
  color: white !important;
838
  border: none !important;
839
  border-radius: 8px !important;
 
841
  font-weight: 600 !important;
842
  font-size: 1rem !important;
843
  transition: all 0.3s ease !important;
844
+ box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3) !important;
845
  }
846
 
847
  .btn-primary:hover {
848
+ background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
849
  transform: translateY(-2px) !important;
850
+ box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4) !important;
851
  }
852
 
853
  .btn-secondary {
854
+ background: linear-gradient(135deg, #475569 0%, #334155 100%) !important;
855
  color: white !important;
856
  border: none !important;
857
  border-radius: 8px !important;
 
861
  }
862
 
863
  .btn-secondary:hover {
864
+ background: linear-gradient(135deg, #334155 0%, #1e293b 100%) !important;
865
  transform: translateY(-2px) !important;
866
  }
867
 
868
  /* Sidebar Styling */
869
  .sidebar {
870
+ background: var(--dark-card) !important;
871
  border-radius: 15px !important;
872
  padding: 25px !important;
873
+ box-shadow: 0 8px 32px var(--dark-shadow) !important;
874
  height: fit-content !important;
875
  }
876
 
877
  .sidebar h3 {
878
+ color: var(--dark-accent) !important;
879
  font-size: 1.4rem !important;
880
  font-weight: 600 !important;
881
  margin-bottom: 15px !important;
882
  padding-bottom: 10px !important;
883
+ border-bottom: 2px solid var(--dark-border) !important;
884
  }
885
 
886
  .sidebar ul {
 
890
  }
891
 
892
  .sidebar li {
893
+ color: #cbd5e1 !important;
894
  padding: 8px 0 !important;
895
+ border-bottom: 1px solid var(--dark-border) !important;
896
  font-size: 0.95rem !important;
897
  line-height: 1.4 !important;
898
  }
899
 
900
  .sidebar strong {
901
+ color: var(--dark-accent) !important;
902
  font-weight: 600 !important;
903
  }
904
 
905
  /* Examples Section */
906
  .examples-section {
907
+ background: #1a2b3c !important;
908
  padding: 20px !important;
909
  border-radius: 10px !important;
910
  margin-top: 20px !important;
911
+ border: 1px solid var(--dark-border) !important;
912
  }
913
 
914
  /* Footer Styling */
915
  .footer {
916
  text-align: center;
917
  padding: 25px;
918
+ background: linear-gradient(135deg, #0d9488 0%, #059669 100%);
919
  border-radius: 15px;
920
  margin-top: 30px;
921
  color: white !important;
922
+ box-shadow: 0 8px 32px rgba(13, 148, 136, 0.3);
923
  }
924
 
925
  .footer p {
 
929
  }
930
 
931
  .footer strong {
932
+ color: #d1fae5 !important;
933
  font-size: 1.2rem !important;
934
  }
935
 
936
+ /* Labels and Text */
937
+ .gr-textbox label, .gr-chatbot label {
938
+ color: var(--dark-text) !important;
939
+ font-weight: 600 !important;
940
+ }
941
+
942
+ /* Loading Animation */
943
+ .loading {
944
+ display: inline-block;
945
+ width: 20px;
946
+ height: 20px;
947
+ border: 3px solid var(--dark-border);
948
+ border-radius: 50%;
949
+ border-top-color: var(--dark-accent);
950
+ animation: spin 1s ease-in-out infinite;
951
+ }
952
+
953
+ @keyframes spin {
954
+ to { transform: rotate(360deg); }
955
+ }
956
+
957
  /* Responsive Design */
958
  @media (max-width: 768px) {
959
  .gradio-container {
 
980
  .feature-card {
981
  padding: 20px !important;
982
  }
983
+
984
+ .chatbot .message.user,
985
+ .chatbot .message.bot {
986
+ margin-left: 5% !important;
987
+ margin-right: 5% !important;
988
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
989
  }
990
  """
991
  ) as iface:
 
1079
  </ul>
1080
  </div>
1081
 
1082
+ <div style="margin-top: 20px; padding: 15px; background: #1a2b3c; border-radius: 8px; text-align: center;">
1083
+ <p style="margin: 0; color: var(--dark-accent); font-weight: 600;">🤖 AI Status</p>
1084
+ <p style="margin: 5px 0 0 0; color: #94a3b8; font-size: 0.9rem;">Ready to help!</p>
1085
  </div>
1086
  </div>
1087
  """)
 
1089
  # Quick action buttons
1090
  gr.HTML("""
1091
  <div style="margin: 20px 0; text-align: center;">
1092
+ <h3 style="color: var(--dark-accent); margin-bottom: 15px;">🚀 Quick Start Topics</h3>
1093
  </div>
1094
  """)
1095