Sanjayraju30 commited on
Commit
9bca5f9
ยท
verified ยท
1 Parent(s): 683e7f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -12
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("# ๐Ÿค– AI-Powered B2B Deal Qualification Engine")
 
 
 
 
 
 
 
 
 
19
 
20
  with gr.Row():
21
- amount = gr.Number(label="Amount")
22
- stage = gr.Dropdown(["Prospecting", "Qualified", "Proposal", "Negotiation", "Closed Won", "Closed Lost"], label="Stage")
23
- industry = gr.Textbox(label="Industry")
24
- lead_score = gr.Number(label="Lead Score")
25
- email_count = gr.Number(label="Email Count")
26
- meeting_count = gr.Number(label="Meeting Count")
27
- close_date_gap = gr.Number(label="Close Date Gap (days)")
28
 
29
- submit_btn = gr.Button("Predict Deal Quality")
 
 
 
 
 
 
 
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],