Update app.py
Browse files73 unmodified lines74757677787980818283848586878889909192939495969773 unmodified lineshistory[-1][1] = ""for character in bot_message:history[-1][1] += charactertime.sleep(0.01) # Adjust the speed hereyield history# Define Gradio Blocks interface with a submit buttonwith gr.Blocks() as demo:chatbot = gr.Chatbot()msg = gr.Textbox(placeholder="Type your message here...")submit_btn = gr.Button("Submit")clear = gr.Button("Clear")def handle_message(user_message, history):history = user(user_message, history)return bot(history)# Bind the submit button to handle_message functionsubmit_btn.click(handle_message, [msg, chatbot], chatbot, queue=False)# Bind the clear button to clear the chat historyclear.click(lambda: None, None, chatbot, queue=False)if __name__ == "__main__":73 unmodified lines74757677787980818283848586878889909173 unmodified lineshistory[-1][1] = ""for character in bot_message:history[-1][1] += charactertime.sleep(0.01) # Reduced sleep time to make response appear fasteryield history# Define Gradio Blocks interfacewith gr.Blocks() as demo:chatbot = gr.Chatbot()msg = gr.Textbox()clear = gr.Button("Clear")msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)clear.click(lambda: None, None, chatbot, queue=False)if __name__ == "__main__":
app.py+6-12