Spaces:
Runtime error
Runtime error
Download app.py from shayan5555/AI-based-Customer-Query-Classification: direct link, hf CLI and curl.
- Browser
- Download file 790 Bytes
-
https://huggingface.co/spaces/shayan5555/AI-based-Customer-Query-Classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/shayan5555/AI-based-Customer-Query-Classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/shayan5555/AI-based-Customer-Query-Classification/resolve/main/app.py
790 Bytes
| from transformers import pipeline | |
| # Load Hugging Face zero-shot classification model | |
| classifier = pipeline("zero-shot-classification", | |
| model="facebook/bart-large-mnli") | |
| # Labels for our AICT problem | |
| labels = ["Complaint", "Request", "Query", "Feedback"] | |
| print("AICT - Smart Customer Message Classifier") | |
| print("------------------------------------------") | |
| print("Type your message below:") | |
| print("Type 'exit' to quit\n") | |
| while True: | |
| text = input("You: ") | |
| if text.lower() == "exit": | |
| break | |
| # AI classification | |
| result = classifier(text, labels) | |
| # Get best prediction | |
| predicted_label = result["labels"][0] | |
| score = result["scores"][0] | |
| print(f"\nPredicted Category: {predicted_label}") | |
| print(f"Confidence: {score:.2f}\n") | |