File size: 5,192 Bytes
bd87812
 
 
d95c8a2
bd87812
 
999e8fb
 
 
 
 
d5402bf
999e8fb
 
 
bd87812
d95c8a2
999e8fb
 
 
 
 
 
 
 
 
d95c8a2
1f0e026
d5402bf
 
fa65e28
d5402bf
 
1f0e026
 
d5402bf
 
cadd938
 
 
 
 
 
999e8fb
 
 
 
d5402bf
999e8fb
 
 
fa65e28
999e8fb
 
 
 
fa65e28
999e8fb
 
cadd938
d5402bf
 
 
 
 
 
 
 
 
 
 
 
1f0e026
d95c8a2
1f0e026
 
fa65e28
1f0e026
 
d95c8a2
1f0e026
 
 
999e8fb
1f0e026
cadd938
d5402bf
999e8fb
 
 
 
 
 
 
 
bd87812
d5402bf
 
 
 
 
 
 
 
1f0e026
 
999e8fb
1f0e026
cadd938
d5402bf
999e8fb
 
 
1f0e026
d5402bf
 
 
 
 
 
 
 
1f0e026
d95c8a2
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import gradio as gr
import pandas as pd
from enrich import enrich_and_score
from llm_email import generate_email_templates

def process_leads(file):
    if file is None:
        return None, "❌ No file uploaded! Please upload a CSV."
    try:
        df = pd.read_csv(file.name)
        enriched_df = enrich_and_score(df)
        enriched_df = enriched_df.drop_duplicates(subset='Company Name', keep='first')
        return enriched_df, "βœ… Leads enriched successfully!"
    except Exception as e:
        return None, f"❌ Error processing file: {str(e)}"

def generate_emails(file):
    if file is None:
        return "", "❌ No file uploaded! Please upload a CSV."
    try:
        df = pd.read_csv(file.name)
        enriched_df = enrich_and_score(df)
        email_templates = generate_email_templates(enriched_df)
        return email_templates, "βœ… Email templates generated!"
    except Exception as e:
        return "", f"❌ Error generating emails: {str(e)}"

with gr.Blocks(css="""
    body {background-color: #0f172a; color: #e2e8f0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;}
    .gradio-container {max-width: 1000px; margin: auto; padding: 20px;}
    h1 {color: #38bdf8; font-weight: 700; font-size: 2.5em;}
    p {color: #94a3b8;}
    .tab {background-color: #1e293b; border-radius: 10px; padding: 20px; margin-top: 20px;}
    .btn-primary {background-color: #2563eb !important; border: none !important; color: white !important;}
    .btn-primary:hover {background-color: #1e40af !important;}
    .gr-dataframe {border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.9); background-color: #334155;}
    .gr-textbox {font-family: monospace; font-size: 14px; background-color: #334155; color: #e0e0e0;}
    .full-width-btn {
        width: 100% !important;
        padding: 12px 0 !important;
        font-weight: 600 !important;
        font-size: 1.1em !important;
        border-radius: 6px !important;
        margin-top: 10px;
    }
    .file-info {
        font-style: italic;
        color: #94a3b8;
        margin-bottom: 8px;
    }
    .message-success {
        color: #22c55e;
        font-weight: 600;
        margin-top: 8px;
    }
    .message-error {
        color: #ef4444;
        font-weight: 600;
        margin-top: 8px;
    }
    .gr-box {
        background-color: #1e293b;
        border-radius: 10px;
        padding: 20px;
    }
    .analytics-box {
        background-color: #0f172a;
        padding: 10px;
        margin-top: 10px;
        border-left: 4px solid #38bdf8;
        color: #cbd5e1;
    }
""") as app:

    gr.Markdown("""
    <h1 style="text-align:center; margin-bottom: 0;">πŸš€ SmartLeadBoost</h1>
    <p style="text-align:center; margin-top: 5px;">
    Upload your leads CSV to get enriched data & AI-crafted outreach emails!</p>
    """)

    with gr.Tabs():
        with gr.TabItem("πŸ“Š Enrich Leads", elem_classes="tab"):
            lead_input = gr.File(label="Upload CSV (Company Name, Website)", file_types=['.csv'], interactive=True)
            lead_file_info = gr.Markdown("", elem_classes="file-info")
            lead_output = gr.Dataframe(label="Enriched Leads with Scores", interactive=False)
            enrich_btn = gr.Button("✨ Enrich Leads", variant="primary", elem_classes="full-width-btn")
            lead_message = gr.Markdown("", elem_classes="message-success")

            def update_file_info(file):
                if file is None:
                    return ""
                return f"Uploaded file: **{file.name}** ({round(file.size/1024, 2)} KB)"

            lead_input.upload(update_file_info, lead_input, lead_file_info)
            enrich_btn.click(fn=process_leads, inputs=lead_input, outputs=[lead_output, lead_message], show_progress=True)

            gr.Markdown("""
            <div class="analytics-box">
                βœ… Leads are automatically deduplicated.<br>
                πŸ“ˆ Prioritized by relevance & enrichment score.<br>
                πŸ“€ Export enriched data to CSV from top-right corner.
            </div>
            """)

        with gr.TabItem("βœ‰οΈ AI Outreach Emails", elem_classes="tab"):
            email_input = gr.File(label="Upload the Same CSV", file_types=['.csv'], interactive=True)
            email_file_info = gr.Markdown("", elem_classes="file-info")
            email_output = gr.Textbox(label="AI-Generated Email Templates", lines=18, interactive=False)
            email_btn = gr.Button("πŸ“§ Generate Email Templates", variant="primary", elem_classes="full-width-btn")
            email_message = gr.Markdown("", elem_classes="message-success")

            email_input.upload(update_file_info, email_input, email_file_info)
            email_btn.click(fn=generate_emails, inputs=email_input, outputs=[email_output, email_message], show_progress=True)

            gr.Markdown("""
            <div class="analytics-box">
                πŸ’¬ Emails generated using GPT-based models.<br>
                🌍 Support for multiple tones, languages, and sender info coming soon.<br>
                πŸ”’ No emails are stored. 100% safe!
            </div>
            """)

if __name__ == "__main__":
    app.launch()