This project implements a self‑healing Retrieval‑Augmented Generation (RAG) system using LangGraph, Azure OpenAI, Azure Blob Storage, and FAISS.
It supports:
- Automatic ingestion of PDFs from Azure Blob Storage
- Chunking + embedding using Azure OpenAI
- FAISS vector index creation
- Uploading vector store back to Blob Storage
- Query‑time retrieval and prompting
- A self‑healing mechanism that rebuilds FAISS only if missing
- An interactive CLI loop for back‑to‑back questions
If faiss.index or metadata.json are missing, the system automatically:
- Downloads PDFs
- Extracts text
- Splits into chunks
- Embeds using Azure OpenAI
- Builds FAISS index
- Uploads index + metadata to Blob Storage
Each question runs independently:
Every question is injected into a fresh prompt with retrieved context.
The CLI loop lets you ask unlimited questions without rebuilding FAISS.
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
pip install -r requirements.txt
cp config.env.example config.env
- Azure OpenAI endpoint (AZURE_OPENAI_ENDPOINT)
- Azure OpenAI API key (AZURE_OPENAI_API_KEY)
- Embeddings deployment name (AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT)
- Chat model deployment name (AZURE_OPENAI_CHAT_DEPLOYMENT)
- Azure Blob Storage connection string (AZURE_BLOB_CONNECTION)
- Containers for PDFs and vector store (AZURE_BLOB_CONTAINER)
- Containers for vector (FAISS) store (AZURE_BLOB_FAISS_CONTAINER)
python main.py
You will see
RAG system ready. Type 'exit' to quit.
Ask a question: What are the top 2 policies name and premium ? Ask a question: What is the policy expire date ?
Ask a question: What are the top 2 policies name and premium ?
STATUS: Answered query using retrieved context. ANSWER: The top 2 policies are:
- MARSH WALL KEY COVER - £109.00
- MARSH WALL KEY COVER is not the second, actually it is COMBINED RTI AND FINANCE GAP - £594.00
So the top 2 policies by premium are:
- COMBINED RTI AND FINANCE GAP - £594.00
- MARSH WALL KEY COVER - £109.00