import gradio as gr from responser import res # Initialize chat history chat_history = [] def reset_chat(): global chat_history chat_history = [] return chat_history # Create Gradio interface with gr.Blocks() as demo: gr.Markdown("# Doctor Chatbot") # Chat history display chatbox = gr.Chatbot(label="Chat History") # User input user_input = gr.Textbox(placeholder="Welcome - How can I help you?", label="Your Message") # Submit button submit_btn = gr.Button("Send") # Reset button reset_btn = gr.Button("Reset Chat") # Define submission action def submit_message(input_text): if input_text: chat_history = res(input_text) return chat_history # Bind actions submit_btn.click(submit_message, user_input, chatbox) reset_btn.click(reset_chat, None, chatbox) # Launch the Gradio app demo.launch()