Satyam0077 commited on
Commit
249e14b
·
verified ·
1 Parent(s): 24a3175

Update app.py

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