This project demonstrates a simple Retrieval-Augmented Generation (RAG) system built using FastAPI, Pinecone, and Google Generative AI. It allows users to upload documents (PDF/DOCX), index their contents for efficient retrieval, and query the indexed documents to receive AI-generated responses.
- Upload multiple PDF and DOCX files for indexing.
- Automatic chunking of documents for efficient retrieval.
- Query the system to receive AI-powered answers based on uploaded content.
- Powered by Pinecone for vector similarity search and Google Generative AI for language model-based responses.
├── app.py # Main FastAPI application
├── example.env # Example environment variables file
├── requirements.txt # Python dependencies for the project
Before running the project, ensure you have the following:
- Python 3.8+ installed on your machine.
- Access to the following API keys:
- Pinecone API Key
- Google API Key
- Docker (optional, for containerized deployment).
git clone <repository-url>
cd <repository-name>python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtRename example.env to .env and update the following variables with your credentials:
PINECONE_API_KEY=<your-pinecone-api-key>
GOOGLE_API_KEY=<your-google-api-key>uvicorn app:app --reloadThe server will start at http://127.0.0.1:8000.
- URL:
/upload_documents/ - Method:
POST - Description: Upload one or more documents (PDF/DOCX) to index their content.
- Request Body: Form data containing file uploads.
- Response: JSON message indicating the number of indexed document chunks.
- URL:
/query/ - Method:
GET - Description: Query the system and get an AI-generated response based on the indexed documents.
- Query Parameter:
query(string) - The question to ask. - Response: JSON containing the query and the generated answer.
curl -X POST "http://127.0.0.1:8000/upload_documents/" \
-H "accept: application/json" \
-F "files=@example.pdf" \
-F "files=@example.docx"curl -X GET "http://127.0.0.1:8000/query/?query=What is data preprocessing?" \
-H "accept: application/json"This project uses the following Python libraries:
fastapiuvicornpineconelangchain_google_genailangchain_communitylangchain_core
Refer to requirements.txt for the full list.