File size: 1,850 Bytes
c4d9410
bc9aa7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from scorer import get_lead_score, calculate_score, calculate_confidence, calculate_risk
from recommender import generate_recommendation

def run_engine(amount, stage, industry, emails, meetings, close_gap):
    lead_score = get_lead_score(stage, emails, meetings, close_gap)
    ai_score = calculate_score(lead_score, emails, meetings, close_gap)
    confidence = calculate_confidence(ai_score)
    risk = calculate_risk(ai_score, confidence, emails, meetings)
    recommendation = generate_recommendation(stage, emails, meetings, risk)

    return lead_score, ai_score, confidence, risk, recommendation

with gr.Blocks(title="B2B Deal Qualification Engine") as demo:
    gr.Markdown("## 🤖 AI-Powered Deal Qualification Engine")

    with gr.Row():
        amount = gr.Number(label="Deal Amount (USD)", value=50000)
        stage = gr.Dropdown(["Prospecting", "Proposal/Price Quote", "Negotiation", "Closed Won", "Closed Lost"], label="Stage")
        industry = gr.Textbox(label="Industry", value="Software")

    with gr.Row():
        emails = gr.Number(label="Emails in Last 7 Days", value=3)
        meetings = gr.Number(label="Meetings in Last 30 Days", value=2)
        close_gap = gr.Number(label="Days Until Close Date", value=10)

    submit = gr.Button("Score Deal")

    with gr.Row():
        lead_score_out = gr.Number(label="Generated Lead Score")
        ai_score_out = gr.Number(label="AI Score (0–100)")
        confidence_out = gr.Number(label="Confidence Level (0–1)")
        risk_out = gr.Textbox(label="Risk Assessment")
        reco_out = gr.Textbox(label="AI Recommendation")

    submit.click(fn=run_engine,
                 inputs=[amount, stage, industry, emails, meetings, close_gap],
                 outputs=[lead_score_out, ai_score_out, confidence_out, risk_out, reco_out])

demo.launch()