Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -810,6 +810,24 @@ def send_mail_with_history(req: gr.Request,chatbot):
|
|
| 810 |
if req.username:
|
| 811 |
send_email_with_attachment_mailjet("lakshmivairamani@gmail.com","conversation history" + req.username, chatbot)
|
| 812 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 813 |
# CSS for styling the buttons and other elements
|
| 814 |
css = """
|
| 815 |
/* Example of custom button styling */
|
|
@@ -821,8 +839,7 @@ css = """
|
|
| 821 |
padding: 10px 20px;
|
| 822 |
font-size: 12px;
|
| 823 |
cursor: pointer;
|
| 824 |
-
|
| 825 |
-
cursor: text;
|
| 826 |
}
|
| 827 |
|
| 828 |
.gr-button:hover {
|
|
@@ -837,8 +854,7 @@ css = """
|
|
| 837 |
padding: 10px 20px;
|
| 838 |
font-size: 14px;
|
| 839 |
cursor: pointer;
|
| 840 |
-
|
| 841 |
-
cursor: text;
|
| 842 |
}
|
| 843 |
|
| 844 |
.gr-buttonbig:hover {
|
|
@@ -896,6 +912,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 896 |
with gr.Row():
|
| 897 |
with gr.Column(scale=2):
|
| 898 |
message = gr.Textbox(show_label=False, container=False, placeholder="Please enter your question")
|
|
|
|
| 899 |
with gr.Row():
|
| 900 |
feedback_textbox = gr.Textbox(visible=False, show_label=False, container=False, placeholder="Please enter your feedback.")
|
| 901 |
submit_feedback_button = gr.Button("Submit Feedback", visible=False,elem_classes="gr-buttonbig")
|
|
@@ -907,7 +924,8 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 907 |
#gr.ClearButton(message, elem_classes="gr-buttonbig")
|
| 908 |
|
| 909 |
stop_button.click(stop_processing, [chatbot],[chatbot])
|
| 910 |
-
|
|
|
|
| 911 |
button.click(handle_query, [message, chatbot], [chatbot])
|
| 912 |
message.submit(handle_query, [message, chatbot], [chatbot])
|
| 913 |
message.submit(lambda x: gr.update(value=""), None, [message], queue=False)
|
|
|
|
| 810 |
if req.username:
|
| 811 |
send_email_with_attachment_mailjet("lakshmivairamani@gmail.com","conversation history" + req.username, chatbot)
|
| 812 |
|
| 813 |
+
# List of sample autocomplete suggestions
|
| 814 |
+
autocomplete_suggestions = [
|
| 815 |
+
"What is cross docking?",
|
| 816 |
+
"Can you create a bar chart with item name and quantity for warehouse WH1000001",
|
| 817 |
+
"What is GRN?",
|
| 818 |
+
"What are the active warehouses?",
|
| 819 |
+
"How can I learn Python?",
|
| 820 |
+
"Explain machine learning.",
|
| 821 |
+
"What is deep learning?",
|
| 822 |
+
"Give me some tips for learning AI."
|
| 823 |
+
]
|
| 824 |
+
|
| 825 |
+
# Function to suggest matching text based on user input
|
| 826 |
+
def suggest_text(user_input):
|
| 827 |
+
# Filter suggestions based on user input
|
| 828 |
+
matches = [s for s in autocomplete_suggestions if user_input.lower() in s.lower()]
|
| 829 |
+
return matches[:5] # Limit to top 5 suggestions
|
| 830 |
+
|
| 831 |
# CSS for styling the buttons and other elements
|
| 832 |
css = """
|
| 833 |
/* Example of custom button styling */
|
|
|
|
| 839 |
padding: 10px 20px;
|
| 840 |
font-size: 12px;
|
| 841 |
cursor: pointer;
|
| 842 |
+
|
|
|
|
| 843 |
}
|
| 844 |
|
| 845 |
.gr-button:hover {
|
|
|
|
| 854 |
padding: 10px 20px;
|
| 855 |
font-size: 14px;
|
| 856 |
cursor: pointer;
|
| 857 |
+
|
|
|
|
| 858 |
}
|
| 859 |
|
| 860 |
.gr-buttonbig:hover {
|
|
|
|
| 912 |
with gr.Row():
|
| 913 |
with gr.Column(scale=2):
|
| 914 |
message = gr.Textbox(show_label=False, container=False, placeholder="Please enter your question")
|
| 915 |
+
suggestions_output = gr.HighlightedText() # Display matching suggestions
|
| 916 |
with gr.Row():
|
| 917 |
feedback_textbox = gr.Textbox(visible=False, show_label=False, container=False, placeholder="Please enter your feedback.")
|
| 918 |
submit_feedback_button = gr.Button("Submit Feedback", visible=False,elem_classes="gr-buttonbig")
|
|
|
|
| 924 |
#gr.ClearButton(message, elem_classes="gr-buttonbig")
|
| 925 |
|
| 926 |
stop_button.click(stop_processing, [chatbot],[chatbot])
|
| 927 |
+
# Show suggestions as user types
|
| 928 |
+
message.change(suggest_text, inputs=textbox, outputs=suggestions_output)
|
| 929 |
button.click(handle_query, [message, chatbot], [chatbot])
|
| 930 |
message.submit(handle_query, [message, chatbot], [chatbot])
|
| 931 |
message.submit(lambda x: gr.update(value=""), None, [message], queue=False)
|