Update app.py
Browse files
app.py
CHANGED
@@ -1,63 +1,59 @@
|
|
1 |
-
# app.py
|
2 |
-
|
3 |
import gradio as gr
|
4 |
from model import score_opportunity
|
5 |
from utils import validate_data
|
6 |
|
7 |
-
def predict_deal(amount, stage, industry, lead_score,
|
8 |
input_data = {
|
9 |
"amount": amount,
|
10 |
"stage": stage,
|
11 |
"industry": industry,
|
12 |
"lead_score": lead_score,
|
13 |
-
"
|
14 |
-
"
|
15 |
-
"close_date_gap": close_date_gap
|
16 |
}
|
17 |
|
18 |
if not validate_data(input_data):
|
19 |
-
return 0, "Invalid", "โ ๏ธ Please enter valid numeric values and select a stage."
|
20 |
|
21 |
result = score_opportunity(input_data)
|
22 |
-
return result['score'], result['risk'], result['recommendation']
|
23 |
|
24 |
with gr.Blocks(title="AI Deal Qualification Engine") as demo:
|
25 |
-
gr.Markdown(
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
)
|
35 |
|
36 |
with gr.Row():
|
37 |
with gr.Column():
|
38 |
-
amount = gr.Number(label="๐ฐ Deal Amount (INR/USD)"
|
39 |
stage = gr.Dropdown(
|
40 |
-
["Prospecting", "Qualified", "Proposal", "Negotiation", "Closed Won", "Closed Lost"],
|
41 |
label="๐ Deal Stage"
|
42 |
)
|
43 |
-
industry = gr.Textbox(label="๐ญ Industry (e.g.,
|
44 |
|
45 |
with gr.Column():
|
46 |
lead_score = gr.Number(label="๐ Lead Score (0โ100)")
|
47 |
-
|
48 |
-
|
49 |
-
close_date_gap = gr.Number(label="๐ Days Until Expected Close")
|
50 |
|
51 |
-
|
52 |
-
submit_btn = gr.Button("๐ Predict Deal")
|
53 |
|
54 |
with gr.Row():
|
55 |
score = gr.Number(label="๐งฎ Deal Score (0โ100)", interactive=False)
|
|
|
56 |
risk = gr.Textbox(label="๐ฆ Risk Level", interactive=False)
|
57 |
recommendation = gr.Textbox(label="๐ง AI Recommendation", lines=2, interactive=False)
|
58 |
|
59 |
submit_btn.click(fn=predict_deal,
|
60 |
-
inputs=[amount, stage, industry, lead_score,
|
61 |
-
outputs=[score, risk, recommendation])
|
62 |
|
63 |
demo.launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from model import score_opportunity
|
3 |
from utils import validate_data
|
4 |
|
5 |
+
def predict_deal(amount, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days):
|
6 |
input_data = {
|
7 |
"amount": amount,
|
8 |
"stage": stage,
|
9 |
"industry": industry,
|
10 |
"lead_score": lead_score,
|
11 |
+
"emails_last_7_days": emails_last_7_days,
|
12 |
+
"meetings_last_30_days": meetings_last_30_days
|
|
|
13 |
}
|
14 |
|
15 |
if not validate_data(input_data):
|
16 |
+
return 0, 0.0, "Invalid", "โ ๏ธ Please enter valid numeric values and select a stage."
|
17 |
|
18 |
result = score_opportunity(input_data)
|
19 |
+
return result['score'], result['confidence'], result['risk'], result['recommendation']
|
20 |
|
21 |
with gr.Blocks(title="AI Deal Qualification Engine") as demo:
|
22 |
+
gr.Markdown("""
|
23 |
+
# ๐ค AI-Powered Deal Qualification Engine
|
24 |
+
_Estimate the quality of your B2B opportunity using AI._
|
25 |
+
|
26 |
+
Enter opportunity details below to predict:
|
27 |
+
โ
Deal Score
|
28 |
+
โ
Risk Level
|
29 |
+
โ
Confidence
|
30 |
+
โ
AI Recommendation
|
31 |
+
""")
|
32 |
|
33 |
with gr.Row():
|
34 |
with gr.Column():
|
35 |
+
amount = gr.Number(label="๐ฐ Deal Amount (INR/USD)")
|
36 |
stage = gr.Dropdown(
|
37 |
+
["Prospecting", "Qualified", "Proposal", "Proposal/Price Quote", "Negotiation", "Closed Won", "Closed Lost"],
|
38 |
label="๐ Deal Stage"
|
39 |
)
|
40 |
+
industry = gr.Textbox(label="๐ญ Industry (e.g., Software, Healthcare)")
|
41 |
|
42 |
with gr.Column():
|
43 |
lead_score = gr.Number(label="๐ Lead Score (0โ100)")
|
44 |
+
emails_last_7_days = gr.Number(label="โ๏ธ Emails Last 7 Days")
|
45 |
+
meetings_last_30_days = gr.Number(label="๐
Meetings Last 30 Days")
|
|
|
46 |
|
47 |
+
submit_btn = gr.Button("๐ Predict Deal")
|
|
|
48 |
|
49 |
with gr.Row():
|
50 |
score = gr.Number(label="๐งฎ Deal Score (0โ100)", interactive=False)
|
51 |
+
confidence = gr.Number(label="๐ Confidence (0โ1)", interactive=False)
|
52 |
risk = gr.Textbox(label="๐ฆ Risk Level", interactive=False)
|
53 |
recommendation = gr.Textbox(label="๐ง AI Recommendation", lines=2, interactive=False)
|
54 |
|
55 |
submit_btn.click(fn=predict_deal,
|
56 |
+
inputs=[amount, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days],
|
57 |
+
outputs=[score, confidence, risk, recommendation])
|
58 |
|
59 |
demo.launch()
|