File size: 2,547 Bytes
41a53b2
 
1c48b85
41a53b2
2a09313
1c48b85
 
 
 
 
 
 
 
 
 
41a53b2
1c48b85
41a53b2
1c48b85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a09313
1c48b85
 
41a53b2
1c48b85
 
 
41a53b2
2a09313
 
 
1c48b85
 
 
 
 
 
 
 
 
 
2a09313
 
1c48b85
 
 
 
2a09313
 
1c48b85
2a09313
41a53b2
2a09313
 
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
import gradio as gr
from model import score_opportunity
from datetime import datetime

def predict_deal(amount, close_date, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days):
    try:
        input_data = {
            "amount": amount,
            "close_date": close_date,
            "stage": stage,
            "industry": industry,
            "lead_score": lead_score,
            "emails_last_7_days": emails_last_7_days,
            "meetings_last_30_days": meetings_last_30_days
        }

        result = score_opportunity(input_data)

        score = result["score"]
        confidence = result["confidence"]

        if score >= 80 and confidence >= 0.85:
            recommendation = "βœ… Great potential. Proceed confidently with the deal."
            risk = "Low"
        elif 60 <= score < 80:
            if confidence >= 0.75:
                recommendation = "🟑 Moderate chance. Strengthen customer engagement."
                risk = "Medium"
            else:
                recommendation = "πŸ€” 50/50. Customer interest is unclear. Clarify further."
                risk = "Medium"
        elif score < 60 and (emails_last_7_days + meetings_last_30_days) >= 5:
            recommendation = "πŸ” Investigate – engagement high, but low interest shown."
            risk = "High"
        else:
            recommendation = "⚠️ Low potential. Reassess or de-prioritize."
            risk = "High"

        return score, confidence, risk, recommendation
    except Exception as e:
        return 0, 0.0, "Error", f"Error: {str(e)}"

demo = gr.Interface(
    fn=predict_deal,
    inputs=[
        gr.Number(label="πŸ’° Deal Amount"),
        gr.Textbox(label="πŸ“… Close Date (YYYY-MM-DD)"),
        gr.Dropdown(
            ["Prospecting", "Qualification", "Proposal/Price Quote", "Negotiation/Review", "Closed Won", "Closed Lost"],
            label="πŸ“Š Stage"
        ),
        gr.Textbox(label="🏭 Industry"),
        gr.Slider(0, 100, step=1, label="πŸ“ˆ Lead Score"),
        gr.Number(label="βœ‰οΈ Emails in Last 7 Days"),
        gr.Number(label="πŸ“… Meetings in Last 30 Days"),
    ],
    outputs=[
        gr.Number(label="βœ… Score"),
        gr.Number(label="πŸ“Š Confidence"),
        gr.Textbox(label="⚠️ Risk"),
        gr.Textbox(label="πŸ€– Recommendation"),
    ],
    title="AI Deal Qualification Engine",
    description="Enter opportunity details to get deal score, confidence level, risk, and AI recommendation."
)

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