Chris4K's picture
Update app.py
eceeded verified
raw
history blame
1.49 kB
from text_generator import TextGenerationTool
# Create an instance of the tool
text_gen_tool = TextGenerationTool()
# Launch the Gradio interface
if __name__ == "__main__":
import gradio as gr
with gr.Blocks(title="Text Generation Tool") as demo:
gr.Markdown("# Text Generation Tool")
with gr.Row():
with gr.Column():
prompt_input = gr.Textbox(
label="Enter your prompt",
placeholder="Write a short story about a robot learning to paint.",
lines=5
)
with gr.Row():
generate_btn = gr.Button("Generate Text")
clear_btn = gr.Button("Clear")
with gr.Column():
output = gr.Textbox(label="Generated Text", lines=15)
generate_btn.click(
fn=text_gen_tool,
inputs=prompt_input,
outputs=output
)
clear_btn.click(
fn=lambda: ("", ""),
inputs=None,
outputs=[prompt_input, output]
)
gr.Examples(
examples=[
["Write a short story about a robot learning to paint."],
["Explain quantum computing to a 10-year-old."],
["Write a poem about the changing seasons."]
],
inputs=prompt_input
)
demo.launch(share=True)