A full-stack, AI-powered web application that automatically extracts claims from uploaded PDFs and fact-checks them against live web sources. Designed specifically to handle "Trap Documents" containing fabricated claims or outdated statistics.
- PDF Parsing: High-fidelity text extraction using PyMuPDF.
- Claim Extraction: Gemini-powered extraction of quantitative claims, dates, and statistics into structured JSON.
- Live Verification: Uses Tavily API to search the live web for evidence supporting or refuting each claim.
- Advanced Evaluation Engine: Differentiates between
VERIFIED,INACCURATE(outdated/partially true), andFALSE(hallucinated) claims. - Beautiful UI: Built with Streamlit, featuring real-time status updates, metric cards, and donut charts.
fact_check_agent/
├── backend/
│ ├── api/ # API endpoints
│ ├── models/ # Pydantic schemas & SQLAlchemy models
│ ├── services/ # Core logic (PDF extraction, LLM, verification)
│ ├── database.py # Database configuration
│ └── main.py # FastAPI application entry point
├── frontend/
│ ├── components/ # UI components
│ ├── utils/ # API communication utils
│ └── app.py # Main Streamlit application
├── tests/ # Generation scripts for trap doc & presentation
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
└── README.md
- Clone the repository and navigate into it.
- Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate pip install -r requirements.txt
- Set up your
.envfile by copying.env.example:Add yourcp .env.example .env
GEMINI_API_KEYandTAVILY_API_KEY.
- Start the FastAPI Backend:
uvicorn backend.main:app --reload --port 8000
- Start the Streamlit Frontend:
Open a new terminal and run:
streamlit run frontend/app.py
- Open your browser to the URL provided by Streamlit (usually
http://localhost:8501).
Run the script to generate a test PDF containing intentionally false and outdated claims:
python tests/generate_trap_doc.pyUpload the generated trap_document.pdf to the Streamlit app to see the verification engine in action.
To generate the architecture slide deck:
python tests/generate_presentation.py