Skip to content

A FastAPI-based service for fact-checking tweets and text statements using multiple sources and AI analysis.

Notifications You must be signed in to change notification settings

Ujwal0404/Twitter-Fact-Checker-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

TruthTracker: AI-Powered Twitter Fact-Checking System

TruthTracker is an advanced fact-checking system that uses AI to analyze and verify Twitter content in real-time. It combines multiple search engines, AI analysis, and source credibility assessment to provide comprehensive fact-checking results.

🌟 Features

  • Real-time Tweet Analysis: Fetch and analyze tweets instantly
  • Multi-Source Verification: Aggregate data from Google, DuckDuckGo, and Wikipedia
  • AI-Powered Analysis: Advanced claim verification using Groq AI
  • Source Credibility: Evaluate source reliability and relevance
  • Comprehensive Reports: Detailed fact-checking results with evidence
  • Engagement Analysis: Consider social context and virality
  • Async Processing: Handle multiple requests efficiently

πŸš€ Quick Start

Prerequisites

  • Python 3.9+
  • Twitter API Bearer Token
  • Groq API Key
  • FastAPI
  • uvicorn

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/truthtracker.git
cd truthtracker
  1. Create and activate virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create .env file:
GROQ_API_KEY=your_groq_api_key
TWITTER_BEARER_TOKEN=your_twitter_bearer_token
ENVIRONMENT=development
LOG_LEVEL=INFO
  1. Run the application:
uvicorn app.main:app --reload

πŸ“– API Documentation

Endpoints

Check Tweet

POST /api/v1/check/tweet
{
    "tweet_id": "1234567890",
    "background_check": false
}

Check Text

POST /api/v1/check/text
{
    "text": "Your text to fact check",
    "background_check": false
}

Get Check Status

GET /api/v1/check/{check_id}

Example Response

{
    "check_id": "uuid",
    "status": "completed",
    "started_at": "2024-11-24T12:00:00Z",
    "completed_at": "2024-11-24T12:00:30Z",
    "results": {
        "responses": [
            "Fact Check Results",
            "Evidence Analysis",
            "Source Analysis"
        ],
        "analysis": {
            "verdict": "True/False/Partially True",
            "confidence": "high/medium/low",
            // ... more analysis details
        }
    }
}

πŸ—οΈ Project Structure

fact_checker/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ routes.py      # API endpoints
β”‚   β”‚   β”œβ”€β”€ models.py      # Pydantic models
β”‚   β”‚   └── dependencies.py
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ twitter.py     # Twitter integration
β”‚   β”‚   β”œβ”€β”€ search.py      # Search tools
β”‚   β”‚   β”œβ”€β”€ analysis.py    # Groq analysis
β”‚   β”‚   └── workflow.py    # Fact-check workflow
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── fact_checker.py
β”‚   └── utils/
β”‚       └── logging.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
└── README.md

βš™οΈ Configuration

Environment Variables

Variable Description Required
GROQ_API_KEY Your Groq API key Yes
TWITTER_BEARER_TOKEN Twitter API bearer token Yes
ENVIRONMENT development/production No
LOG_LEVEL INFO/DEBUG/WARNING/ERROR No
CACHE_TTL Cache time-to-live in seconds No
MAX_WORKERS Maximum worker threads No

πŸ› οΈ Development

Running Tests

pytest tests/

Code Style

# Install development dependencies
pip install -r requirements-dev.txt

# Run linter
flake8 app/

# Run type checker
mypy app/

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • FastAPI for the web framework
  • Groq for AI analysis
  • Twitter API for data access
  • All the contributors and supporters

πŸ“ž Support

For support and questions, please open an issue on GitHub.


Built with ❀️ and Python

About

A FastAPI-based service for fact-checking tweets and text statements using multiple sources and AI analysis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages