File size: 797 Bytes
3bea7ba
2dcd846
 
3bea7ba
3737c61
2dcd846
a1bc5b4
3737c61
a1bc5b4
3737c61
be692a1
3737c61
 
4954a39
4cccde5
1cda688
4954a39
 
 
 
2dcd846
4954a39
dd1408d
 
2dcd846
4cccde5
6927fc4
2dcd846
3737c61
4954a39
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
import subprocess

subprocess.run("pip install ./textgen.zip", shell=True)

import gradio as gr

from textgen import load

textgen = load()

def generate(text, length=50):
    return textgen.generate(text, length=length)

with gr.Blocks() as app:
    gr.Markdown("# 🦊 textgen")
    with gr.Column(variant="panel"):
        with gr.Row():
            text = gr.TextArea(label="Text")
        with gr.Row():
            length = gr.Number(label="Length", value=25)
            
    with gr.Row(variant="panel"):
        btn = gr.Button("Generate", variant="primary")
        clear = gr.Button("Clear")
        
    btn.click(generate, [text, length], [text])
    clear.click(lambda: "", None, [text], queue=False)
    
if __name__ == "__main__":
    app.queue().launch(debug=True, ssr_mode=False)