Spaces:
Runtime error
Runtime error
Download Demo Basic Streaming.py from bumk766fall2023/ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 724 Bytes
-
https://huggingface.co/spaces/bumk766fall2023/ChatBot/resolve/main/Demo%20Basic%20Streaming.py
- Command line
-
hf download 'hf://spaces/bumk766fall2023/ChatBot/Demo Basic Streaming.py'
-
curl -L -o 'Demo Basic Streaming.py' https://huggingface.co/spaces/bumk766fall2023/ChatBot/resolve/main/Demo%20Basic%20Streaming.py
724 Bytes
| import gradio as gr | |
| import random | |
| import time | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot() | |
| msg = gr.Textbox() | |
| def user(user_message, history): | |
| return "", history + [[user_message, None]] | |
| def bot(history): | |
| bot_message = "The Moon, Earth s only natural satellite and the fifth largest moon in our Solar System, is a celestial body that orbits our planet approximately every 27.3 days." | |
| history[-1][1] = "" | |
| for character in bot_message: | |
| history[-1][1] += character | |
| time.sleep(0.05) | |
| yield history | |
| msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then( | |
| bot, chatbot, chatbot | |
| ) | |
| demo.queue() | |
| demo.launch() |