File size: 819 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
import time

import gradio as gr

import modelscope_gradio_components as mgr


def submit(_chatbot):
    _chatbot.append(["test user", "test bot"])  # 此时只有 bot 会开启打字机效果
    yield _chatbot
    time.sleep(2)
    _chatbot.append(["test user", {
        "text": "test bot",
        "flushing": False
    }])  # 两者都没有打字机效果
    yield _chatbot
    time.sleep(2)
    _chatbot.append([{
        "text": "test user",
        "flushing": True
    }, {
        "text": "test bot",
        "flushing": False
    }])  # user 会开启打字机效果
    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()