CloudyMod is the machine learning toxicity detection service for CloudyAI. It uses transformer-based models via Transformers.js to analyze text for toxic content across multiple languages.
- Multi-Model Support: Uses Xenova/toxic-bert for toxicity classification
- Multi-Language: Automatic language detection via CloudyTrad
- Slang Expansion: Expands common slang/abbreviations before analysis
- Fast Inference: ONNX Runtime for optimized performance
- API Authentication: Token-based security
cd CloudyMod
npm installCreate .env file:
PORT=8001
API_TOKEN=your-secret-token-here
CLOUDYTRAD_URL=http://localhost:5001
CLOUDYTRAD_KEY=your-cloudytrad-token# Development
npm run dev
# Production
npm run build
npm startAnalyze text for toxicity.
Headers:
Authorization: Bearer your-secret-token-here
Content-Type: application/json
Request:
{
"text": "Your text to analyze",
"lang": "auto"
}Response:
{
"scores": {
"toxicity": 0.95,
"severe_toxicity": 0.12,
"obscene": 0.78,
"threat": 0.05,
"insult": 0.82,
"identity_attack": 0.03,
"sexual_explicit": 0.15
},
"language": "en"
}Health check endpoint (no authentication required).
Response:
{
"status": "healthy",
"service": "CloudyMod",
"models": ["toxic-bert"]
}- Xenova/toxic-bert: English toxicity classification
- Uses ONNX Runtime for fast inference
- Models are downloaded automatically on first run
CloudyMod expands common slang before analysis:
kys→kill yourselffdp→fils de putentm→nique ta mère- And many more...
Integrates with CloudyTrad for automatic language detection to route text to the appropriate model.
- Inference Time: ~50-200ms per message
- Memory Usage: ~500MB (with models loaded)
- Concurrent Requests: Handles multiple simultaneous requests
All endpoints except /health require authentication:
curl -X POST http://localhost:8001/v1/ml/analyze \
-H "Authorization: Bearer your-secret-token-here" \
-H "Content-Type: application/json" \
-d '{"text":"test message","lang":"auto"}'- Check internet connection
- Ensure sufficient disk space (~500MB)
- Check Hugging Face availability
- Normal for transformer models
- Consider increasing server RAM to 1GB+
- First request is slower (model loading)
- Subsequent requests are faster (~50-100ms)
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 8001 |
API_TOKEN |
Authentication token | your-secret-token-here |
CLOUDYTRAD_URL |
CloudyTrad service URL | http://localhost:5001 |
CLOUDYTRAD_KEY |
CloudyTrad API token | `` |
CloudyMod is called by CloudyAPI's moderation service:
const response = await fetch('http://localhost:8001/v1/ml/analyze', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ text: message, lang: 'auto' })
});