Files changed (1) hide show
  1. app.py +49 -49
app.py CHANGED
@@ -598,53 +598,53 @@ def create_gradio_interface():
598
 
599
  chatbot = GradioEmotionChatbot(emotion_model_id, response_model_id)
600
 
601
- # Create the Gradio interface with dark mode styling
602
  custom_css = """
603
- /* Dark mode styling */
604
  body {
605
- background-color: #1a1a1a !important;
606
- color: #e0e0e0 !important;
607
  }
608
 
609
  .gradio-container {
610
- max-width: 1200px !important; /* Increased width for horizontal expansion */
611
  margin: auto !important;
612
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
613
  border-radius: 12px !important;
614
- background: #2d2d2d !important;
615
  padding: 20px !important;
 
616
  }
617
 
618
  /* Chatbot header styling */
619
  .gradio-container h1, #header {
620
- color: #a29bfe !important;
621
  text-align: center !important;
622
- font-size: 2.2rem !important; /* Larger font for better visibility */
623
  margin-bottom: 8px !important;
624
  font-weight: 700 !important;
625
- text-shadow: 0 0 2px rgba(0,0,0,0.5) !important; /* Subtle shadow for clarity */
626
  }
627
 
628
  .gradio-container p, #subheader {
629
  text-align: center !important;
630
- color: #d0d0d0 !important; /* Lighter color for better contrast */
631
  margin-bottom: 20px !important;
632
- font-size: 1.1rem !important; /* Slightly larger font */
633
  font-weight: 400 !important;
634
  }
635
 
636
  /* Chatbot window styling */
637
  #chatbot {
638
- height: 450px !important; /* Slightly taller for better content display */
639
  overflow: auto !important;
640
  border-radius: 10px !important;
641
- background-color: #1a1a1a !important;
642
- border: 1px solid #3d3d3d !important;
643
  padding: 15px !important;
644
  margin-bottom: 20px !important;
645
  }
646
 
647
- /* Force horizontal text orientation for ALL elements */
648
  * {
649
  writing-mode: horizontal-tb !important;
650
  text-orientation: mixed !important;
@@ -655,34 +655,34 @@ def create_gradio_interface():
655
  .message {
656
  border-radius: 12px !important;
657
  padding: 10px 15px !important;
658
- margin: 8px 0 !important;
659
- max-width: 70% !important; /* Adjusted for horizontal expansion */
660
- width: auto !important; /* Allow messages to expand */
661
  word-break: break-word !important;
662
- font-size: 1rem !important; /* Clearer font size */
663
- line-height: 1.4 !important; /* Improved readability */
664
- text-shadow: 0 0 1px rgba(0,0,0,0.3) !important; /* Subtle shadow for text clarity */
665
  }
666
 
667
  .user-message {
668
- background-color: #4a5568 !important;
669
- color: #f0f4f8 !important; /* Lighter text for contrast */
670
- margin-left: auto !important; /* Align user messages to the right */
671
  }
672
 
673
  .bot-message {
674
- background-color: #553c9a !important;
675
- color: #ffffff !important; /* Pure white for maximum clarity */
676
- margin-right: auto !important; /* Align bot messages to the left */
677
  }
678
 
679
  /* User input styling */
680
  #user-input, .gradio-container textarea, .gradio-container input[type="text"] {
681
- background-color: #2d2d2d !important;
682
- color: #e0e0e0 !important;
683
  border-radius: 20px !important;
684
  padding: 12px 18px !important;
685
- border: 1px solid #4a4a4a !important;
686
  margin-bottom: 15px !important;
687
  writing-mode: horizontal-tb !important;
688
  text-orientation: mixed !important;
@@ -691,10 +691,10 @@ def create_gradio_interface():
691
  min-height: 50px !important;
692
  height: auto !important;
693
  resize: none !important;
694
- font-size: 1rem !important; /* Clearer font size */
695
  }
696
 
697
- /* Force text orientation for any text inputs */
698
  .cm-editor, .cm-scroller, .cm-content, .cm-line {
699
  writing-mode: horizontal-tb !important;
700
  text-orientation: mixed !important;
@@ -703,7 +703,7 @@ def create_gradio_interface():
703
  /* Ensure row is horizontal */
704
  .gradio-row {
705
  flex-direction: row !important;
706
- gap: 10px !important; /* Add spacing between elements */
707
  }
708
 
709
  /* Fix for chat bubbles */
@@ -712,28 +712,28 @@ def create_gradio_interface():
712
  text-orientation: mixed !important;
713
  }
714
 
715
- /* Apply horizontal text to all text elements in chatbot */
716
  .prose, .prose p, .prose span, .text-input-with-enter {
717
  writing-mode: horizontal-tb !important;
718
  text-orientation: mixed !important;
719
  direction: ltr !important;
720
  }
721
 
722
- /* Target the specific user bubble on the right side */
723
  .gradio-chatbot > div > div {
724
  writing-mode: horizontal-tb !important;
725
  text-orientation: mixed !important;
726
  direction: ltr !important;
727
  }
728
 
729
- /* Target any text inside chatbot bubbles */
730
  .gradio-chatbot * {
731
  writing-mode: horizontal-tb !important;
732
  text-orientation: mixed !important;
733
  direction: ltr !important;
734
  }
735
 
736
- /* AVATAR AND USERNAME FIXES */
737
  .avatar, .avatar-container, .avatar-image, .user-avatar, .bot-avatar {
738
  writing-mode: horizontal-tb !important;
739
  text-orientation: mixed !important;
@@ -749,7 +749,7 @@ def create_gradio_interface():
749
 
750
  /* Button styling */
751
  .send-btn, .clear-btn {
752
- background-color: #6c5ce7 !important;
753
  color: #ffffff !important;
754
  border: none !important;
755
  border-radius: 20px !important;
@@ -761,16 +761,16 @@ def create_gradio_interface():
761
  }
762
 
763
  .send-btn:hover, .clear-btn:hover {
764
- background-color: #5649c1 !important;
765
  transform: translateY(-1px) !important;
766
  }
767
 
768
  .clear-btn {
769
- background-color: #e74c3c !important;
770
  }
771
 
772
  .clear-btn:hover {
773
- background-color: #c0392b !important;
774
  }
775
 
776
  /* Hide footer */
@@ -778,14 +778,14 @@ def create_gradio_interface():
778
  display: none !important;
779
  }
780
 
781
- /* Fix scrollbar */
782
  ::-webkit-scrollbar {
783
  width: 8px;
784
- background-color: #1a1a1a;
785
  }
786
 
787
  ::-webkit-scrollbar-thumb {
788
- background-color: #4a4a4a;
789
  border-radius: 4px;
790
  }
791
  """
