Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
|
| 3 |
+
# Load Hugging Face zero-shot classification model
|
| 4 |
+
classifier = pipeline("zero-shot-classification",
|
| 5 |
+
model="facebook/bart-large-mnli")
|
| 6 |
+
|
| 7 |
+
# Labels for our AICT problem
|
| 8 |
+
labels = ["Complaint", "Request", "Query", "Feedback"]
|
| 9 |
+
|
| 10 |
+
print("AICT - Smart Customer Message Classifier")
|
| 11 |
+
print("------------------------------------------")
|
| 12 |
+
print("Type your message below:")
|
| 13 |
+
print("Type 'exit' to quit\n")
|
| 14 |
+
|
| 15 |
+
while True:
|
| 16 |
+
text = input("You: ")
|
| 17 |
+
|
| 18 |
+
if text.lower() == "exit":
|
| 19 |
+
break
|
| 20 |
+
|
| 21 |
+
# AI classification
|
| 22 |
+
result = classifier(text, labels)
|
| 23 |
+
|
| 24 |
+
# Get best prediction
|
| 25 |
+
predicted_label = result["labels"][0]
|
| 26 |
+
score = result["scores"][0]
|
| 27 |
+
|
| 28 |
+
print(f"\nPredicted Category: {predicted_label}")
|
| 29 |
+
print(f"Confidence: {score:.2f}\n")
|