This repository is a hands-on LangChain learning and experimentation space. It contains small examples that demonstrate how prompt templates, models, chains, runnables, tools, retrievers, embeddings, vector stores, and document-processing components fit together in practice.
- Models
- Prompt templates
- Chains and runnables
- Tools and agents
- Document loaders
- Text splitters
- Embeddings
- Vector stores
- Retrieval and RAG
- Output parsing
- Structured output
- Hugging Face integrations
- OpenAI integrations
- Anthropic integrations
.
├── building/
├── chains/
├── chatbot/
├── document_loader/
├── langchain runnables/
├── langchain_models/
├── outputparser/
├── retrievers/
├── runnables/
├── structuredOutput/
├── textSplitters/
├── tool calling/
├── tools/
├── vector stores/
├── .env.example
├── .gitignore
├── requirements.txt
└── README.md
The repository root contains the contents of the original local LangChain folder.
git clone https://github.com/Akrishna4/langchain-learning.git
cd langchain-learning
python -m venv .venv
source .venv/bin/activate
# Windows:
# .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .envOpen the new .env file and add your own API keys. The example files are written to read environment variables rather than hardcoded secrets.
The examples are intentionally standalone. Run each script directly from the repository root, for example:
python chains/simple_chain.py
python chains/sequential_chain.py
python document_loader/directory_loader.pyFor folders containing spaces, use quotes around the path:
python "vector stores/vectorstores.py"Some examples require API access to OpenAI, Anthropic, or Hugging Face. If a script is not meant to be executed in a headless environment, it may be a demonstration-only pattern.
The repository currently expects these variables in .env when the relevant example is run:
OPENAI_API_KEY— OpenAI chat and embedding examplesANTHROPIC_API_KEY— Anthropic chat examplesHUGGINGFACEHUB_API_TOKEN— Hugging Face endpoint examplesWEATHERSTACK_API_KEY— the custom weather tool example inbuilding/b.pyLANGCHAIN_API_KEY— optional LangSmith / tracing supportLANGCHAIN_TRACING_V2— optional LangSmith tracing toggleLANGCHAIN_PROJECT— optional LangSmith project name
A sensible order for these examples is:
- Models
- Prompt templates
- Chains
- Runnables
- Tools and agents
- Document loaders
- Text splitters
- Embeddings and vector stores
- Retrievers and RAG
- Output parsing and structured output
- These scripts are intended for learning and experimentation.
- Keep API keys in
.envand never commit them. - The root
.env.examplefile shows the expected variable names without any real credentials. - Some examples use local PDF, TXT, and CSV files as inputs for document-loading and retrieval experiments.
- Individual examples may require different API keys or external services.