Skip to content

Repository files navigation

🚀 RAG-LLM-Applications

A comprehensive collection of Retrieval-Augmented Generation (RAG) and Large Language Model (LLM) applications showcasing modern AI techniques for building intelligent, context-aware systems.


📋 Table of Contents


🎯 Overview

This repository contains a collection of Python-based RAG and LLM applications that demonstrate advanced techniques for:

  • Document Processing & Chunking — Breaking down large documents into meaningful chunks
  • Vector Embeddings — Creating semantic representations using OpenAI embeddings
  • Vector Search — Retrieving relevant context using FAISS similarity search
  • Conversational AI — Building stateful, memory-aware chatbots
  • Agentic Workflows — Creating autonomous agents that can reason and act

All projects leverage LangChain and LangGraph for orchestration, providing a foundation for production-ready applications.


📦 Projects

1. PDF RAG Chatbot 📄

Location: pdf-rag-chatbot/

A Streamlit-powered application that enables users to upload PDF documents and ask natural language questions about their content.

Key Features:

  • PDF text extraction using PyPDF2
  • Intelligent text chunking with LangChain
  • Semantic similarity search using FAISS
  • Real-time token counting and cost tracking
  • Interactive UI with response streaming

Tech Stack:

Layer Technology
Frontend Streamlit
PDF Processing PyPDF2
Chunking LangChain CharacterTextSplitter
Embeddings OpenAI text-embedding-ada-002
Vector Store FAISS
LLM Orchestration LangChain

How It Works:

User Uploads PDF → PyPDF2 Extracts Text → LangChain Splits into Chunks
    → OpenAI Embeddings Vectorizes → FAISS Stores
    → User Query → Semantic Search → LLM Generates Answer

2. Multiple PDFs Chatbot 📚

Location: multiple-pdfs-chatbot/

An enhanced version that handles multiple PDF uploads with conversational memory and chat history.

Key Features:

  • Multi-document processing
  • Conversational retrieval chain with memory
  • Chat history persistence in session state
  • Custom HTML templating for chat UI
  • Support for both OpenAI and Hugging Face embeddings
  • Efficient recursive text splitting

Tech Stack:

  • Frontend: Streamlit with custom HTML templates
  • Vector Store: FAISS
  • LLM: ChatOpenAI (gpt-3.5-turbo)
  • Memory: ConversationBufferMemory
  • Chain Type: ConversationalRetrievalChain

Workflow:

  1. Upload multiple PDFs
  2. Click Process to index all documents
  3. Ask questions and maintain conversation context
  4. System remembers previous Q&A exchanges

3. Research AI Agent 🔬

Location: research-ai-agent/

An autonomous agent that conducts research by leveraging multiple tools and LLMs to gather, synthesize, and document information.

Key Features:

  • Tool-calling agent architecture
  • Multiple information sources: DuckDuckGo web search, Wikipedia, and file persistence
  • Structured output using Pydantic
  • Automatic research report generation
  • Timestamped output logging

Available Tools:

Tool Description
search DuckDuckGo web search
wikipedia Wikipedia knowledge retrieval
save_text_to_file Persist research output to file

Process:

User Query → Agent Reasoning → Tool Calling (Search / Wiki)
    → Information Synthesis → Structured Output → File Persistence

Output Format:

{
  "topic": "Research Topic",
  "summary": "Comprehensive findings",
  "sources": "List of sources",
  "tools_used": ["search", "wikipedia"]
}

4. LangGraph AI Agent 🤖

Location: langraph-ai-agent/

A sophisticated multi-path agent using LangGraph that routes messages to specialized handlers based on message type classification.

Key Features:

  • Message classification (emotional vs. logical)
  • Dual-agent system:
    • Therapist Agent — Empathetic, emotion-focused responses
    • Logical Agent — Fact-based, analytical responses
  • State-based graph workflow
  • Structured message routing
  • Interactive chatbot interface

Architecture:

Message → Classifier → Router → [Therapist Agent | Logical Agent] → Response

Message Routing:

Message Type Examples Handler
Emotional Therapy, feelings, personal problems Therapist Agent
Logical Facts, information, analysis Logical Agent

Graph Structure:

START → Classifier → Router → (Conditional Edges) → Therapist / Logical → END

Dependencies:

  • LangGraph — state management and graph execution
  • LangChain — LLM integration
  • GPT-3.5-turbo — inference

5. Website RAG Chatbot 🌐

Location: website-rag-chatbot/

Project structure established with src/ directory. Planned expansion for web scraping and website content indexing.


🚀 Quick Start

Prerequisites:

  • Python 3.8+
  • OpenAI API Key
  • Virtual environment (recommended)

Clone the repository:

git clone https://github.com/AreebEhsan/RAG-LLM-Applications.git
cd RAG-LLM-Applications

Environment setup — create a .env file in the root directory:

OPENAI_API_KEY=your_openai_api_key_here

💻 Installation Guide

PDF RAG Chatbot

cd pdf-rag-chatbot
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
streamlit run app.py

requirements.txt:

