Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,13 +10,13 @@ classifier = pipeline(
|
|
| 10 |
)
|
| 11 |
|
| 12 |
# Label mapping (MUST match training)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
}
|
| 21 |
|
| 22 |
def classify_request(role, context, request):
|
|
@@ -26,9 +26,11 @@ def classify_request(role, context, request):
|
|
| 26 |
|
| 27 |
# Get highest scoring label
|
| 28 |
best = max(outputs, key=lambda x: x["score"])
|
|
|
|
|
|
|
| 29 |
|
| 30 |
return {
|
| 31 |
-
"Predicted intent":
|
| 32 |
"Confidence": round(best["score"], 3)
|
| 33 |
}
|
| 34 |
|
|
|
|
| 10 |
)
|
| 11 |
|
| 12 |
# Label mapping (MUST match training)
|
| 13 |
+
label_map = {
|
| 14 |
+
"LABEL_0": "administrative_action",
|
| 15 |
+
"LABEL_1": "attendance",
|
| 16 |
+
"LABEL_2": "check_in",
|
| 17 |
+
"LABEL_3": "clarification",
|
| 18 |
+
"LABEL_4": "general_chat",
|
| 19 |
+
"LABEL_5": "technical_help"
|
| 20 |
}
|
| 21 |
|
| 22 |
def classify_request(role, context, request):
|
|
|
|
| 26 |
|
| 27 |
# Get highest scoring label
|
| 28 |
best = max(outputs, key=lambda x: x["score"])
|
| 29 |
+
|
| 30 |
+
readable_label = label_map.get(best["label"], best["label"])
|
| 31 |
|
| 32 |
return {
|
| 33 |
+
"Predicted intent": readable_label,
|
| 34 |
"Confidence": round(best["score"], 3)
|
| 35 |
}
|
| 36 |
|