Spaces:
Runtime error
Runtime error
File size: 976 Bytes
fe97494 c93bd12 fe97494 9ef5d40 5198906 fe97494 c93bd12 1f2cd00 c93bd12 3cae8c2 c93bd12 3cae8c2 c93bd12 1f2cd00 |
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 |
import gradio as gr
import time
def generate_no_stream():
text = "Hello, this is a demo without using streaming that emulates a model"
time.sleep(2.4)
return text
def generate_streaming():
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_non_stream = gr.Textbox(label="Non-streaming Generation")
out_stream = gr.Textbox(label="Streaming Generation")
def change_visibility():
return {
out_non_stream: gr.update(visible=True),
out: gr.update(visible=True),
}
btn.click(fn=change_visibility, outputs=[out_non_stream, out_stream])
btn.click(fn=generate_no_stream, outputs=out_non_stream)
btn.click(fn=generate_streaming, outputs=out_stream)
demo.launch(debug=True) |