Spaces:
Sleeping
Sleeping
Update chatbot_ui.py
Browse files- chatbot_ui.py +4 -9
chatbot_ui.py
CHANGED
|
@@ -5,11 +5,7 @@ import random # For generating random responses
|
|
| 5 |
def chatbot_response(user_input, history):
|
| 6 |
user_input = user_input.lower()
|
| 7 |
|
| 8 |
-
# Handle
|
| 9 |
-
if user_input.strip() == "":
|
| 10 |
-
return "Welcome! How can I assist you with your studies today?", history
|
| 11 |
-
|
| 12 |
-
# Predefined responses based on user input
|
| 13 |
if "time management" in user_input:
|
| 14 |
return "Time management is key! Try creating a prioritized to-do list and setting specific study blocks.", history
|
| 15 |
|
|
@@ -30,18 +26,17 @@ def chatbot_response(user_input, history):
|
|
| 30 |
# Gradio interface setup
|
| 31 |
with gr.Blocks() as demo:
|
| 32 |
gr.Markdown("# Study Assistance Chatbot")
|
| 33 |
-
gr.Markdown("
|
| 34 |
|
| 35 |
chatbot = gr.Chatbot() # Chat history UI
|
| 36 |
user_input = gr.Textbox(label="Enter your question here:", placeholder="Type your question...") # Textbox for user input
|
| 37 |
submit_button = gr.Button("Submit") # Submit button for user input
|
| 38 |
|
| 39 |
-
# Initialize the chat history
|
| 40 |
-
initial_history = [
|
| 41 |
|
| 42 |
# Submit action - to update chat with response and add it to chat history
|
| 43 |
submit_button.click(chatbot_response, inputs=[user_input, chatbot], outputs=[user_input, chatbot])
|
| 44 |
|
| 45 |
# Launch the Gradio app
|
| 46 |
demo.launch()
|
| 47 |
-
|
|
|
|
| 5 |
def chatbot_response(user_input, history):
|
| 6 |
user_input = user_input.lower()
|
| 7 |
|
| 8 |
+
# Handle time management and study tips
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
if "time management" in user_input:
|
| 10 |
return "Time management is key! Try creating a prioritized to-do list and setting specific study blocks.", history
|
| 11 |
|
|
|
|
| 26 |
# Gradio interface setup
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
gr.Markdown("# Study Assistance Chatbot")
|
| 29 |
+
gr.Markdown("Ask me anything related to your academic studies.")
|
| 30 |
|
| 31 |
chatbot = gr.Chatbot() # Chat history UI
|
| 32 |
user_input = gr.Textbox(label="Enter your question here:", placeholder="Type your question...") # Textbox for user input
|
| 33 |
submit_button = gr.Button("Submit") # Submit button for user input
|
| 34 |
|
| 35 |
+
# Initialize the chat history as an empty list
|
| 36 |
+
initial_history = []
|
| 37 |
|
| 38 |
# Submit action - to update chat with response and add it to chat history
|
| 39 |
submit_button.click(chatbot_response, inputs=[user_input, chatbot], outputs=[user_input, chatbot])
|
| 40 |
|
| 41 |
# Launch the Gradio app
|
| 42 |
demo.launch()
|
|
|