import gradio as gr # For building the chatbot UI # Chatbot response function def chatbot_response(user_input): if user_input.lower() in ["hello", "hi"]: response = "Hello! How can I help you with your studies today?" else: response = "I'm here to assist with academic questions. Feel free to ask about study tips, time management, or anything else!" # Returning the conversation in the correct format (list of tuples) return [(user_input, response)] # Gradio interface setup with gr.Blocks() as demo: gr.Markdown("# Study Assistance Chatbot") gr.Markdown("Ask me anything related to your academic studies.") chatbot = gr.Chatbot() # Chat history UI user_input = gr.Textbox(label="Enter your question here:", placeholder="Type your question...") # Textbox for user input submit_button = gr.Button("Submit") # Submit button for user input # Submit action - to update chat with response submit_button.click(chatbot_response, inputs=user_input, outputs=chatbot) # Launch the Gradio app demo.launch()