Satyam0077 commited on
Commit
cc07f68
·
verified ·
1 Parent(s): 661107f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -12
app.py CHANGED
@@ -1,18 +1,42 @@
1
  import gradio as gr
2
- from inference import predict_ticket_issue_type, predict_urgency_level
3
 
4
- def analyze_ticket(text):
5
- issue_type = predict_ticket_issue_type(text)
6
- urgency = predict_urgency_level(text)
7
- return f"Issue Type: {issue_type}\nUrgency: {urgency}"
 
8
 
9
- demo = gr.Interface(
10
- fn=analyze_ticket,
11
- inputs=gr.Textbox(lines=4, placeholder="Paste customer ticket here..."),
12
- outputs="text",
13
- title="🎫 Customer Support Ticket Classifier",
14
- description="Predicts the Issue Type and Urgency Level from a support ticket."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  )
16
 
17
  if __name__ == "__main__":
18
- demo.launch()
 
1
  import gradio as gr
2
+ from src.inference import predict_ticket # ✅ Correct import
3
 
4
+ def predict_interface(ticket_text):
5
+ result = predict_ticket(ticket_text)
6
+ issue = result.get('issue_type', 'Unknown')
7
+ urgency = result.get('urgency_level', 'Unknown')
8
+ entities = result.get('entities', {})
9
 
10
+ entities_display = []
11
+ for key in ['products', 'dates', 'complaints']:
12
+ values = entities.get(key, [])
13
+ formatted_values = ', '.join(values) if values else 'None'
14
+ entities_display.append(f"{key.capitalize()}: {formatted_values}")
15
+ entities_str = "\n".join(entities_display)
16
+
17
+ return issue, urgency, entities_str
18
+
19
+ iface = gr.Interface(
20
+ fn=predict_interface,
21
+ inputs=gr.Textbox(
22
+ label="📝 Customer Support Ticket",
23
+ lines=6,
24
+ placeholder="Describe your issue clearly. Example: 'I returned the washing machine on 10th May but no refund received.'"
25
+ ),
26
+ outputs=[
27
+ gr.Textbox(label="📌 Predicted Issue Type", lines=1),
28
+ gr.Textbox(label="⏱️ Predicted Urgency Level", lines=1),
29
+ gr.Textbox(label="🧠 Extracted Entities", lines=6)
30
+ ],
31
+ title="📬 Customer Support Ticket Analyzer",
32
+ description=(
33
+ "Paste a customer support ticket. This tool uses ML to predict:\n"
34
+ "- 📌 Issue Type (e.g., Late Delivery, Refund)\n"
35
+ "- ⏱️ Urgency Level (Low/Medium/High)\n"
36
+ "- 🧠 Extracted Entities (Products, Dates, Complaints)"
37
+ ),
38
+ allow_flagging="never"
39
  )
40
 
41
  if __name__ == "__main__":
42
+ iface.launch()