File size: 1,104 Bytes
ec40afd
32b2742
ec40afd
32b2742
ec40afd
 
32b2742
 
ec40afd
 
 
 
 
 
 
32b2742
 
ec40afd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
import time

import gradio as gr

def open_accordion():
    return gr.Accordion(open=True, label="Test Accordion")

with gr.Blocks() as demo:
    with gr.Column():
        with gr.Accordion(label="Test Accordion", open=False) as accordion:
            temp_slider = gr.Slider(minimum=0, maximum=100,value=50)
            temp_slider.change(lambda x: x, [temp_slider])

        btn = gr.Button(value="Open Accordion")
        btn.click(open_accordion, outputs=[accordion])

        with gr.Tabs():
            with gr.Tab("Chat"):
                chatbot = gr.Chatbot()
                msg = gr.Textbox()

    def user(user_message, history):
        return "", history + [[user_message, None]]

    def bot(history):
        history[-1][1] = ''
        for msg in range(0, 10000):
            history[-1][1] += str(msg)
            if msg % 100 == 0:
                history[-1][1] += '\n'
            time.sleep(0.01)
            yield history

    msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
        fn=bot, inputs=chatbot, outputs=chatbot, api_name='bot',
    )

demo.launch()