streamlit==1.47.1
PyPDF2==3.0.1
langchain==0.1.17
langchain-community==0.0.38
openai==1.3.9
faiss-cpu
python-dotenv==1.1.1

Multiple PDFs Chatbot

cd multiple-pdfs-chatbot
python -m venv venv
source venv/bin/activate
pip install streamlit PyPDF2 python-dotenv openai tiktoken \
            langchain langchain-community faiss-cpu
streamlit run app.py

Research AI Agent

cd research-ai-agent
python -m venv venv
source venv/bin/activate
pip install langchain-openai langchain-community python-dotenv pydantic
python main.py

Example prompt:

What can I help you research? → "Latest developments in quantum computing"

LangGraph AI Agent

cd langraph-ai-agent
python -m venv venv
source venv/bin/activate

# Option 1: uv (faster, modern dependency resolver)
pip install uv
uv sync

# Option 2: pip
pip install langchain-openai>=0.3.27 langgraph>=0.5.1 python-dotenv>=1.1.1

python main.py

Usage:

Message: → Ask a question or share a feeling
Message: exit → Quit the application

📊 Technology Stack

Component Technology Purpose
Language Python 3.8+ Core implementation
LLM Framework LangChain Orchestration & chains
Agentic Workflows LangGraph State management & routing
LLM Models OpenAI API (GPT-3.5-turbo, GPT-4) Inference
Vector Embeddings OpenAI Embeddings / HuggingFace Semantic representations
Vector Database FAISS Similarity search
PDF Processing PyPDF2 Text extraction
Text Splitting LangChain TextSplitter Chunking strategy
Frontend Streamlit Web UI
Configuration python-dotenv Environment management
External APIs DuckDuckGo, Wikipedia Research data sources

📁 Repository Structure

RAG-LLM-Applications/
├── README.md
├── LICENSE
├── .gitignore
├── .devcontainer/
│
├── pdf-rag-chatbot/
│   ├── app.py
│   ├── requirements.txt
│   ├── runtime.txt
│   └── README.md
│
├── multiple-pdfs-chatbot/
│   ├── app.py
│   ├── HTMLtemplates.py
│   └── __pycache__/
│
├── research-ai-agent/
│   ├── main.py
│   ├── tools.py
│   ├── research_output.txt
│   └── __pycache__/
│
├── langraph-ai-agent/
│   ├── main.py
│   ├── pyproject.toml
│   ├── .python-version
│   ├── uv.lock
│   ├── graph.png
│   └── README.md
│
└── website-rag-chatbot/
    └── src/

🎓 Key Concepts Demonstrated

Retrieval-Augmented Generation (RAG)

  • Document chunking with overlap
  • Vector embeddings and semantic search
  • Context-aware LLM responses
  • Reducing hallucination through grounding

Conversational AI

  • Memory management (ConversationBufferMemory)
  • Chat history persistence
  • Multi-turn dialogue

Agentic Patterns

  • Tool-calling agents
  • Conditional routing
  • State management
  • Graph-based workflows

LLM Integration

  • Function calling (OpenAI API)
  • Structured output parsing (Pydantic)
  • Token counting and cost tracking
  • Model selection and parameters

📝 Usage Examples

PDF RAG Chatbot:

# Upload a PDF in the Streamlit interface, then ask:
"What are the main points discussed in chapter 3?"
# System retrieves relevant chunks and generates a grounded answer.

Multiple PDFs Chatbot:

1. Upload multiple PDFs
2. Click "Process" to index all documents
3. Ask: "Compare the findings from all documents"
4. System maintains conversation context across turns

Research Agent:

$ python main.py
What can I help you research?"Machine learning trends 2025"

✅ Structured Output:
{
  "topic": "Machine learning trends 2025",
  "summary": "...",
  "sources": "...",
  "tools_used": ["search", "wikipedia"]
}

LangGraph Agent:

Message: "I'm feeling anxious about my presentation"
→ [Therapist Agent responds with empathy]

Message: "What is the capital of France?"
→ [Logical Agent responds with facts]

Message: exit
→ Over and out

🔧 Configuration & Customization

Adjust chunk size:

text_splitter = CharacterTextSplitter(
    chunk_size=1500,   # Increase for larger contexts
    chunk_overlap=300  # Overlap for continuity
)

Change LLM model:

llm = ChatOpenAI(model_name="gpt-4", temperature=0.7)

Switch embedding provider:

# OpenAI (default)
embeddings = OpenAIEmbeddings()

# Hugging Face (local, no API key required)
embeddings = HuggingFaceInstructEmbeddings()

🐛 Troubleshooting

OpenAI API key not found Ensure a .env file exists at the project root with a valid OPENAI_API_KEY.

FAISS import error

pip install faiss-cpu   # CPU version
pip install faiss-gpu   # GPU version (requires CUDA)

Streamlit app not loading

streamlit run app.py --logger.level=debug

LangGraph import errors

pip install --upgrade langgraph langchain-openai

🤝 Contributing

Contributions are welcome. Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add your feature'
  4. Push to branch: git push origin feature/your-feature
  5. Open a Pull Request

📚 References


📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


👤 Author

Areeb Ehsan

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages