File size: 3,501 Bytes
d5f320c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3dc5262
d5f320c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3dc5262
 
d5f320c
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# SafeStream AI β€” Intelligent Content Moderation

> AI-powered content moderation using rule-based scoring and reinforcement learning for smarter, faster, and more adaptive decisions.

---

## Features

- *AI toxicity analysis* β€” scores content across multiple harm categories
- *RL-driven decision engine* β€” outputs one of: Allow / Flag / Remove / Review
- *Confidence scoring* β€” quantified certainty on every moderation decision
- *Category breakdown* β€” per-content scores for toxicity, insult, threat, and obscene language
- *Live moderation history* β€” running log of past decisions in the dashboard
- *Real-time stats* β€” dashboard metrics updated on every request
- *Modern UI* β€” clean gradient-styled interface

---

## Architecture


Frontend (HTML/CSS/JS)
        ↓
FastAPI Backend (/moderate)
        ↓
  AI + RL Decision Logic
        ↓
Structured Moderation Output


---

## Tech Stack

| Layer       | Technology                          |
|-------------|-------------------------------------|
| Frontend    | HTML, CSS, JavaScript               |
| Backend     | FastAPI (Python)                    |
| Deployment  | Hugging Face Spaces (Docker)        |
| Model logic | Rule-based scoring + AI (extendable)|

---

## Project Structure


.
β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ templates/
β”‚   └── index.html
└── static/
    β”œβ”€β”€ styles.css
    β”œβ”€β”€ script.js
    └── logo.jpeg


---

## How It Works

1. User submits text via the dashboard
2. Frontend sends a POST request to /moderate
3. Backend analyzes the content using AI scoring + RL logic
4. Response includes a decision, confidence score, explanation, and category breakdown
5. Dashboard updates in real time

---

## API Reference

### POST /moderate

*Request body:*
json
{
  "text": "Your content here"
}


*Response:*
json
{
  "decision": "flag",
  "confidence": 0.85,
  "explanation": "Potentially harmful content detected",
  "ai_scores": {
    "toxicity": 0.8,
    "insult": 0.6,
    "threat": 0.7,
    "obscene": 0.5
  }
}


*Decision values:* allow Β· flag Β· remove Β· review

---

## Running Locally

*1. Clone the repository*
bash
git clone <your-repo-url>
cd safestream-ai


*2. Install dependencies*
bash
pip install -r requirements.txt


*3. Start the server*
bash
uvicorn app:app --reload


*4. Open in browser*

http://127.0.0.1:8000


---

## Deployment

This project is deployed on *Hugging Face Spaces* using Docker.

- Dockerfile handles container setup
- FastAPI app runs on port 7860

---

## Roadmap

- [ ] Integrate real LLM (OpenAI / Anthropic / Perspective API)
- [ ] Train RL agent dynamically on moderation feedback
- [ ] Analytics dashboard with charts
- [ ] Multi-language moderation support
- [ ] User authentication and persistent moderation logs
- [ ] Real-time streaming moderation
- [ ] Webhook support for external integrations

---

## Use Cases

- Social media platforms
- Community forums and Discord servers
- Live chat and messaging apps
- Online gaming platforms
- Content safety pipelines

---

## Author

Built by Team *Good Girls Guide to AI* Β· Systems Β· Product

---

## Inspiration

As online content grows exponentially, scalable and intelligent moderation becomes critical infrastructure. SafeStream AI explores how AI and reinforcement learning can work together to make moderation smarter, faster, and more adaptive β€” reducing both false positives and harmful content slipping through.