Spaces:
Runtime error
Runtime error
File size: 1,816 Bytes
465f2e4 6247140 465f2e4 |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import gradio as gr
from email_generator import (
generate_email,
DEFAULT_GENERATOR, AVAILABLE_GENERATORS
)
with gr.Blocks() as demo:
# -- Description.
gr.Markdown('# Email Generation')
gr.Markdown("""
Start an email and let AI do the rest, courtesy of the HuggingFace community!
AI is supposed to help automate the boring stuff,
and there's nothing more boring to me than writing generic emails.
Use this demo to interact with various HuggingFace models for automatic email generation.
Select a model from the dropdown list to use a specific pretrained model,
or leave it unchanged to default to [pszemraj/opt-350m-email-generation](https://huggingface.co/pszemraj/opt-350m-email-generation).
Then you just have to begin your email and click 'Generate Email' to complete it automatically!
"""
)
gr.Image('bored.jpg', label='Credit: https://unsplash.com/@thomascpark')
# -- Model parameters.
with gr.Row():
model_tag = gr.Dropdown(
choices=AVAILABLE_GENERATORS,
label='Choose a HuggingFace model',
value=DEFAULT_GENERATOR
)
max_tokens = gr.Slider(10, 200, value=64, label='Max Tokens')
# -- Prompt.
with gr.Row():
with gr.Column():
prompt = gr.Textbox(
lines=4,
label='',
placeholder='Begin your email here...'
)
generate_button = gr.Button('Generate Email', variant='primary')
# -- Output.
with gr.Row():
output = gr.Textbox(lines=8, label='Output', interactive=False)
# -- Button actions.
generate_button.click(fn=generate_email, inputs=[model_tag, prompt, max_tokens], outputs=output)
demo.launch()
|