File size: 2,344 Bytes
41a53b2
 
9bca5f9
41a53b2
d2fb148
41a53b2
 
 
 
 
d2fb148
 
41a53b2
9bca5f9
 
d2fb148
9bca5f9
41a53b2
d2fb148
41a53b2
 
d2fb148
 
 
 
 
 
 
 
 
 
41a53b2
 
9bca5f9
d2fb148
9bca5f9
d2fb148
9bca5f9
 
d2fb148
41a53b2
9bca5f9
 
d2fb148
 
9bca5f9
d2fb148
41a53b2
 
9bca5f9
d2fb148
9bca5f9
 
41a53b2
 
d2fb148
 
41a53b2
 
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
import gradio as gr
from model import score_opportunity
from utils import validate_data

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

    if not validate_data(input_data):
        return 0, 0.0, "Invalid", "โš ๏ธ Please enter valid numeric values and select a stage."

    result = score_opportunity(input_data)
    return result['score'], result['confidence'], result['risk'], result['recommendation']

with gr.Blocks(title="AI Deal Qualification Engine") as demo:
    gr.Markdown("""
    # ๐Ÿค– AI-Powered Deal Qualification Engine
    _Estimate the quality of your B2B opportunity using AI._

    Enter opportunity details below to predict:
    โœ… Deal Score  
    โœ… Risk Level  
    โœ… Confidence  
    โœ… AI Recommendation
    """)

    with gr.Row():
        with gr.Column():
            amount = gr.Number(label="๐Ÿ’ฐ Deal Amount (INR/USD)")
            stage = gr.Dropdown(
                ["Prospecting", "Qualified", "Proposal", "Proposal/Price Quote", "Negotiation", "Closed Won", "Closed Lost"],
                label="๐Ÿ“Š Deal Stage"
            )
            industry = gr.Textbox(label="๐Ÿญ Industry (e.g., Software, Healthcare)")

        with gr.Column():
            lead_score = gr.Number(label="๐Ÿ“ˆ Lead Score (0โ€“100)")
            emails_last_7_days = gr.Number(label="โœ‰๏ธ Emails Last 7 Days")
            meetings_last_30_days = gr.Number(label="๐Ÿ“… Meetings Last 30 Days")

    submit_btn = gr.Button("๐Ÿ” Predict Deal")

    with gr.Row():
        score = gr.Number(label="๐Ÿงฎ Deal Score (0โ€“100)", interactive=False)
        confidence = gr.Number(label="๐Ÿ“Š Confidence (0โ€“1)", interactive=False)
        risk = gr.Textbox(label="๐Ÿšฆ Risk Level", interactive=False)
        recommendation = gr.Textbox(label="๐Ÿง  AI Recommendation", lines=2, interactive=False)

    submit_btn.click(fn=predict_deal,
                     inputs=[amount, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days],
                     outputs=[score, confidence, risk, recommendation])

demo.launch()