Spaces:
Running
Running
File size: 850 Bytes
630cbf4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import time
import gradio as gr
import modelscope_gradio_components as mgr
def fn(input, chatbot):
chatbot.append([{
"text": input.text,
"files": input.files,
}, None])
yield {
user_input: mgr.MultimodalInput(interactive=False),
user_chatbot: chatbot
}
time.sleep(2)
chatbot[-1][1] = {"text": "Hello!"}
yield {user_chatbot: chatbot}
# 打字机效果结束触发
def flushed():
return mgr.MultimodalInput(interactive=True)
with gr.Blocks() as demo:
user_chatbot = mgr.Chatbot()
user_input = mgr.MultimodalInput()
user_input.submit(fn=fn,
inputs=[user_input, user_chatbot],
outputs=[user_input, user_chatbot])
user_chatbot.flushed(fn=flushed, outputs=[user_input])
if __name__ == "__main__":
demo.queue().launch()
|