Sanjayraju30 commited on
Commit
d2fb148
ยท
verified ยท
1 Parent(s): 3c079d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -28
app.py CHANGED
@@ -1,63 +1,59 @@
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 = {
9
  "amount": amount,
10
  "stage": stage,
11
  "industry": industry,
12
  "lead_score": lead_score,
13
- "email_count": email_count,
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],
61
- outputs=[score, risk, recommendation])
62
 
63
  demo.launch()
 
 
 
1
  import gradio as gr
2
  from model import score_opportunity
3
  from utils import validate_data
4
 
5
+ def predict_deal(amount, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days):
6
  input_data = {
7
  "amount": amount,
8
  "stage": stage,
9
  "industry": industry,
10
  "lead_score": lead_score,
11
+ "emails_last_7_days": emails_last_7_days,
12
+ "meetings_last_30_days": meetings_last_30_days
 
13
  }
14
 
15
  if not validate_data(input_data):
16
+ return 0, 0.0, "Invalid", "โš ๏ธ Please enter valid numeric values and select a stage."
17
 
18
  result = score_opportunity(input_data)
19
+ return result['score'], result['confidence'], result['risk'], result['recommendation']
20
 
21
  with gr.Blocks(title="AI Deal Qualification Engine") as demo:
22
+ gr.Markdown("""
23
+ # ๐Ÿค– AI-Powered Deal Qualification Engine
24
+ _Estimate the quality of your B2B opportunity using AI._
25
+
26
+ Enter opportunity details below to predict:
27
+ โœ… Deal Score
28
+ โœ… Risk Level
29
+ โœ… Confidence
30
+ โœ… AI Recommendation
31
+ """)
32
 
33
  with gr.Row():
34
  with gr.Column():
35
+ amount = gr.Number(label="๐Ÿ’ฐ Deal Amount (INR/USD)")
36
  stage = gr.Dropdown(
37
+ ["Prospecting", "Qualified", "Proposal", "Proposal/Price Quote", "Negotiation", "Closed Won", "Closed Lost"],
38
  label="๐Ÿ“Š Deal Stage"
39
  )
40
+ industry = gr.Textbox(label="๐Ÿญ Industry (e.g., Software, Healthcare)")
41
 
42
  with gr.Column():
43
  lead_score = gr.Number(label="๐Ÿ“ˆ Lead Score (0โ€“100)")
44
+ emails_last_7_days = gr.Number(label="โœ‰๏ธ Emails Last 7 Days")
45
+ meetings_last_30_days = gr.Number(label="๐Ÿ“… Meetings Last 30 Days")
 
46
 
47
+ submit_btn = gr.Button("๐Ÿ” Predict Deal")
 
48
 
49
  with gr.Row():
50
  score = gr.Number(label="๐Ÿงฎ Deal Score (0โ€“100)", interactive=False)
51
+ confidence = gr.Number(label="๐Ÿ“Š Confidence (0โ€“1)", interactive=False)
52
  risk = gr.Textbox(label="๐Ÿšฆ Risk Level", interactive=False)
53
  recommendation = gr.Textbox(label="๐Ÿง  AI Recommendation", lines=2, interactive=False)
54
 
55
  submit_btn.click(fn=predict_deal,
56
+ inputs=[amount, stage, industry, lead_score, emails_last_7_days, meetings_last_30_days],
57
+ outputs=[score, confidence, risk, recommendation])
58
 
59
  demo.launch()