Skip to content

tashfeen786/LangChain

Repository files navigation

🦜 LangChain — Hands-On Learning Repository

Python LangChain Jupyter OpenAI License

🤖 A structured, hands-on repository covering LangChain — the most widely used framework for building LLM-powered applications, RAG systems, AI agents, and production-grade GenAI pipelines.


🎯 Why LangChain?

LangChain is the backbone of modern GenAI development:

  • ⚡ Powers RAG systems — retrieval + generation pipelines
  • 🤖 Used in AI Agents with tool calling
  • 🏭 Industry standard for production LLM apps
  • 🔗 Integrates with OpenAI, Groq, HuggingFace, Anthropic
  • 📦 Used internally by CryptoChat project for RAG pipeline

📚 What's Covered

🔗 1. LangChain Chains (LANGCHAIN_CHAIN/)

Building sequential pipelines that connect prompts → LLMs → outputs.

from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate

prompt = PromptTemplate(
    input_variables=["topic"],
    template="Explain {topic} in simple terms."
)
chain = LLMChain(llm=llm, prompt=prompt)
result = chain.run("RAG systems")

Key Concepts:

  • Simple chains — single step LLM calls
  • Sequential chains — multi-step pipelines
  • Prompt templates — dynamic input handling

📤 2. Output Parsers (LANGCHAIN_OTUPUT_PARSERS/)

Converting raw LLM text output into structured Python objects.

from langchain.output_parsers import PydanticOutputParser
from pydantic import BaseModel

class Movie(BaseModel):
    title: str
    year: int
    genre: str

parser = PydanticOutputParser(pydantic_object=Movie)
# LLM output → structured Movie object

Key Concepts:

  • StrOutputParser — plain text output
  • PydanticOutputParser — structured JSON → Python objects
  • CommaSeparatedListOutputParser — list extraction
  • Format instructions — telling LLM how to respond

⚡ 3. Runnables (Runnables in LangChain/)

LangChain Expression Language (LCEL) — modern, composable pipelines.

from langchain_core.runnables import RunnablePassthrough

# LCEL pipe syntax — composing chains
chain = prompt | llm | output_parser

# Parallel execution
chain = RunnableParallel(
    summary=summarize_chain,
    keywords=keyword_chain
)

Key Concepts:

  • RunnablePassthrough — pass data through unchanged
  • RunnableParallel — run multiple chains simultaneously
  • RunnableLambda — wrap any Python function as runnable
  • Pipe | operator — elegant chain composition

🧠 4. LangChain Models (langchain_model/)

Connecting to different LLM providers and model types.

# Chat Models
from langchain_openai import ChatOpenAI
from langchain_groq import ChatGroq

llm = ChatGroq(model="llama3-8b-8192")  # Fast & free

# Embedding Models
from langchain_community.embeddings import HuggingFaceEmbeddings
embeddings = HuggingFaceEmbeddings(
    model_name="sentence-transformers/all-MiniLM-L6-v2"
)

Key Concepts:

  • LLM vs ChatModel differences
  • OpenAI, Groq, HuggingFace integration
  • Embedding models for vector search
  • Model parameters — temperature, max_tokens, streaming

🏗️ LangChain Architecture Overview

User Input
    ↓
Prompt Template (dynamic variables)
    ↓
LLM Model (OpenAI / Groq / HuggingFace)
    ↓
Output Parser (text → structured data)
    ↓
Chain / Runnable (connects everything)
    ↓
Final Output

🛠️ Tech Stack

Component Technology
Framework LangChain v0.2+
LLM APIs OpenAI, Groq
Embeddings HuggingFace sentence-transformers
Language Python 3.10+
Notebooks Jupyter Notebook

🚀 Getting Started

# Clone the repo
git clone https://github.com/tashfeen786/LangChain.git
cd LangChain

# Install dependencies
pip install langchain langchain-openai langchain-groq \
            langchain-community python-dotenv jupyter

# Set up API keys
cp .env.example .env
# Add your keys to .env

Environment Variables

OPENAI_API_KEY=your_openai_key
GROQ_API_KEY=your_groq_key

🏗️ Project Structure

LangChain/
│
├── LANGCHAIN_CHAIN/            # LLM chains & sequential pipelines
├── LANGCHAIN_OTUPUT_PARSERS/   # Structured output parsing
├── Runnables in LangChain/     # LCEL — modern runnable interface
├── langchain_model/            # LLM & embedding model integration
└── README.md

🔗 Real-World Application

This LangChain knowledge is directly applied in:

🤖 CryptoChat RAG System — used LangChain to build the complete RAG pipeline: document loading → embedding → vector search → Groq LLM → personalized crypto investment advice.

View Project →


🔮 Coming Soon

  • RAG pipeline from scratch
  • AI Agent with tool calling
  • Memory & conversation history
  • LangGraph — stateful agent workflows
  • LangSmith — observability & debugging

👨‍💻 Author

Tashfeen Aziz — AI/ML Engineer & Python Developer

LinkedIn GitHub Email


If you found this helpful, please give it a star!

About

Hands-on LangChain learning — Chains, Output Parsers, Runnables & LLM Models | OpenAI · Groq · HuggingFace | Used in production RAG systems

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors