Spaces:
Sleeping
Sleeping
Update chatbot_ui.py
Browse files- chatbot_ui.py +7 -6
chatbot_ui.py
CHANGED
|
@@ -5,7 +5,7 @@ import random # For generating random responses
|
|
| 5 |
def chatbot_response(user_input):
|
| 6 |
user_input = user_input.lower()
|
| 7 |
|
| 8 |
-
if user_input.strip() == "":
|
| 9 |
return "Welcome! How can I assist you with your studies today?"
|
| 10 |
|
| 11 |
if "time management" in user_input:
|
|
@@ -17,7 +17,7 @@ def chatbot_response(user_input):
|
|
| 17 |
"Use active recall and spaced repetition for better retention.",
|
| 18 |
"Set a specific goal for each study session."
|
| 19 |
]
|
| 20 |
-
return random.choice(tips)
|
| 21 |
|
| 22 |
elif "hello" in user_input or "hi" in user_input:
|
| 23 |
return "Hello! How can I help you with your studies today?"
|
|
@@ -32,15 +32,16 @@ with gr.Blocks() as demo:
|
|
| 32 |
|
| 33 |
with gr.Row():
|
| 34 |
with gr.Column():
|
| 35 |
-
user_input = gr.Textbox(label="Enter your question here:")
|
| 36 |
submit_button = gr.Button("Submit")
|
| 37 |
|
| 38 |
with gr.Column():
|
| 39 |
-
chatbot_output = gr.Textbox(label="Chatbot Response", interactive=False
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
submit_button.click(chatbot_response, inputs=user_input, outputs=chatbot_output)
|
| 42 |
|
| 43 |
# Launch the Gradio app
|
| 44 |
demo.launch()
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 5 |
def chatbot_response(user_input):
|
| 6 |
user_input = user_input.lower()
|
| 7 |
|
| 8 |
+
if user_input.strip() == "":
|
| 9 |
return "Welcome! How can I assist you with your studies today?"
|
| 10 |
|
| 11 |
if "time management" in user_input:
|
|
|
|
| 17 |
"Use active recall and spaced repetition for better retention.",
|
| 18 |
"Set a specific goal for each study session."
|
| 19 |
]
|
| 20 |
+
return random.choice(tips)
|
| 21 |
|
| 22 |
elif "hello" in user_input or "hi" in user_input:
|
| 23 |
return "Hello! How can I help you with your studies today?"
|
|
|
|
| 32 |
|
| 33 |
with gr.Row():
|
| 34 |
with gr.Column():
|
| 35 |
+
user_input = gr.Textbox(label="Enter your question here:", placeholder="Type your question...")
|
| 36 |
submit_button = gr.Button("Submit")
|
| 37 |
|
| 38 |
with gr.Column():
|
| 39 |
+
chatbot_output = gr.Textbox(label="Chatbot Response", interactive=False)
|
| 40 |
+
|
| 41 |
+
# Trigger a welcome message on app launch
|
| 42 |
+
demo.load(lambda: "Welcome! How can I assist you with your studies today?", outputs=chatbot_output)
|
| 43 |
|
| 44 |
submit_button.click(chatbot_response, inputs=user_input, outputs=chatbot_output)
|
| 45 |
|
| 46 |
# Launch the Gradio app
|
| 47 |
demo.launch()
|
|
|
|
|
|