Spaces:
Sleeping
Sleeping
File size: 2,039 Bytes
af6f1bd ad54f6d a0e8f2d 3614b91 af6f1bd a0e8f2d 3614b91 af6f1bd 3614b91 a0e8f2d 3614b91 af6f1bd a0e8f2d af6f1bd a0e8f2d af6f1bd a0e8f2d ad54f6d af6f1bd a0e8f2d af6f1bd a0e8f2d af6f1bd a0e8f2d af6f1bd 3614b91 a0e8f2d 3614b91 a0e8f2d 3614b91 af6f1bd a0e8f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # app.py
# Telecom Customer Complaint Classification and Routing App
# Using Hugging Face Transformers + Gradio
from transformers import pipeline
import gradio as gr
# Load zero-shot classification model
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
# Complaint categories
categories = [
"Network Issue",
"Billing Issue",
"SIM Issue",
"Recharge Issue",
"Device Issue"
]
# Mapping categories to routing teams
routing_teams = {
"Network Issue": "Network Operations",
"Billing Issue": "Billing Support",
"SIM Issue": "SIM Support",
"Recharge Issue": "Payments Team",
"Device Issue": "Technical Support"
}
# Function to classify complaint
def classify_complaint(complaint_text):
if not complaint_text.strip():
return "No input provided", "0.0%", "N/A"
result = classifier(complaint_text, candidate_labels=categories)
top_category = result['labels'][0]
confidence_score = result['scores'][0]
suggested_team = routing_teams.get(top_category, "General Support")
confidence_percent = f"{confidence_score*100:.2f}%"
return top_category, confidence_percent, suggested_team
# Build Gradio UI
with gr.Blocks() as demo:
gr.Markdown("## 📞 Telecom Customer Complaint Classification and Routing")
gr.Markdown("Enter a customer complaint below to get category, confidence, and routing team.")
with gr.Row():
complaint_input = gr.Textbox(label="Customer Complaint", placeholder="Type your complaint here...", lines=4)
submit_btn = gr.Button("Submit")
with gr.Row():
category_output = gr.Textbox(label="Predicted Category")
confidence_output = gr.Textbox(label="Confidence Score")
team_output = gr.Textbox(label="Suggested Routing Team")
submit_btn.click(
classify_complaint,
inputs=complaint_input,
outputs=[category_output, confidence_output, team_output]
)
# Launch the app
if __name__ == "__main__":
demo.launch() |