Spaces:
Running
Running
Download components/Chatbot/demos/message_config.py from modelscope/modelscope-studio: direct link, hf CLI and curl.
- Browser
- Download file 815 Bytes
-
https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/refs%2Fpr%2F1/components/Chatbot/demos/message_config.py
- Command line
-
hf download hf://spaces/modelscope/modelscope-studio@refs/pr/1/components/Chatbot/demos/message_config.py
-
curl -L -o message_config.py https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/refs%2Fpr%2F1/components/Chatbot/demos/message_config.py
815 Bytes
| import time | |
| import gradio as gr | |
| import modelscope_studio as mgr | |
| def submit(_chatbot): | |
| _chatbot.append(["test user", | |
| "test bot"]) # bot starts the typewriter by default | |
| yield _chatbot | |
| time.sleep(2) | |
| _chatbot.append(["test user", { | |
| "text": "test bot", | |
| "flushing": False | |
| }]) # both start the typewriter | |
| yield _chatbot | |
| time.sleep(2) | |
| _chatbot.append([{ | |
| "text": "test user", | |
| "flushing": True | |
| }, { | |
| "text": "test bot", | |
| "flushing": False | |
| }]) # user starts the typewriter | |
| yield _chatbot | |
| with gr.Blocks() as demo: | |
| chatbot = mgr.Chatbot(height=600, ) | |
| button = gr.Button("Submit") | |
| button.click(fn=submit, inputs=[chatbot], outputs=[chatbot]) | |
| if __name__ == "__main__": | |
| demo.queue().launch() | |