Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from agent import generate_email | |
| from email_sender import send_email | |
| def on_generate(to_email, context, tone): | |
| subject, body = generate_email("mistralai/Mistral-7B-Instruct-v0.1", to_email, context, tone) | |
| return subject, body | |
| def on_send(sender_email, to_email, subject, body, refresh_token): | |
| return send_email(sender_email, to_email, subject, body, refresh_token) | |
| with gr.Blocks(theme=gr.themes.Base(), css="body { background-color: #111; color: white; }") as app: | |
| gr.Markdown("## ✉️ Agent d'envoi de mails", elem_id="title") | |
| with gr.Row(): | |
| with gr.Column(): | |
| to_email = gr.Text(label="Destinataire") | |
| context = gr.Text(label="Contexte de l'email") | |
| tone = gr.Dropdown(["Chaleureux", "Formel", "Amical"], value="Chaleureux", label="Ton") | |
| generate_btn = gr.Button("✏️ Générer l'email") | |
| with gr.Column(): | |
| subject_output = gr.Text(label="Objet") | |
| body_output = gr.TextArea(label="Corps de l'email", lines=15) | |
| with gr.Row(): | |
| sender_email = gr.Text(label="Adresse d'envoi (Gmail)") | |
| refresh_token = gr.Text(label="Refresh Token Gmail", type="password") | |
| send_btn = gr.Button("📤 Envoyer le mail") | |
| status = gr.Textbox(label="Statut") | |
| generate_btn.click(on_generate, inputs=[to_email, context, tone], outputs=[subject_output, body_output]) | |
| send_btn.click(on_send, inputs=[sender_email, to_email, subject_output, body_output, refresh_token], outputs=status) | |
| app.launch() | |