Spaces:
Running
Running
Download run.py from gradio/chatbot_simple: direct link, hf CLI and curl.
- Browser
- Download file 602 Bytes
-
https://huggingface.co/spaces/gradio/chatbot_simple/resolve/main/run.py
- Command line
-
hf download hf://spaces/gradio/chatbot_simple/run.py
-
curl -L -o run.py https://huggingface.co/spaces/gradio/chatbot_simple/resolve/main/run.py
602 Bytes
| 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?", "Today is a great day", "I'm very hungry"]) | |
| chat_history.append({"role": "user", "content": message}) | |
| chat_history.append({"role": "assistant", "content": bot_message}) | |
| time.sleep(2) | |
| return "", chat_history | |
| msg.submit(respond, [msg, chatbot], [msg, chatbot]) | |
| if __name__ == "__main__": | |
| demo.launch() | |