Context Aware RAG Assistant
Author: Richmond Iroegbu Elochukwu
Affiliation: Ready Tensor AI Developer Certification Program
Keywords: LangChain, RAG, Chatbot, LLM, Vector Database, Context Retrieval
This project presents a Context-Aware LangChain RAG Chatbot designed to enable intelligent and document-grounded conversational interactions using modern Large Language Models (LLMs). The system integrates Retrieval-Augmented Generation (RAG) with a vector database, ensuring contextually accurate responses grounded in uploaded documents. The current implementation leverages a single document, “Agenda 2063: The Africa We Want” demonstrating the chatbot’s ability to perform domain-specific question answering. The model supports multiple LLM backends, including OpenAI, Groq, and Gemini, offering flexibility and cost efficiency.
Traditional chatbots often rely solely on pre-trained LLM knowledge, resulting in responses that may be outdated or contextually irrelevant for domain-specific applications. To address this, the Context-Aware LangChain RAG Chatbot employs Retrieval-Augmented Generation, allowing users to interact with custom document data while maintaining the fluency of LLM responses.
This project was developed as part of the Ready Tensor AI Developer Certification Program to demonstrate practical implementation of a document-grounded AI assistant using the LangChain framework.
The chatbot’s architecture combines document ingestion, embedding, vector storage, retrieval, and response generation in a modular pipeline.
The chatbot follows a modular RAG pipeline:
PDF Document → Text Chunking → Embeddings → Vector Store → Query Retrieval → Prompt Assembly → LLM Response
Each stage is isolated in its own module:
vectordb.py handles vector storage and similarity search.prompt_builder.py and prompt_instructions.py manage dynamic prompt assembly.app.py orchestrates document loading, query handling, and model responses.This modular approach promotes scalability and allows swapping components such as the embedding model or LLM provider without breaking the pipeline.
Logging and error handling mechanisms ensure reliability during document parsing, vectorization, and inference.
The chatbot was evaluated using the Agenda 2063 Popular Version document. User queries were tested for semantic relevance and factual grounding.
git https://github.com/Richmondiroegbu/context-aware-rag-assistant.git cd src pip install -r requirements.txt
Create a .env file and add your API keys:
OPENAI_API_KEY=your_key
GROQ_API_KEY=your_key
GEMINI_API_KEY=your_key
Run the chatbot:
python run.py
Upload your document (e.g., Agenda 2063.pdf) and start interacting through the command line or web interface (depending on configuration).
The Context Aware RAG Assistant Chatbot demonstrates how Retrieval-Augmented Generation can empower LLMs to produce accurate, document-grounded, and context-sensitive answers. Its modular design allows for easy adaptation across various domains, such as policy documents, technical manuals, and enterprise knowledge bases.