mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
* clear button * restore * button in interface * changelog * fixes * simplify * changes * components * changed dropdown behavior * fix label * add tests * update demos * changelog * changelog * restore * formatting * revert dropdown * frontend changes * other fixes * changelog * update guide * future * fix tests * fix tests * fix tests * changelog * update guide
20 lines
503 B
Python
20 lines
503 B
Python
import gradio as gr
|
|
import random
|
|
import time
|
|
|
|
with gr.Blocks() as demo:
|
|
chatbot = gr.Chatbot()
|
|
msg = gr.Textbox()
|
|
clear = gr.ClearButton([msg, chatbot])
|
|
|
|
def respond(message, chat_history):
|
|
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
|
chat_history.append((message, bot_message))
|
|
time.sleep(2)
|
|
return "", chat_history
|
|
|
|
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|