A Retrieval-Augmented Generation (RAG) application built using FastAPI, LangChain, ChromaDB, and Mistral AI.
This project allows users to upload PDF documents and ask questions about their content. The system retrieves the most relevant document chunks from a vector database and generates grounded answers using Mistral AI.
- PDF document ingestion
- Automatic text chunking
- Mistral Embeddings
- ChromaDB vector storage
- Semantic search and retrieval
- Mistral-powered answer generation
- Source citations
- FastAPI REST API
- Interactive Swagger documentation
- FastAPI
- Uvicorn
- LangChain
- Mistral AI Embeddings
- ChromaDB
- Mistral Small
- PyPDF
├── app
│ ├── ingest.py
│ ├── main.py
│ ├── rag.py
│ └── schemas.py
│
├── data
│ └── deeplearning.pdf
│
├── vectorstore
│ └── chroma.sqlite3
│
├── README.md
└── requirements.txt
git clone https://github.com/maroofiums/AI-Research-Assistant.git
cd AI-Research-Assistantpython -m venv .venvActivate:
Windows:
.venv\Scripts\activateLinux/macOS:
source .venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root.
MISTRAL_API_KEY=your_mistral_api_keyPlace a PDF inside the data directory.
Example:
data/
└── deeplearning.pdf
Run:
from app.ingest import create_vectorstore
create_vectorstore("data/deeplearning.pdf")This process:
- Loads the PDF
- Splits text into chunks
- Generates embeddings
- Stores vectors in ChromaDB
Start FastAPI:
uvicorn app.main:app --reloadServer URL:
http://127.0.0.1:8000
Swagger Documentation:
http://127.0.0.1:8000/docs
GET /Response:
{
"message": "Welcome to AI Research Assistant"
}POST /uploadUpload a PDF file to create embeddings and store them in ChromaDB.
Response:
{
"message": "Document uploaded",
"chunks": 125
}POST /askRequest:
{
"question": "What is backpropagation?"
}Response:
{
"answer": "Backpropagation is a training algorithm used to update neural network weights by propagating errors backward through the network.",
"sources": [
{
"page": 12,
"source": "data/deeplearning.pdf",
"preview": "Backpropagation computes gradients..."
}
]
}PDF
↓
PyPDFLoader
↓
RecursiveCharacterTextSplitter
↓
Mistral Embeddings
↓
ChromaDB
↓
Retriever
↓
Prompt Template
↓
Mistral Small
↓
Answer + Sources
- Upload a PDF document
- Generate embeddings
- Store vectors in ChromaDB
- Ask questions
- Retrieve relevant chunks
- Generate grounded answers
- Return answer with citations
- Multi-document support
- Chat history
- Streaming responses
- Hybrid Search (BM25 + Vector Search)
- Reranking
- LangGraph integration
- Docker deployment
- PostgreSQL + PGVector
- User authentication
- Large PDFs may take time to embed.
- Mistral Embeddings require a valid API key.
- Network interruptions may cause embedding failures during ingestion.