CoolFace
Apppublic

verastudio/Letter_Maker2

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py61 linesDownload Raw Back to root
1import gradio as gr2from jinja2 import Template3 4# Template for the letter5letter_template = """6{{ salutation }}7 8{{ body_intro }}9 10{{ body_main_content }}11 12{{ body_conclusion }}13 14{{ closing }},15{{ name }}16"""17 18# Function to compile the letter19def compile_letter(salutation, body_intro, body_main_content, body_conclusion, closing, name):20    template = Template(letter_template)21    letter = template.render(22        salutation=salutation,23        body_intro=body_intro,24        body_main_content=body_main_content,25        body_conclusion=body_conclusion,26        closing=closing,27        name=name28    )29    return letter30 31# Gradio interface32def create_interface():33    salutation_example = "Dear Jamie,"34    body_intro_example = "I hope this email finds you well."35    body_main_content_example = "I am writing to express my sincere gratitude for your..."36    body_conclusion_example = "Thank you once again for everything you do."37    closing_example = "Sincerely"38    39    salutation = gr.Textbox(label="Salutation (예: Dear Jamie,)", placeholder=salutation_example, lines=1)40    body_intro = gr.Textbox(label="Body_Intro (예: I hope this email finds you well.)", placeholder=body_intro_example, lines=2)41    body_main_content = gr.Textbox(label="Body_Main_Content (예: I am writing to express my sincere gratitude for your...)", placeholder=body_main_content_example, lines=6)42    body_conclusion = gr.Textbox(label="Body_Conclusion (예: Thank you once again for everything you do.)", placeholder=body_conclusion_example, lines=2)43    closing = gr.Textbox(label="Closing (예: Sincerely)", placeholder=closing_example, lines=1)44    name = gr.Textbox(label="Your Name (예: Your name...)", placeholder="Your name...", lines=1)45    46    letter_output = gr.Textbox(label="Generated Letter", interactive=False, lines=12)47    48    interface = gr.Interface(49        fn=compile_letter,50        inputs=[salutation, body_intro, body_main_content, body_conclusion, closing, name],51        outputs=letter_output,52        title="Email Letter Maker",53        description="Create an email by filling in the sections. You may use the examples provided as a guide."54    )55    56    return interface57 58if __name__ == "__main__":59    interface = create_interface()60    interface.launch()61