Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,18 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|