Skip to content

Repository files navigation

LangChain Learning

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.

Topics covered

  • 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

Repository structure

.
├── 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.

Setup

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 .env

Open the new .env file and add your own API keys. The example files are written to read environment variables rather than hardcoded secrets.

Running examples

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.py

For 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.

Environment variables

The repository currently expects these variables in .env when the relevant example is run:

  • OPENAI_API_KEY — OpenAI chat and embedding examples
  • ANTHROPIC_API_KEY — Anthropic chat examples
  • HUGGINGFACEHUB_API_TOKEN — Hugging Face endpoint examples
  • WEATHERSTACK_API_KEY — the custom weather tool example in building/b.py
  • LANGCHAIN_API_KEY — optional LangSmith / tracing support
  • LANGCHAIN_TRACING_V2 — optional LangSmith tracing toggle
  • LANGCHAIN_PROJECT — optional LangSmith project name

Learning progression

A sensible order for these examples is:

  1. Models
  2. Prompt templates
  3. Chains
  4. Runnables
  5. Tools and agents
  6. Document loaders
  7. Text splitters
  8. Embeddings and vector stores
  9. Retrievers and RAG
  10. Output parsing and structured output

Notes

  • These scripts are intended for learning and experimentation.
  • Keep API keys in .env and never commit them.
  • The root .env.example file 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.

About

Hands-on LangChain learning repository covering models, prompts, chains, runnables, tools, agents, RAG, retrievers, embeddings, output parsers, structured output, and vector stores.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages