Spaces:
Running
Running
Feedback Moderation API - Test Data
Test data for the Wasla Feedback Moderation API.
Configuration
API_URL="http://127.0.0.1:8000/api/v1/moderate"
API_KEY="your-api-key-here"
Health Check
curl http://127.0.0.1:8000/health
Expected Response:
{
"status": "ok",
"multilingual_model_loaded": true,
"arabic_model_loaded": true,
"llm_verification_enabled": false
}
English Test Cases
Toxic Examples
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "You are an idiot and your family should leave"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "This product is terrible and I hate everything about it!"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "You are stupid and worthless"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Shut up you moron, nobody cares about your opinion"}'
Clean Examples
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Thank you for the wonderful service"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "I absolutely love this product!"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "The delivery was fast and the quality exceeded my expectations."}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Great customer support, very helpful team."}'
Arabic Test Cases
Toxic Examples (Arabic)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "أنت حيوان قذر و غبي يجب أن تموت"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "اخرس يا حقير، لا أحد يهتم برأيك"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "أنت غبي جداً ولا تستحق العيش"}'
Clean Examples (Arabic)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "شكراً لكم على الخدمة الممتازة"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "أعجبني المنتج كثيراً، الجودة ممتازة"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "التوصيل كان سريعاً والخدمة رائعة"}'
French Test Cases
Toxic Examples (French)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Tu es un sale idiot, je vais te tuer espèce de merde"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Ferme-la, espèce de débile mental"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Tu ne vaux rien, dégage!"}'
Clean Examples (French)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Merci beaucoup pour votre aide"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Service excellent, je recommande!"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "La livraison était rapide et le produit conforme à la description."}'
Italian Test Cases
Toxic Examples (Italian)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Sei uno stupido e non vali niente"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Stai zitto, idiota! Nessuno ti vuole qui"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Sei un fallito totale, vattene via"}'
Clean Examples (Italian)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Grazie mille per il vostro ottimo servizio"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Prodotto eccellente, consegna veloce!"}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Sono molto soddisfatto del servizio clienti."}'
Edge Cases
Short Text
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "ok"}'
Mixed Language
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello, شكراً for your help"}'
Numbers and Special Characters
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Order #12345 received. Rating: 5/5 stars!"}'
Negative but Non-Toxic Feedback
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "I am disappointed with the late delivery. Please improve."}'
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "The product did not meet my expectations. I would like a refund."}'
Error Cases
Missing API Key
curl -X POST "$API_URL" \
-H "Content-Type: application/json" \
-d '{"text": "test"}'
Expected Response: 403 Forbidden
Invalid API Key
curl -X POST "$API_URL" \
-H "X-API-Key: wrong-key" \
-H "Content-Type: application/json" \
-d '{"text": "test"}'
Expected Response: 403 Forbidden
Empty Text
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": ""}'
Expected Response: 422 Unprocessable Entity
Text Too Long (>5000 chars)
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d "{\"text\": \"$(python -c 'print("x" * 5001)')\"}"
Expected Response: 422 Unprocessable Entity
Python Test Script
import requests
API_URL = "http://127.0.0.1:8000/api/v1/moderate"
API_KEY = "your-api-key-here"
test_cases = [
("en", True, "You are an idiot and your family should leave"),
("en", False, "Thank you for the wonderful service"),
("ar", True, "أنت حيوان قذر و غبي يجب أن تموت"),
("ar", False, "شكراً لكم على الخدمة الممتازة"),
("fr", True, "Tu es un sale idiot, je vais te tuer espèce de merde"),
("fr", False, "Merci beaucoup pour votre aide"),
("it", True, "Sei uno stupido e non vali niente"),
("it", False, "Grazie mille per il vostro ottimo servizio"),
]
headers = {"X-API-Key": API_KEY}
for lang, expected_toxic, text in test_cases:
r = requests.post(API_URL, json={"text": text}, headers=headers)
data = r.json()
flag = "FAIL" if data["has_bad_words"] != expected_toxic else "PASS"
print(f"[{flag}] {lang.upper()} - Expected toxic={expected_toxic}, Got: {data}")
Expected Response Format
{
"has_bad_words": true,
"confidence": 0.9812,
"label": "toxic",
"detected_language": "en",
"llm_verified": false
}
| Field | Type | Description |
|---|---|---|
has_bad_words |
boolean | True if text is toxic (above threshold) |
confidence |
float | Toxicity probability (0.0 - 1.0) |
label |
string | Raw model label (toxic/not_toxic or HATE/NON_HATE) |
detected_language |
string | ISO 639-1 code (en, ar, fr, it, unknown) |
llm_verified |
boolean | True if LLM verification was used |