Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from src.inference import predict_ticket #
|
| 3 |
|
| 4 |
def predict_interface(ticket_text):
|
| 5 |
result = predict_ticket(ticket_text)
|
| 6 |
-
issue = result.get(
|
| 7 |
-
urgency = result.get(
|
| 8 |
-
entities = result.get(
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
entities_str = "\n".join(
|
| 16 |
|
| 17 |
return issue, urgency, entities_str
|
| 18 |
|
|
@@ -26,7 +26,7 @@ iface = gr.Interface(
|
|
| 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=(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from src.inference import predict_ticket # Now points to the corrected inference.py
|
| 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 |
+
# Format entity output
|
| 11 |
+
lines = []
|
| 12 |
+
for key in ["products", "dates", "complaints"]:
|
| 13 |
+
vals = entities.get(key, [])
|
| 14 |
+
lines.append(f"{key.capitalize()}: {', '.join(vals) if vals else 'None'}")
|
| 15 |
+
entities_str = "\n".join(lines)
|
| 16 |
|
| 17 |
return issue, urgency, entities_str
|
| 18 |
|
|
|
|
| 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=(
|