Spaces:
Sleeping
Sleeping
Update chatbot_ui.py
Browse files4 unmodified lines5678910115 unmodified lines171819202122238 unmodified lines3233343536373839404142434445464 unmodified linesdef chatbot_response(user_input):user_input = user_input.lower()if user_input.strip() == "": # Show the welcome message for empty inputreturn "Welcome! How can I assist you with your studies today?"if "time management" in user_input:5 unmodified lines"Use active recall and spaced repetition for better retention.","Set a specific goal for each study session."]return random.choice(tips) # Randomly pick a study tipelif "hello" in user_input or "hi" in user_input:return "Hello! How can I help you with your studies today?"8 unmodified lineswith gr.Row():with gr.Column():user_input = gr.Textbox(label="Enter your question here:")submit_button = gr.Button("Submit")with gr.Column():chatbot_output = gr.Textbox(label="Chatbot Response", interactive=False, value="Welcome! How can I assist you with your studies today?")submit_button.click(chatbot_response, inputs=user_input, outputs=chatbot_output)# Launch the Gradio appdemo.launch()4 unmodified lines5678910115 unmodified lines171819202122238 unmodified lines323334353637383940414243444546474 unmodified linesdef chatbot_response(user_input):user_input = user_input.lower()if user_input.strip() == "":return "Welcome! How can I assist you with your studies today?"if "time management" in user_input:5 unmodified lines"Use active recall and spaced repetition for better retention.","Set a specific goal for each study session."]return random.choice(tips)elif "hello" in user_input or "hi" in user_input:return "Hello! How can I help you with your studies today?"8 unmodified lineswith gr.Row():with gr.Column():user_input = gr.Textbox(label="Enter your question here:", placeholder="Type your question...")submit_button = gr.Button("Submit")with gr.Column():chatbot_output = gr.Textbox(label="Chatbot Response", interactive=False)# Trigger a welcome message on app launchdemo.load(lambda: "Welcome! How can I assist you with your studies today?", outputs=chatbot_output)submit_button.click(chatbot_response, inputs=user_input, outputs=chatbot_output)# Launch the Gradio appdemo.launch()
chatbot_ui.py+7-6