A comprehensive repository of practical hands-on implementations, architectural modules, and complete codebases for Generative AI and LangChain concepts, structured around the following playlist: 👉 Generative AI & LangChain Course Playlist
This repository serves as a centralized hub for all my completed implementations, modular integrations, and custom applications pushed for production-ready reference.
- Video 1: Foundations of LangChain, LLM Integrations, Local Embeddings & Streamlit UIs
- Video 2: RAG Project - Multi-Format Ingestion, Document Loaders & Mistral AI Orchestration
- Video 3: Runnables, Tools & Agents — LangChain Expression Language (LCEL) Internals
Generative_AI/
│
├── RAG_Project/ # 🧠 Retrieval-Augmented Generation Hub
│ ├── document_loaders/
│ │ ├── GRU.pdf # Research paper (Gated Recurrent Units)
│ │ ├── notes.txt # Plaintext Deep Learning notes
│ │ ├── pdf.py # PyPDFLoader integration
│ │ ├── test.py # TextLoader integration
│ │ └── page.py # WebBaseLoader URL content loader
│ │
│ ├── Test_splitter/ # ✂️ Ingestion Text Splitting Experiments
│ │ ├── char_split.py # CharacterTextSplitter testing
│ │ ├── token_split.py # TokenTextSplitter testing
│ │ └── semantic_split.py # RecursiveCharacterTextSplitter testing
│ │
│ ├── Vector_Store/ # 🗄️ Vector Database Storage & Indexing
│ │ └── db.py # ChromaDB and MistralEmbeddings ingestion
│ │
│ ├── Retrievers/ # 🔍 Advanced Document Retrieval Modules
│ │ ├── Arixv.py # ArxivRetriever search testing
│ │ ├── Mmr.py # Similarity vs MMR diversity comparison
│ │ └── Multiquery.py # MultiQueryRetriever expansion
│ │
│ ├── chroma_db/ # [Local Only - Git Ignored] Persisted vector records
│ ├── Big.pdf # Large test corpus PDF for RAG pipeline ingestion
│ ├── README.md # Detailed RAG project documentation & roadmap
│ ├── Database.py # Main Vector Database build & ingestion pipeline
│ ├── main.py # Clean LLM chat & prompt testing module
│ ├── streamlit_app.py # Dedicated Streamlit Web UI mapping precisely to main.py
│ └── requirements.txt # Ingestion, embedding, LLM, and vector database packages
│
├── Video_1/ # 🎥 Foundations & Streamlit Chatbot
│ ├── chat_models/
│ │ ├── chat.py # Groq LLM integration
│ │ ├── Hugging_face.py # HF API Endpoint integration
│ │ ├── chatbot.py # CLI Interactive chatbot with memory
│ │ └── chatbot_ui.py # Streamlit chatbot web dashboard
│ │
│ ├── Embedding_models/
│ │ └── huggingface_embeddings.py # Local text embeddings (Sentence-Transformers)
│ │
│ ├── intro.txt # Detailed summary of Video 1 tasks
│ └── requirements.txt # Video 1 package dependencies
│
├── Agents/ # 🤖 LangChain Runnables, Tools & Agents
│ ├── Runnables/
│ │ ├── Sequence_runnables.py # Basic LCEL chain (prompt | llm | parser)
│ │ ├── parallel_runnables.py # RunnableParallel — concurrent multi-branch chains
│ │ └── passthrough_runnables.py # RunnablePassthrough — piping raw output downstream
│ ├── Tools/
│ │ ├── custom_tool.py # @tool decorator — creating custom LLM tools
│ │ ├── call_bind_execute_tool.py # Tool binding, tool calls & manual execution loop
│ │ ├── news_summarizer.py # TavilySearchResults + LCEL summarization chain
│ │ ├── Agent.py # LangGraph ReAct agent (weather + news tools)
│ │ └── streamlit_app.py # Premium Streamlit UI with agent trace transparency
│ ├── .env # API keys for Agents module
│ └── requirements.txt # Agents module dependencies
│
├── .env.example # Template for secure environment keys
├── .gitignore # Standard Python gitignore rules
└── README.md # Main repository index (this file)
The following functional units and configurations have been successfully implemented and verified:
- Chat Integrations:
- Hooked up Groq Cloud API using
llama-3.3-70b-versatile. - Connected Hugging Face Hub using
meta-llama/Llama-3.3-70B-Instruct.
- Hooked up Groq Cloud API using
- State & Memory Management:
- Built an interactive CLI chatbot utilizing LangChain message schemas (
SystemMessage,HumanMessage,AIMessage) to maintain persistent session history.
- Built an interactive CLI chatbot utilizing LangChain message schemas (
- Streamlit Web Application:
- Designed and deployed a feature-rich Streamlit chatbot interface with sidebar customizations (Model selectors, creativity/temperature sliders, and live system prompt tuning).
- Text Embeddings:
- Ran local mathematical text representations using
sentence-transformers/all-MiniLM-L6-v2to convert text into 384-dimensional vector coordinates.
- Ran local mathematical text representations using
- Core Concepts:
- Implemented modular Prompt Templates (
ChatPromptTemplatefor dynamic variables) and Structured JSON Outputs from LLMs.
- Implemented modular Prompt Templates (
A specialized Retrieval-Augmented Generation (RAG) pipeline designed to load, partition, embed, index, and synthesize responses using:
-
Multi-Format Ingestion:
- Integrated
PyPDFLoaderto load, parse, and partition mathematical research documents (e.g.,GRU.pdfandBig.pdf) into discrete, metadata-rich page collections. - Integrated
TextLoaderto ingest unstructured plaintext assets (e.g.,notes.txt) into memory-mappable document streams. - Integrated
WebBaseLoaderto pull and extract raw textual document streams directly from live website URLs.
- Integrated
-
Document Chunking & Splitting:
- Implemented character, token, and recursive text partitioners (
CharacterTextSplitter,TokenTextSplitter,RecursiveCharacterTextSplitter). - Utilizes
RecursiveCharacterTextSplitterinside the main orchestration pipeline to structure text data into standardized semantic chunks (chunk_size=1000,chunk_overlap=200).
- Implemented character, token, and recursive text partitioners (
-
Vector Database Ingestion, Indexing & Querying:
- Integrated
MistralAIEmbeddingsusing themistral-embedmodel to represent raw textual chunks as high-dimensional mathematical vector spaces. - Leveraged
Chromato persist, search, and manage document indexes locally insidechroma_db/. - Implemented and executed semantic similarity searches (
similarity_search) returning clean, formatted page contents and source metadata for the top matching records.
- Integrated
-
Advanced Contextual Retrieval Strategies:
- Added
ArxivRetriever(Arixv.py) for live API queries. Bypassed rate limits and redirects via custom HTTPS configurations. - Added Maximal Marginal Relevance (MMR) retrieval (
Mmr.py) to reduce duplication by weighting chunk diversity. - Added Multi-Query Expansion (
Multiquery.py) powered byChatMistralAIto automatically generate multiple query perspectives and maximize database match rates.
- Added
-
Advanced Orchestration, Prompting & Premium UI:
- Added
Database.pyas the official, standalone vector database build pipeline which handles parsingBig.pdf, splitting chunks semantically, and indexing vectors inside local Chroma storage. - Streamlined
main.pyinto a clean base LLM testing suite invoking ChatMistralAI (open-mistral-7b) with dynamic prompts to verify model answers. - Added
streamlit_app.pyas a premium, dedicated Streamlit UI designed to directly mirror and executemain.py's query flow with gorgeous glassmorphic dark themes, persistent chat memory, structured citations card blocks, and real-time parameter sidebar sliders (MMR vs Similarity search,$k$ ,$fetch_k$ , temperature).
- Added
Deep-dive into LangChain Expression Language (LCEL) and the full Tools & Agents stack:
- Sequence Runnables (
Sequence_runnables.py):- Built the foundational LCEL pipe chain:
prompt | llm | parser. - Demonstrated how
ChatPromptTemplate,ChatMistralAI, andStrOutputParsercompose as a single invokable unit.
- Built the foundational LCEL pipe chain:
- Parallel Runnables (
parallel_runnables.py):- Used
RunnableParallelto run multiple independent LLM chains concurrently in a singleinvoke()call. - All branches share the same input dict — each branch extracts its own key and has its own prompt + parser pipeline.
- Used
- Passthrough Runnables (
passthrough_runnables.py):- Chained two sequential stages using
RunnablePassthroughto pass raw code output into a parallel explanation branch. - Final response dict contains both
codeandexplanationkeys.
- Chained two sequential stages using
- Custom Tools (
custom_tool.py):- Used the
@tooldecorator to convert a plain Python function into an LLM-callable tool. - Explored
.name,.description, and.args— the tool metadata the LLM uses for reasoning.
- Used the
- Tool Binding & Execution (
call_bind_execute_tool.py):- Demonstrated the full bind → call → execute lifecycle:
llm.bind_tools([...]), detectingresult.tool_calls, manually invoking the tool, and feedingToolMessageresults back.
- Demonstrated the full bind → call → execute lifecycle:
- News Summarizer (
news_summarizer.py):- Combined
TavilySearchResults(pre-built community tool) with an LCEL summarization chain to fetch and summarize live news.
- Combined
- LangGraph ReAct Agent (
Agent.py):- Built a full autonomous ReAct (Reason + Act) agent using
create_react_agentfrom LangGraph. - Integrated two real-time tools: OpenWeatherMap (weather) and Tavily (news search).
- Agent autonomously decides which tools to call, executes them, and synthesizes a final markdown response.
- Built a full autonomous ReAct (Reason + Act) agent using
- City Agent Streamlit UI (
streamlit_app.py):- Premium dark-themed Streamlit web app with
st.chat_messagefor proper markdown rendering. - Agent Trace Panel: per-response collapsible expander showing every internal step — human messages, tool calls with args, raw tool results, and AI reasoning messages.
- Sidebar toggle to auto-expand traces, quick-ask buttons, live stats counters.
- Premium dark-themed Streamlit web app with
git clone <your-repository-url>
cd Generative_AICreate a .env file under both the root directory and/or the RAG_Project folder:
cp .env.example .envOpen the .env file and insert your API keys:
GROQ_API_KEY=gsk_your_actual_key_here
HUGGINGFACEHUB_API_TOKEN=hf_your_actual_key_here
MISTRAL_API_KEY=your_mistral_api_key_here- Install dependencies:
pip install -r Video_1/requirements.txt
- Start the interactive UI:
python -m streamlit run Video_1/chat_models/chatbot_ui.py
- Install dependencies:
pip install -r RAG_Project/requirements.txt
- Run document loaders test (PDF):
python RAG_Project/document_loaders/pdf.py
- Run document loaders test (Web scraping):
python RAG_Project/document_loaders/page.py
- Run text splitters test (Recursive Character):
python RAG_Project/Test_splitter/semantic_split.py
- Run vector store ingestion & similarity search test (ChromaDB):
python RAG_Project/Vector_Store/db.py
- Run advanced retrievers tests (MultiQuery, MMR, ArXiv):
python RAG_Project/Retrievers/Multiquery.py
- Build and populate your RAG vector database (Big.pdf):
python RAG_Project/Database.py
- Run chatbot prompt testing:
python RAG_Project/main.py
- Start premium Conversational Web UI:
streamlit run RAG_Project/streamlit_app.py
- Install dependencies:
pip install -r Agents/requirements.txt
- Run basic sequence chain:
python Agents/Runnables/Sequence_runnables.py
- Run parallel multi-branch chain:
python Agents/Runnables/parallel_runnables.py
- Run passthrough code-generation + explanation chain:
python Agents/Runnables/passthrough_runnables.py
- Run custom tool demo:
python Agents/Tools/custom_tool.py
- Run tool binding + manual execution loop:
python Agents/Tools/call_bind_execute_tool.py
- Run news summarizer with Tavily:
python Agents/Tools/news_summarizer.py
- Run ReAct agent (CLI):
python Agents/Tools/Agent.py
- Launch premium City Agent Streamlit UI:
streamlit run Agents/Tools/streamlit_app.py