@@ -794,7 +794,7 @@ def create_gradio_interface():
794
  gr.Markdown("# EmotionChat", elem_id="header")
795
  gr.Markdown("A supportive chatbot that understands how you feel", elem_id="subheader")
796
 
797
- # Chat interface with improved styling
798
  chatbot_interface = gr.Chatbot(
799
  elem_id="chatbot",
800
  show_label=False,
@@ -803,7 +803,7 @@ def create_gradio_interface():
803
  "https://em-content.zobj.net/source/microsoft-teams/363/robot_1f916.png"],
804
  )
805
 
806
- # Input and button row with better styling
807
  with gr.Row():
808
  user_input = gr.Textbox(
809
  placeholder="Type your message here...",
@@ -820,13 +820,13 @@ def create_gradio_interface():
820
  # New conversation button
821
  clear_btn = gr.Button("New Conversation", elem_classes="clear-btn")
822
 
823
- # Set up the event handlers
824
  submit_btn.click(
825
  chatbot.process_message,
826
  inputs=[user_input, chatbot_interface],
827
  outputs=[chatbot_interface],
828
  ).then(
829
- lambda: "", # Clear the input box after sending
830
  None,
831
  [user_input],
832
  )
@@ -836,7 +836,7 @@ def create_gradio_interface():
836
  inputs=[user_input, chatbot_interface],
837
  outputs=[chatbot_interface],
838
  ).then(
839
- lambda: "", # Clear the input box after sending
840
  None,
841
  [user_input],
842
  )
 
