Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,30 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from scorer import get_lead_score, calculate_score, calculate_confidence, calculate_risk
|
| 3 |
from recommender import generate_recommendation
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
def run_engine(amount, stage, industry, emails, meetings, close_gap):
|
| 6 |
-
lead_score = get_lead_score(stage, emails, meetings, close_gap)
|
| 7 |
-
ai_score = calculate_score(lead_score, emails, meetings, close_gap)
|
| 8 |
confidence = calculate_confidence(ai_score)
|
| 9 |
risk = calculate_risk(ai_score, confidence, emails, meetings)
|
| 10 |
recommendation = generate_recommendation(stage, emails, meetings, risk)
|
|
|
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
with gr.Row():
|
| 18 |
amount = gr.Number(label="Deal Amount (USD)", value=50000)
|
|
@@ -22,19 +34,23 @@ with gr.Blocks(title="B2B Deal Qualification Engine") as demo:
|
|
| 22 |
with gr.Row():
|
| 23 |
emails = gr.Number(label="Emails in Last 7 Days", value=3)
|
| 24 |
meetings = gr.Number(label="Meetings in Last 30 Days", value=2)
|
| 25 |
-
close_gap = gr.Number(label="Days Until Close Date", value=
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
with gr.Row():
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 34 |
reco_out = gr.Textbox(label="AI Recommendation")
|
|
|
|
| 35 |
|
| 36 |
submit.click(fn=run_engine,
|
| 37 |
-
inputs=[amount, stage, industry, emails, meetings, close_gap],
|
| 38 |
-
outputs=[lead_score_out, ai_score_out, confidence_out, risk_out, reco_out])
|
| 39 |
|
| 40 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from scorer import get_lead_score, calculate_score, calculate_confidence, calculate_risk
|
| 3 |
from recommender import generate_recommendation
|
| 4 |
+
from insights import explain_score
|
| 5 |
+
from logger import log_submission
|
| 6 |
|
| 7 |
+
def run_engine(amount, stage, industry, emails, meetings, close_gap, feedback=""):
|
| 8 |
+
lead_score = get_lead_score(stage, emails, meetings, close_gap, amount)
|
| 9 |
+
ai_score = calculate_score(lead_score, emails, meetings, close_gap, amount)
|
| 10 |
confidence = calculate_confidence(ai_score)
|
| 11 |
risk = calculate_risk(ai_score, confidence, emails, meetings)
|
| 12 |
recommendation = generate_recommendation(stage, emails, meetings, risk)
|
| 13 |
+
explanation = explain_score(lead_score, ai_score, confidence, risk, stage, close_gap, emails, meetings)
|
| 14 |
|
| 15 |
+
# Simulate logging (can be extended to DB)
|
| 16 |
+
log_submission({
|
| 17 |
+
"amount": amount, "stage": stage, "industry": industry,
|
| 18 |
+
"emails": emails, "meetings": meetings, "gap": close_gap,
|
| 19 |
+
"lead_score": lead_score, "score": ai_score, "confidence": confidence,
|
| 20 |
+
"risk": risk, "feedback": feedback
|
| 21 |
+
})
|
| 22 |
|
| 23 |
+
return lead_score, ai_score, confidence, risk, recommendation, explanation
|
| 24 |
+
|
| 25 |
+
with gr.Blocks(title="AI Deal Qualification Engine") as app:
|
| 26 |
+
gr.Markdown("# 🤖 AI-Powered Deal Qualification Engine")
|
| 27 |
+
gr.Markdown("Score deals intelligently using pipeline stage, engagement, and timing.")
|
| 28 |
|
| 29 |
with gr.Row():
|
| 30 |
amount = gr.Number(label="Deal Amount (USD)", value=50000)
|
|
|
|
| 34 |
with gr.Row():
|
| 35 |
emails = gr.Number(label="Emails in Last 7 Days", value=3)
|
| 36 |
meetings = gr.Number(label="Meetings in Last 30 Days", value=2)
|
| 37 |
+
close_gap = gr.Number(label="Days Until Close Date", value=14)
|
| 38 |
|
| 39 |
+
feedback = gr.Textbox(label="Optional: Rep Feedback")
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
+
submit = gr.Button("Run AI Scoring")
|
| 43 |
+
|
| 44 |
+
with gr.Accordion("📊 Results", open=True):
|
| 45 |
+
lead_score_out = gr.Number(label="Lead Score (Generated)", interactive=False)
|
| 46 |
+
ai_score_out = gr.Number(label="AI Score (0–100)", interactive=False)
|
| 47 |
+
confidence_out = gr.Number(label="Confidence", interactive=False)
|
| 48 |
+
risk_out = gr.Textbox(label="Risk Level")
|
| 49 |
reco_out = gr.Textbox(label="AI Recommendation")
|
| 50 |
+
explain_out = gr.Textbox(label="AI Explanation")
|
| 51 |
|
| 52 |
submit.click(fn=run_engine,
|
| 53 |
+
inputs=[amount, stage, industry, emails, meetings, close_gap, feedback],
|
| 54 |
+
outputs=[lead_score_out, ai_score_out, confidence_out, risk_out, reco_out, explain_out])
|
| 55 |
|
| 56 |
+
app.launch()
|