Spaces:
Sleeping
Sleeping
File size: 5,243 Bytes
f996a72 |
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
---
title: VerifAI News Verification API
emoji: π
colorFrom: purple
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
license: mit
---
# VerifAI - Fake News Detection API
Multi-model fake news detection system for both **text** and **images** with intelligent API management and diverse global news sources.
**Version:** 3.0.0
**Last Updated:** January 2026
## β¨ Features
### Core Detection
- **Text Detection**: BERT + LLM (Gemini 2.0/Groq) + Web Verification
- **Image Detection**: OCR (EasyOCR) + Gemini Vision + Manipulation Analysis
- **Real-time API**: FastAPI with CORS support
### Intelligent API Management
- **6 Gemini API Keys** with smart round-robin rotation
- **Groq Llama 3.1 70B Fallback** when Gemini is exhausted
- **Response Caching** with 1-hour TTL (40-60% API reduction)
- **Rate Limit Detection** with 60-second cooldowns
### Diverse News Sources
- **100+ Trusted Domains** from all continents
- **Unique Domain Per Source** (no duplicate domains)
- Wire Services: Reuters, AP, AFP
- International: BBC, CNN, DW, Al Jazeera, NDTV, SCMP
- Regional coverage: US, UK, Europe, Asia, Africa, Latin America, Oceania
---
## π‘ API Endpoints
### Health Check
```http
GET /
```
Returns API status including cache stats and key health.
### API Key Status
```http
GET /api-status
```
Returns detailed status of all Gemini keys and Groq fallback.
### Text Verification
```http
POST /check
Content-Type: application/json
{"text": "Your news text to verify"}
```
**Response:**
```json
{
"credibility": 85.0,
"verdict": "VERIFIED",
"bert_score": 0.92,
"llm_score": 0.78,
"web_score": 1.0,
"sources": [
{
"title": "BBC News - Article Title",
"url": "https://bbc.com/...",
"trusted": true,
"domain": "bbc.com"
}
]
}
```
### Image Verification (Base64)
```http
POST /check-image
Content-Type: application/json
{"image": "data:image/jpeg;base64,..."}
```
**Response:**
```json
{
"credibility": 75,
"verdict": "LIKELY REAL",
"alert": "β
Content appears mostly credible",
"extracted_text": "Text extracted from image...",
"bert_score": 0.85,
"llm_score": 0.70,
"web_score": 0.8,
"image_manipulation_score": 0.2,
"concerns": "Minor artifacts detected",
"sources": [...]
}
```
### Image Verification (File Upload)
```http
POST /check-image-upload
Content-Type: multipart/form-data
image: <file>
```
### Text Extraction (OCR only)
```http
POST /extract-text
Content-Type: application/json
{"image": "data:image/jpeg;base64,..."}
```
---
## π§ Environment Variables
Set these in **Space Settings β Repository secrets**:
| Variable | Description | Required |
|----------|-------------|----------|
| `GEMINI_API_KEY` | Additional Gemini API key | Optional |
| `GROQ_API_KEY` | Groq API key for fallback | Pre-configured |
> **Note:** 6 Gemini keys are already hardcoded in `app.py`. Environment variables are optional extras.
---
## π Credibility Scoring
| Score Range | Verdict | Description |
|-------------|---------|-------------|
| 80-100% | β
VERIFIED / REAL | Highly credible, matched trusted sources |
| 60-79% | β οΈ LIKELY REAL | Mostly credible, some uncertainty |
| 40-59% | π€ UNCERTAIN | Inconclusive, requires manual review |
| 20-39% | β οΈ LIKELY FAKE | Suspicious patterns detected |
| 0-19% | π¨ FAKE | Strong indicators of misinformation |
---
## π Trusted News Sources
**Wire Services:** Reuters, AP, AFP, UPI
**By Region:**
| Region | Example Sources |
|--------|----------------|
| **US** | NYT, WaPo, WSJ, CNN, NBC, Bloomberg, Forbes |
| **UK** | BBC, Guardian, Telegraph, FT, Economist |
| **Europe** | DW (Germany), France24, El PaΓs, Corriere |
| **Middle East** | Al Jazeera, Arab News, Times of Israel |
| **Asia** | NDTV, Hindu, SCMP, Japan Times, Korea Herald |
| **Africa** | News24, Daily Maverick, AllAfrica |
| **Latin America** | Folha, Infobae, El Universal |
| **Oceania** | ABC Australia, NZ Herald |
---
## π Deployment
### Hugging Face Spaces
1. Create a new Space with **Docker** SDK
2. Upload contents of `huggingface/` folder
3. Space will auto-build and deploy
### Local Development
```bash
cd huggingface
pip install -r requirements.txt
python -m uvicorn app:app --host 127.0.0.1 --port 7860 --reload
```
---
## π Model Information
| Component | Model | Purpose |
|-----------|-------|---------|
| **BERT** | `jy46604790/Fake-News-BERT-Detect` | Binary classification |
| **LLM** | Gemini 2.0 Flash / Groq Llama 3.1 70B | Fact analysis |
| **Vision** | Gemini Vision | Image manipulation detection |
| **OCR** | EasyOCR | Text extraction from images |
| **Search** | DuckDuckGo | Web verification |
---
## π Performance
- **Startup Time:** ~30-60s (model loading)
- **Text Analysis:** 3-8s per request
- **Image Analysis:** 5-12s per request
- **Cache Hit Rate:** 40-60% (reduces API calls)
- **Uptime:** 99.9% (Gemini + Groq redundancy)
---
## π License
MIT License
|