598
 
599
  chatbot = GradioEmotionChatbot(emotion_model_id, response_model_id)
600
 
601
+ # Create the Gradio interface with theme-agnostic styling
602
  custom_css = """
603
+ /* Neutral styling for light/dark mode compatibility */
604
  body {
605
+ color: #333333; /* Dark gray for text, works in both modes */
 
606
  }
607
 
608
  .gradio-container {
609
+ max-width: 1200px !important; /* Wide container for horizontal layout */
610
  margin: auto !important;
611
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
612
  border-radius: 12px !important;
613
+ background: #f5f5f5; /* Light gray background, neutral */
614
  padding: 20px !important;
615
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Subtle shadow for depth */
616
  }
617
 
618
  /* Chatbot header styling */
619
  .gradio-container h1, #header {
620
+ color: #6b46c1 !important; /* Vibrant purple, good contrast */
621
  text-align: center !important;
622
+ font-size: 2.2rem !important;
623
  margin-bottom: 8px !important;
624
  font-weight: 700 !important;
625
+ text-shadow: 0 0 2px rgba(0,0,0,0.2) !important; /* Subtle shadow */
626
  }
627
 
628
  .gradio-container p, #subheader {
629
  text-align: center !important;
630
+ color: #666666 !important; /* Medium gray for subtitle */
631
  margin-bottom: 20px !important;
632
+ font-size: 1.1rem !important;
633
  font-weight: 400 !important;
634
  }
635
 
636
  /* Chatbot window styling */
637
  #chatbot {
638
+ height: 450px !important;
639
  overflow: auto !important;
640
  border-radius: 10px !important;
641
+ background-color: #ffffff !important; /* White background for chat */
642
+ border: 1px solid #d0d0d0 !important; /* Light border */
643
  padding: 15px !important;
644
  margin-bottom: 20px !important;
645
  }
646
 
647
+ /* Force horizontal text orientation */
648
  * {
649
  writing-mode: horizontal-tb !important;
650
  text-orientation: mixed !important;
 
655
  .message {
656
  border-radius: 12px !important;
657
  padding: 10px 15px !important;
658
+ margin: 8px 10px !important; /* Added margin for spacing */
659
+ max-width: 75% !important; /* Same width for both user and bot */
660
+ width: auto !important;
661
  word-break: break-word !important;
662
+ font-size: 1rem !important;
663
+ line-height: 1.4 !important;
664
+ text-shadow: 0 0 1px rgba(0,0,0,0.2) !important; /* Subtle shadow */
665
  }
666
 
667
  .user-message {
668
+ background-color: #e6e6fa !important; /* Light lavender for user */
669
+ color: #333333 !important; /* Dark text for contrast */
670
+ margin-left: auto !important; /* Align right */
671
  }
672
 
673
  .bot-message {
674
+ background-color: #6b46c1 !important; /* Purple for bot */
675
+ color: #ffffff !important; /* White text for contrast */
676
+ margin-right: auto !important; /* Align left */
677
  }
678
 
679
  /* User input styling */
680
  #user-input, .gradio-container textarea, .gradio-container input[type="text"] {
681
+ background-color: #ffffff !important;
682
+ color: #333333 !important;
683
  border-radius: 20px !important;
684
  padding: 12px 18px !important;
685
+ border: 1px solid #d0d0d0 !important;
686
  margin-bottom: 15px !important;
687
  writing-mode: horizontal-tb !important;
688
  text-orientation: mixed !important;
 
691
  min-height: 50px !important;
692
  height: auto !important;
693
  resize: none !important;
694
+ font-size: 1rem !important;
695
  }
696
 
697
+ /* Force text orientation for inputs */
698
  .cm-editor, .cm-scroller, .cm-content, .cm-line {
699
  writing-mode: horizontal-tb !important;
700
  text-orientation: mixed !important;
 
703
  /* Ensure row is horizontal */
704
  .gradio-row {
705
  flex-direction: row !important;
706
+ gap: 10px !important;
707
  }
708
 
709
  /* Fix for chat bubbles */
 
712
  text-orientation: mixed !important;
713
  }
714
 
715
+ /* Apply horizontal text to all text elements */
716
  .prose, .prose p, .prose span, .text-input-with-enter {
717
  writing-mode: horizontal-tb !important;
718
  text-orientation: mixed !important;
719
  direction: ltr !important;
720
  }
721
 
722
+ /* Target user bubble */
723
  .gradio-chatbot > div > div {
724
  writing-mode: horizontal-tb !important;
725
  text-orientation: mixed !important;
726
  direction: ltr !important;
727
  }
728
 
729
+ /* Target text inside chatbot bubbles */
730
  .gradio-chatbot * {
731
  writing-mode: horizontal-tb !important;
732
  text-orientation: mixed !important;
733
  direction: ltr !important;
734
  }
735
 
736
+ /* Avatar fixes */
737
  .avatar, .avatar-container, .avatar-image, .user-avatar, .bot-avatar {
738
  writing-mode: horizontal-tb !important;
739
  text-orientation: mixed !important;
 
749
 
750
  /* Button styling */
751
  .send-btn, .clear-btn {
752
+ background-color: #6b46c1 !important; /* Purple button */
753
  color: #ffffff !important;
754
  border: none !important;
755
  border-radius: 20px !important;
 
761
  }
762
 
763
  .send-btn:hover, .clear-btn:hover {
764
+ background-color: #553c9a !important; /* Darker purple on hover */
765
  transform: translateY(-1px) !important;
766
  }
767
 
768
  .clear-btn {
769
+ background-color: #e53e3e !important; /* Red for clear button */
770
  }
771
 
772
  .clear-btn:hover {
773
+ background-color: #c53030 !important; /* Darker red on hover */
774
  }
775
 
776
  /* Hide footer */
 
778
  display: none !important;
779
  }
780
 
781
+ /* Scrollbar styling */
782
  ::-webkit-scrollbar {
783
  width: 8px;
784
+ background-color: #f5f5f5;
785
  }
786
 
787
  ::-webkit-scrollbar-thumb {
788
+ background-color: #b0b0b0;
789
  border-radius: 4px;
790
  }
791
  """
 
794
  gr.Markdown("# EmotionChat", elem_id="header")
795
  gr.Markdown("A supportive chatbot that understands how you feel", elem_id="subheader")
796
 
797
+ # Chat interface
798
  chatbot_interface = gr.Chatbot(
799
  elem_id="chatbot",
800
  show_label=False,
 
803
  "https://em-content.zobj.net/source/microsoft-teams/363/robot_1f916.png"],
804
  )
805
 
806
+ # Input and button row
807
  with gr.Row():
808
  user_input = gr.Textbox(
809
  placeholder="Type your message here...",
 
820
  # New conversation button
821
  clear_btn = gr.Button("New Conversation", elem_classes="clear-btn")
822
 
823
+ # Event handlers
824
  submit_btn.click(
825
  chatbot.process_message,
826
  inputs=[user_input, chatbot_interface],
827
  outputs=[chatbot_interface],
828
  ).then(
829
+ lambda: "", # Clear input box
830
  None,
831
  [user_input],
832
  )
 
836
  inputs=[user_input, chatbot_interface],
837
  outputs=[chatbot_interface],
838
  ).then(
839
+ lambda: "", # Clear input box
840
  None,
841
  [user_input],
842
  )