Spaces:
Sleeping
Sleeping
| 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 | |