Spaces:
Sleeping
Sleeping
| 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() | |