Skip to content
This repository was archived by the owner on Nov 9, 2025. It is now read-only.
FallenProjectsPublic archive

About

Toxicity & NSFW Detector API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Toxicity & NSFW Detector API

A lightweight Rust-powered HTTP microservice to identify toxic or NSFW text in real-time. Perfect for moderation bots, public APIs, or internal tools.


🚀 Features

  • ✅ Detects toxicity, obscenity, sexual explicitness, and more
  • ⚙️ Configurable thresholds per category
  • 🌀 Supports both GET and POST (/check)
  • 🛡️ Auto retries, timeout protection, and flags for review
  • ✅ Simple live demo at / with examples and an input form

🛠️ Quick Start

1. Build & Run Locally

git clone https://github.com/AshokShau/toxicity-detector.git
cd toxicity-detector

# Build the server (Docker or local):
docker build -t toxicity-detector .
docker run -d -p 5001:5001 --name toxic-api toxicity-detector

🔗 Visit http://localhost:5001 / in your browser to test.


2. API Endpoints

GET /check

/check?text=your+message
      &toxicity_threshold=0.5
      &nsfw_threshold=0.2

POST /check

curl -X POST http://localhost:5001/check \
  -H "Content-Type: application/json" \
  -d '{
    "text": "send me your nudes",
    "toxicity_threshold": 0.5,
    "nsfw_threshold": 0.2
}'

Response example:

{
  "text": "send me your nudes",
  "is_bad": true,
  "scores": {
    "toxicity": 43.38,
    "sexual_explicit": 76.13,
    ...
  },
  "thresholds": {
    "toxicity": 50.0,
    "sexual_explicit": 20.0
  },
  "flags": {
    "is_toxic": true,
    "is_nsfw": true,
    "needs_review": true
  }
}

3. / Health + Demo Page

The root path serves a small HTML interface where you:

  • Enter any string in the form
  • See results instantly
  • Find GET/POST links & sample curl commands

This makes testing very straightforward for users or bots.


🔧 Configuration Guide

  • toxicity_threshold, nsfw_threshold — float values between 0–1
  • Lower thresholds → stricter moderation
  • Default values: 0.8 (toxicity), 0.7 (nsfw)
  • max_retries = 2, timeout = 10s (server-side)

📦 Deployment Options

  • Docker: Use the provided Dockerfile
  • Self-hosted VPS: Install Python 3.11+, dependencies, then run

🛡️ License & Credits

  • Based on Detoxify
  • This repo is MIT-licensed — feel free to adapt & improve

🤝 Contributing

Fix a bug? Want new features (like auth, bulk-check)? PRs are welcome!


Thanks for using Toxicity Detector! cc @AshokShau 💙

About

Toxicity & NSFW Detector API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages