Redmind commited on
Commit
83af1fb
·
verified ·
1 Parent(s): 4557a38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -81
app.py CHANGED
@@ -613,120 +613,83 @@ def handle_dislike(data: gr.LikeData):
613
 
614
  def update_message(request: gr.Request):
615
  return f"<h4 style='font-size: 22px; font-family: Calibri;'>Welcome, {request.username}</h4>"
616
- custom_css = """
617
- /* Include the CSS defined above */
618
- .gradio-button {
619
- background-color: #6366f1 !important;
620
- color: white !important;
621
- border-radius: 10px !important;
622
- padding: 10px 20px !important;
623
- font-size: 16px !important;
624
- border: none !important;
625
- text-align: center;
626
- }
627
 
628
- .gradio-button:hover {
629
- background-color: #4f46e5 !important;
630
- cursor: pointer !important;
631
- }
632
- .gradio-input, .gradio-markdown {
633
- font-family: 'Arial', sans-serif;
634
- border-radius: 10px;
635
- padding: 10px;
636
- border: 1px solid #ddd;
637
- margin-bottom: 20px;
 
638
  }
639
 
640
- .gradio-markdown {
641
- background-color: #f7f7f7;
642
  }
643
 
644
- .gradio-row {
645
- justify-content: space-between;
 
 
 
646
  }
647
 
648
- .gradio-column {
649
- display: flex;
650
- flex-direction: column;
651
- justify-content: space-between;
652
  }
653
- .logout-button {
654
- position: absolute;
655
- top: 20px;
656
- right: 20px;
657
- background: none;
658
- border: none;
659
- color: #6366f1;
660
- font-size: 14px;
661
- text-decoration: underline;
662
- cursor: pointer;
663
  }
664
- """
665
- with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
 
666
  gr.Markdown("<CENTER><h1 style='font-size: 22px; font-family: Calibri;'>RedMind GPT</h1></CENTER>")
667
- m=gr.Markdown()
668
  demo.load(update_message, None, m)
669
- logout_button = gr.Button("Logout", link="/logout", elem_id="logout-button")
 
 
 
670
  with gr.Row():
671
- sample_button = gr.Button("What is the expected receiving date and the status of ASN24081900001",elem_id="gradio-button")
672
  sample_button1 = gr.Button("What are the active warehouses available")
673
  sample_button2 = gr.Button("Explain Pre-Receiving Yard Management")
674
  sample_button3 = gr.Button("Can you generate a pie chart with item names and quantities in warehouse WH")
675
- sample_button4 = gr.Button("I want to analyze item name and quantity for different custmers in a stacked bar chart for the warehouse WH", visible=False)
676
 
677
  with gr.Row():
678
- chatbot = gr.Chatbot(
679
- label="Ask a question about the API, Database, a Document or Warehouse inventory analysis.") # .style(color_map=["blue","grey","red"])
680
-
681
 
682
  with gr.Row():
683
  with gr.Column(scale=2):
684
  message = gr.Textbox(show_label=False, container=False, placeholder="Please enter your question")
685
  with gr.Row():
686
- feedback_textbox = gr.Textbox(visible=False, show_label=False,container=False, placeholder = "Please enter your feedback.")
687
  submit_feedback_button = gr.Button("Submit Feedback", visible=False)
688
  with gr.Column(scale=1):
689
  with gr.Row():
690
- #audio_input = gr.Audio(sources=["microphone"], show_label=False, container=False,
691
- # waveform_options=gr.WaveformOptions(show_controls=False))
692
- button = gr.Button("Submit",elem_id="submit")
693
- #gr.ClearButton(message, elem_classes="gr-button", elem_id="clear")
694
 
695
- #button.click(answer_question, [message, chatbot, audio_input], [chatbot])
696
  button.click(answer_question, [message, chatbot], [chatbot])
697
-
698
  message.submit(answer_question, [message, chatbot], [chatbot])
699
- #message.submit(answer_question, [message, chatbot, audio_input], [chatbot])
700
  message.submit(lambda x: gr.update(value=""), None, [message], queue=False)
701
  button.click(lambda x: gr.update(value=''), [], [message])
702
 
703
  chatbot.like(handle_dislike, None, outputs=[feedback_textbox, submit_feedback_button])
704
- submit_feedback_button.click(submit_feedback, [feedback_textbox, chatbot],
705
- [chatbot, feedback_textbox, submit_feedback_button])
706
  submit_feedback_button.click(lambda x: gr.update(value=''), [], [feedback_textbox])
707
 
