|
import gradio as gr |
|
|
|
|
|
api = gr.Interface.load("models/bigscience/bloom") |
|
|
|
def change_textbox(choice, textin): |
|
if choice == "short": |
|
return textin[:-50] + api(textin[-50:]) |
|
elif choice == "long": |
|
return textin[:-500] + api(textin[-500:]) |
|
|
|
else: |
|
return gr.Textbox.update(visible=False) |
|
|
|
with gr.Blocks() as block: |
|
radio = gr.Radio( |
|
["short", "long", "none"], label="What kind of essay would you like to write?" |
|
) |
|
textin = gr.Textbox(lines=2, interactive=True) |
|
textout = gr.Textbox(lines=2, interactive=True) |
|
radio.change(fn=change_textbox, inputs=[radio, textin], outputs=textout) |
|
block.launch() |