File size: 1,550 Bytes
e813d54
99d6843
e813d54
8fe992b
0c1dca0
99d6843
e813d54
9b5b26a
73a7679
 
8c01ffb
73a7679
 
99d6843
 
73a7679
 
 
 
 
99d6843
73a7679
 
 
ae7a494
e813d54
73a7679
 
 
 
531d9ae
73a7679
 
8c01ffb
73a7679
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
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()