Sanjayraju30's picture
Update app.py
9bca5f9 verified
raw
history blame
2.34 kB
# 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()