|
import gradio as gr |
|
from model import score_opportunity |
|
from utils import validate_data |
|
|
|
def predict_deal(amount, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days): |
|
input_data = { |
|
"amount": amount, |
|
"stage": stage, |
|
"industry": industry, |
|
"lead_score": lead_score, |
|
"emails_last_7_days": emails_last_7_days, |
|
"meetings_last_30_days": meetings_last_30_days |
|
} |
|
|
|
if not validate_data(input_data): |
|
return 0, 0.0, "Invalid", "โ ๏ธ Please enter valid numeric values and select a stage." |
|
|
|
result = score_opportunity(input_data) |
|
return result['score'], result['confidence'], 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 |
|
โ
Confidence |
|
โ
AI Recommendation |
|
""") |
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
amount = gr.Number(label="๐ฐ Deal Amount (INR/USD)") |
|
stage = gr.Dropdown( |
|
["Prospecting", "Qualified", "Proposal", "Proposal/Price Quote", "Negotiation", "Closed Won", "Closed Lost"], |
|
label="๐ Deal Stage" |
|
) |
|
industry = gr.Textbox(label="๐ญ Industry (e.g., Software, Healthcare)") |
|
|
|
with gr.Column(): |
|
lead_score = gr.Number(label="๐ Lead Score (0โ100)") |
|
emails_last_7_days = gr.Number(label="โ๏ธ Emails Last 7 Days") |
|
meetings_last_30_days = gr.Number(label="๐
Meetings Last 30 Days") |
|
|
|
submit_btn = gr.Button("๐ Predict Deal") |
|
|
|
with gr.Row(): |
|
score = gr.Number(label="๐งฎ Deal Score (0โ100)", interactive=False) |
|
confidence = gr.Number(label="๐ Confidence (0โ1)", 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, emails_last_7_days, meetings_last_30_days], |
|
outputs=[score, confidence, risk, recommendation]) |
|
|
|
demo.launch() |
|
|