708
- """sample_button.click(
709
- answer_question,[sample_button, chatbot, audio_input], [chatbot])
710
- sample_button1.click(
711
- answer_question, [sample_button1, chatbot, audio_input], [chatbot])
712
- sample_button2.click(
713
- answer_question, [sample_button2, chatbot, audio_input], [chatbot])
714
- sample_button3.click(
715
- answer_question, [sample_button3, chatbot, audio_input], [chatbot])
716
- sample_button4.click(
717
- answer_question, [sample_button4, chatbot, audio_input], [chatbot])"""
718
- sample_button.click(
719
- answer_question,[sample_button, chatbot], [chatbot])
720
- sample_button1.click(
721
- answer_question, [sample_button1, chatbot], [chatbot])
722
- sample_button2.click(
723
- answer_question, [sample_button2, chatbot], [chatbot])
724
- sample_button3.click(
725
- answer_question, [sample_button3, chatbot], [chatbot])
726
- sample_button4.click(
727
- answer_question, [sample_button4, chatbot], [chatbot])
728
-
729
-
730
-
731
 
732
  demo.launch(auth=[("lakshmi", "redmind"), ("arun", "redmind")])
 
613
 
614
  def update_message(request: gr.Request):
615
  return f"<h4 style='font-size: 22px; font-family: Calibri;'>Welcome, {request.username}</h4>"
 
 
 
 
 
 
 
 
 
 
 
616
 
617
+ # CSS for styling the buttons and other elements
618
+ css = """
619
+ /* Example of custom button styling */
620
+ .gr-button {
621
+ background-color: #4A90E2; /* Change to your desired button color */
622
+ color: white;
623
+ border-radius: 8px; /* Make the corners rounded */
624
+ border: none;
625
+ padding: 10px 20px;
626
+ font-size: 16px;
627
+ cursor: pointer;
628
  }
629
 
630
+ .gr-button:hover {
631
+ background-color: #357ABD; /* Darker shade on hover */
632
  }
633
 
634
+ /* Customizing the Logout link to be on the right */
635
+ .logout-link {
636
+ text-align: right;
637
+ display: inline-block;
638
+ width: 100%;
639
  }
640
 
641
+ .logout-link a {
642
+ color: #4A90E2; /* Link color */
643
+ text-decoration: none;
644
+ font-size: 16px;
645
  }
646
+
647
+ .logout-link a:hover {
648
+ text-decoration: underline; /* Underline on hover */
 
 
 
 
 
 
 
649
  }
650
+ """
651
+
652
+ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
653
  gr.Markdown("<CENTER><h1 style='font-size: 22px; font-family: Calibri;'>RedMind GPT</h1></CENTER>")
654
+ m = gr.Markdown()
655
  demo.load(update_message, None, m)
656
+
657
+ # Logout link styled as text link in the right corner
658
+ gr.Markdown("<div class='logout-link'><a href='/logout'>Logout</a></div>")
659
+
660
  with gr.Row():
661
+ sample_button = gr.Button("What is the expected receiving date and the status of ASN24081900001")
662
  sample_button1 = gr.Button("What are the active warehouses available")
663
  sample_button2 = gr.Button("Explain Pre-Receiving Yard Management")
664
  sample_button3 = gr.Button("Can you generate a pie chart with item names and quantities in warehouse WH")
665
+ sample_button4 = gr.Button("I want to analyze item name and quantity for different customers in a stacked bar chart for the warehouse WH", visible=False)
666
 
667
  with gr.Row():
668
+ chatbot = gr.Chatbot(label="Ask a question about the API, Database, a Document or Warehouse inventory analysis.")
 
 
669
 
670
  with gr.Row():
671
  with gr.Column(scale=2):
672
  message = gr.Textbox(show_label=False, container=False, placeholder="Please enter your question")
673
  with gr.Row():
674
+ feedback_textbox = gr.Textbox(visible=False, show_label=False, container=False, placeholder="Please enter your feedback.")
675
  submit_feedback_button = gr.Button("Submit Feedback", visible=False)
676
  with gr.Column(scale=1):
677
  with gr.Row():
678
+ button = gr.Button("Submit", elem_id="submit")
 
 
 
679
 
 
680
  button.click(answer_question, [message, chatbot], [chatbot])
 
681
  message.submit(answer_question, [message, chatbot], [chatbot])
 
682
  message.submit(lambda x: gr.update(value=""), None, [message], queue=False)
683
  button.click(lambda x: gr.update(value=''), [], [message])
684
 
685
  chatbot.like(handle_dislike, None, outputs=[feedback_textbox, submit_feedback_button])
686
+ submit_feedback_button.click(submit_feedback, [feedback_textbox, chatbot], [chatbot, feedback_textbox, submit_feedback_button])
 
687
  submit_feedback_button.click(lambda x: gr.update(value=''), [], [feedback_textbox])
688
 
689
+ sample_button.click(answer_question, [sample_button, chatbot], [chatbot])
690
+ sample_button1.click(answer_question, [sample_button1, chatbot], [chatbot])
691
+ sample_button2.click(answer_question, [sample_button2, chatbot], [chatbot])
692
+ sample_button3.click(answer_question, [sample_button3, chatbot], [chatbot])
693
+ sample_button4.click(answer_question, [sample_button4, chatbot], [chatbot])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
694
 
695
  demo.launch(auth=[("lakshmi", "redmind"), ("arun", "redmind")])