File size: 1,387 Bytes
1c3fe08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""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)