moderator-api / test_multilingual.py
Mohameddda's picture
Initial commit
1c3fe08
"""Quick smoke test – sends one sample per supported language."""
import requests
API_URL = "http://127.0.0.1:8000/api/v1/moderate"
HEADERS = {"X-API-Key": "change-me-before-production"}
samples = [
# English
("English (toxic)", "You are an idiot and your family should leave"),
("English (clean)", "Thank you for the wonderful service"),
# Arabic – stronger toxic phrasing
("Arabic (toxic)", "أنت حيوان قذر و غبي يجب أن تموت"),
("Arabic (clean)", "شكراً لكم على الخدمة الممتازة"),
# French – stronger toxic phrasing
("French (toxic)", "Tu es un sale idiot, je vais te tuer espèce de merde"),
("French (clean)", "Merci beaucoup pour votre aide"),
# Italian
("Italian (toxic)", "Sei uno stupido e non vali niente"),
("Italian (clean)", "Grazie mille per il vostro ottimo servizio"),
]
print("-" * 70)
for label, text in samples:
r = requests.post(API_URL, json={"text": text}, headers=HEADERS)
data = r.json()
flag = "🚫" if data["has_bad_words"] else "✅"
lang = data.get("detected_language", "?")
llm = " 🤖LLM" if data.get("llm_verified") else ""
print(f"{flag} [{label}] lang={lang} confidence={data['confidence']:.4f} label={data['label']}{llm}")
print(f" \"{text}\"")
print()
print("-" * 70)