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