This project is a demo of a simple Retrieval-Augmented Generation (RAG) system, featuring a FastAPI backend with document ingestion and querying, and a React + Vite frontend for user interaction.
-
Backend (FastAPI, ChromaDB, Transformers):
- Ingest plain text documents into a vector database (ChromaDB)
- Query the database for relevant documents using semantic search
- Generate answers to user questions using a GPT-2 model, augmented with retrieved context
-
Frontend (React, Vite):
- Upload and ingest text files
- Ask questions and receive answers with supporting context
- Simple, modern UI for demo purposes
backend/ main.py # FastAPI app, ChromaDB, GPT-2 integration send_txt_to_api.py # CLI utility to ingest .txt files via API requirements.txt # Python dependencies frontend/ src/App.tsx # Main React app (UI for ingest/query) index.html # HTML entry point package.json # Frontend dependencies vite.config.mts # Vite config -
Install Python dependencies:
cd backend pip install -r requirements.txt -
Run the FastAPI server:
uvicorn main:app --reload
The API will be available at
http://localhost:8000. -
(Optional) Ingest .txt files via CLI:
python send_txt_to_api.py <directory_with_txt_files> # Or specify a custom API URL: python send_txt_to_api.py <dir> --api-url http://localhost:8000/ingest
-
Install Node dependencies:
cd frontend npm install -
Start the development server:
npm run dev
The app will be available at
http://localhost:3000.
-
Ingest Documents:
- Use the web UI to upload
.txtfiles, then click "Ingest". - Or use the CLI utility to batch-ingest files.
- Use the web UI to upload
-
Ask Questions:
- Enter a question in the web UI and click "Query".
- The backend retrieves relevant documents and generates an answer using GPT-2.
- Backend: FastAPI, ChromaDB, Transformers (GPT-2), Torch
- Frontend: React, Vite, TypeScript
- This demo uses GPT-2 for simplicity; for production, use a more capable model.
- ChromaDB is used for vector search; you can swap for other vector DBs as needed.