File size: 2,340 Bytes
9bca5f9 41a53b2 9bca5f9 41a53b2 9bca5f9 41a53b2 9bca5f9 41a53b2 9bca5f9 41a53b2 9bca5f9 41a53b2 9bca5f9 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 61 62 63 64 |
# app.py
import gradio as gr
from model import score_opportunity
from utils import validate_data
def predict_deal(amount, stage, industry, lead_score, email_count, meeting_count, close_date_gap):
input_data = {
"amount": amount,
"stage": stage,
"industry": industry,
"lead_score": lead_score,
"email_count": email_count,
"meeting_count": meeting_count,
"close_date_gap": close_date_gap
}
if not validate_data(input_data):
return 0, "Invalid", "โ ๏ธ Please enter valid numeric values and select a stage."
result = score_opportunity(input_data)
return result['score'], 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**
โ
**AI Recommendation**
"""
)
with gr.Row():
with gr.Column():
amount = gr.Number(label="๐ฐ Deal Amount (INR/USD)", scale=1)
stage = gr.Dropdown(
["Prospecting", "Qualified", "Proposal", "Negotiation", "Closed Won", "Closed Lost"],
label="๐ Deal Stage"
)
industry = gr.Textbox(label="๐ญ Industry (e.g., IT, Healthcare)")
with gr.Column():
lead_score = gr.Number(label="๐ Lead Score (0โ100)")
email_count = gr.Number(label="โ๏ธ Email Interactions")
meeting_count = gr.Number(label="๐
Meeting Count")
close_date_gap = gr.Number(label="๐ Days Until Expected Close")
with gr.Row():
submit_btn = gr.Button("๐ Predict Deal")
with gr.Row():
score = gr.Number(label="๐งฎ Deal Score (0โ100)", 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, email_count, meeting_count, close_date_gap],
outputs=[score, risk, recommendation])
demo.launch()
|