Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangGraph RAG Pipeline (Self‑Healing, Azure‑Native)

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

🚀 Features

✔ Self‑Healing Vector Store

If faiss.index or metadata.json are missing, the system automatically:

  1. Downloads PDFs
  2. Extracts text
  3. Splits into chunks
  4. Embeds using Azure OpenAI
  5. Builds FAISS index
  6. Uploads index + metadata to Blob Storage

✔ Stateless Querying

Each question runs independently:

✔ Dynamic Prompting

Every question is injected into a fresh prompt with retrieved context.

✔ Back‑to‑Back Questions

The CLI loop lets you ask unlimited questions without rebuilding FAISS.


📁 Project Structure


🔧 Installation

1. Create a virtual environment

python -m venv venv
source venv/bin/activate   # macOS/Linux
venv\Scripts\activate      # Windows

2. Install dependencies

pip install -r requirements.txt

🔐 Configuration

cp config.env.example config.env

Fill all required config values.

  • 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)

💬 Interactive Question Loop

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:

  1. MARSH WALL KEY COVER - £109.00
  2. 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:

  1. COMBINED RTI AND FINANCE GAP - £594.00
  2. MARSH WALL KEY COVER - £109.00

About

LangGraph example to create multiple nodes with edges to implement RAG/Embedding and interact with LLM.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages