Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import time | |
| def generate(): | |
| text = "Hello, this is a demo without using streaming that emulates a model" | |
| results = "" | |
| for word in text.split(): | |
| time.sleep(0.2) | |
| results += word | |
| results += " " | |
| yield results | |
| with gr.Blocks() as demo: | |
| btn = gr.Button("Generate") | |
| out = gr.Textbox(label="Generation", visible=False) | |
| def change_visibility(): | |
| return { | |
| out: gr.update(visible=True) | |
| } | |
| btn.click(fn=change_visibility, outputs=out) | |
| btn.click(fn=generate, outputs=out) | |
| demo.launch(debug=True) |