Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from model import score_opportunity
|
|
|
|
| 3 |
|
| 4 |
def predict_deal(amount, stage, industry, lead_score, email_count, meeting_count, close_date_gap):
|
| 5 |
input_data = {
|
|
@@ -11,27 +14,47 @@ def predict_deal(amount, stage, industry, lead_score, email_count, meeting_count
|
|
| 11 |
"meeting_count": meeting_count,
|
| 12 |
"close_date_gap": close_date_gap
|
| 13 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
result = score_opportunity(input_data)
|
| 15 |
return result['score'], result['risk'], result['recommendation']
|
| 16 |
|
| 17 |
with gr.Blocks(title="AI Deal Qualification Engine") as demo:
|
| 18 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
with gr.Row():
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
with gr.Row():
|
| 32 |
-
score = gr.Number(label="Score (0โ100)", interactive=False)
|
| 33 |
-
risk = gr.Textbox(label="Risk Level", interactive=False)
|
| 34 |
-
recommendation = gr.Textbox(label="AI Recommendation", lines=2, interactive=False)
|
| 35 |
|
| 36 |
submit_btn.click(fn=predict_deal,
|
| 37 |
inputs=[amount, stage, industry, lead_score, email_count, meeting_count, close_date_gap],
|
|
|
|
| 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, email_count, meeting_count, close_date_gap):
|
| 8 |
input_data = {
|
|
|
|
| 14 |
"meeting_count": meeting_count,
|
| 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 |
+
# ๐ค AI-Powered Deal Qualification Engine
|
| 28 |
+
_Estimate the quality of your B2B opportunity using AI._
|
| 29 |
+
Enter opportunity details below to predict:
|
| 30 |
+
โ
**Deal Score**
|
| 31 |
+
โ
**Risk Level**
|
| 32 |
+
โ
**AI Recommendation**
|
| 33 |
+
"""
|
| 34 |
+
)
|
| 35 |
|
| 36 |
with gr.Row():
|
| 37 |
+
with gr.Column():
|
| 38 |
+
amount = gr.Number(label="๐ฐ Deal Amount (INR/USD)", scale=1)
|
| 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., IT, Healthcare)")
|
| 44 |
|
| 45 |
+
with gr.Column():
|
| 46 |
+
lead_score = gr.Number(label="๐ Lead Score (0โ100)")
|
| 47 |
+
email_count = gr.Number(label="โ๏ธ Email Interactions")
|
| 48 |
+
meeting_count = gr.Number(label="๐
Meeting Count")
|
| 49 |
+
close_date_gap = gr.Number(label="๐ Days Until Expected Close")
|
| 50 |
+
|
| 51 |
+
with gr.Row():
|
| 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, email_count, meeting_count, close_date_gap],
|