Spaces:
Sleeping
Sleeping
Update chatbot_ui.py
Browse files- chatbot_ui.py +9 -6
chatbot_ui.py
CHANGED
|
@@ -3,12 +3,18 @@ import random # For generating random responses
|
|
| 3 |
|
| 4 |
# Chatbot response function
|
| 5 |
def chatbot_response(user_input):
|
|
|
|
| 6 |
user_input = user_input.strip().lower()
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
if "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return "Time management is key! Try creating a prioritized to-do list and setting specific study blocks."
|
| 11 |
|
|
|
|
| 12 |
elif "study tips" in user_input:
|
| 13 |
tips = [
|
| 14 |
"Take regular breaks while studying to stay focused.",
|
|
@@ -17,9 +23,7 @@ def chatbot_response(user_input):
|
|
| 17 |
]
|
| 18 |
return random.choice(tips)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
return "Hello! How can I assist you with your studies today?"
|
| 22 |
-
|
| 23 |
else:
|
| 24 |
return "I'm here to assist with general academic questions. Feel free to ask about study tips, time management, or anything else!"
|
| 25 |
|
|
@@ -37,4 +41,3 @@ with gr.Blocks() as demo:
|
|
| 37 |
|
| 38 |
# Launch the Gradio app
|
| 39 |
demo.launch()
|
| 40 |
-
|
|
|
|
| 3 |
|
| 4 |
# Chatbot response function
|
| 5 |
def chatbot_response(user_input):
|
| 6 |
+
# Ensure the input is in lowercase and stripped of extra spaces
|
| 7 |
user_input = user_input.strip().lower()
|
| 8 |
|
| 9 |
+
# Define responses for specific queries
|
| 10 |
+
if "hello" in user_input or "hi" in user_input:
|
| 11 |
+
return "Hello! How can I help you with your studies today?"
|
| 12 |
+
|
| 13 |
+
# Handle time management query
|
| 14 |
+
elif "time management" in user_input:
|
| 15 |
return "Time management is key! Try creating a prioritized to-do list and setting specific study blocks."
|
| 16 |
|
| 17 |
+
# Handle study tips query
|
| 18 |
elif "study tips" in user_input:
|
| 19 |
tips = [
|
| 20 |
"Take regular breaks while studying to stay focused.",
|
|
|
|
| 23 |
]
|
| 24 |
return random.choice(tips)
|
| 25 |
|
| 26 |
+
# If input doesn't match predefined queries
|
|
|
|
|
|
|
| 27 |
else:
|
| 28 |
return "I'm here to assist with general academic questions. Feel free to ask about study tips, time management, or anything else!"
|
| 29 |
|
|
|
|
| 41 |
|
| 42 |
# Launch the Gradio app
|
| 43 |
demo.launch()
|
|
|