Spaces:
Sleeping

Narra123 commited on
Commit
96d4660
·
verified ·
1 Parent(s): acd29a2

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -87
app.py DELETED
@@ -1,87 +0,0 @@
1
- # app.py
2
- # Telecom Customer Complaint Classification and Routing App
3
- # Using Hugging Face Transformers + Gradio
4
-
5
- # Import required libraries
6
- from transformers import pipeline
7
- import gradio as gr
8
-
9
- # -----------------------------
10
- # Step 1: Load Zero-Shot Classification Model
11
- # -----------------------------
12
- # Load the facebook/bart-large-mnli model once at startup
13
- classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
14
-
15
- # -----------------------------
16
- # Step 2: Define Complaint Categories
17
- # -----------------------------
18
- categories = [
19
- "Network Issue",
20
- "Billing Issue",
21
- "SIM Issue",
22
- "Recharge Issue",
23
- "Device Issue"
24
- ]
25
-
26
- # Mapping categories to routing teams
27
- routing_teams = {
28
- "Network Issue": "Network Operations",
29
- "Billing Issue": "Billing Support",
30
- "SIM Issue": "SIM Support",
31
- "Recharge Issue": "Payments Team",
32
- "Device Issue": "Technical Support"
33
- }
34
-
35
- # -----------------------------
36
- # Step 3: Define Prediction Function
37
- # -----------------------------
38
- def classify_complaint(complaint_text):
39
- """
40
- Classify the customer complaint into a category and suggest routing team.
41
- """
42
- if not complaint_text.strip():
43
- return "No input provided", 0.0, "N/A"
44
-
45
- # Use Hugging Face zero-shot classifier
46
- result = classifier(complaint_text, candidate_labels=categories)
47
-
48
- # Get the top category and its confidence score
49
- top_category = result['labels'][0]
50
- confidence_score = result['scores'][0]
51
-
52
- # Map to routing team
53
- suggested_team = routing_teams.get(top_category, "General Support")
54
-
55
- # Format confidence score as percentage
56
- confidence_percent = f"{confidence_score*100:.2f}%"
57
-
58
- return top_category, confidence_percent, suggested_team
59
-
60
- # -----------------------------
61
- # Step 4: Build Gradio UI
62
- # -----------------------------
63
- with gr.Blocks() as demo:
64
- gr.Markdown("## 📞 Telecom Customer Complaint Classification and Routing")
65
- gr.Markdown("Enter a customer complaint below and get the predicted category, confidence score, and suggested routing team.")
66
-
67
- with gr.Row():
68
- complaint_input = gr.Textbox(label="Customer Complaint", placeholder="Type your complaint here...", lines=4)
69
- submit_btn = gr.Button("Submit")
70
-
71
- with gr.Row():
72
- category_output = gr.Textbox(label="Predicted Category")
73
- confidence_output = gr.Textbox(label="Confidence Score")
74
- team_output = gr.Textbox(label="Suggested Routing Team")
75
-
76
- # Connect button to function
77
- submit_btn.click(
78
- classify_complaint,
79
- inputs=complaint_input,
80
- outputs=[category_output, confidence_output, team_output]
81
- )
82
-
83
- # -----------------------------
84
- # Step 5: Launch App
85
- # -----------------------------
86
- if __name__ == "__main__":
87
- demo.launch()