A hands-on, module-by-module learning repository covering the LangChain ecosystem β from raw LLM calls to RAG pipelines, tools, and agents.
β οΈ Note on this README: This repository was documented from its folder/file structure alone (no source code,requirements.txt, orsetup.pycontents were provided). Sections that cannot be verified from the file names β such as license terms, live demos, and exact dependency versions β are marked accordingly instead of being guessed.
Langchain is a structured, numbered curriculum of standalone Python scripts and notebooks that walk through the LangChain framework end-to-end β starting from raw LLM invocation and progressing through chat models, embeddings, prompts, structured output, output parsers, chains, LCEL runnables, Retrieval-Augmented Generation (RAG), tools, and agents.
Why it exists
- Serves as a personal reference / learning log while mastering LangChain concept-by-concept.
- Each numbered folder (
01β11) isolates one concept so it can be studied or reused independently.
Real-world use case
- A ready-made playground for anyone learning LangChain to see minimal, working examples of each building block (loaders, splitters, retrievers, chains, tools, agents) before combining them into a full application.
Target users
- Students and developers learning LangChain
- Engineers who want copy-paste-ready snippets for LLMs, RAG, and agent components
- Instructors looking for a ready reference curriculum structure
Based on the modules present in the repository:
β
Basic LLM invocation examples (01.LLMs)
β
Multi-provider chat model examples β OpenAI, Anthropic, Google, Hugging Face (API & local) (02.ChatModels)
β
Embedding generation with OpenAI and local Hugging Face models, plus a document similarity demo (03.EmbeddingModels)
β
Static & dynamic prompts, chat templates, message placeholders, and a simple chatbot (04.Prompt)
β
Structured output using TypedDict, Pydantic, and JSON Schema (05.Structure_Output)
β
Output parsers β string, JSON, structured, and Pydantic parsers, including chain integration (06.OutputParser)
β
Chain compositions β simple, sequential, parallel, and conditional chains (07.Chains)
β
LCEL / Runnables β RunnableSequence, RunnableParallel, RunnablePassthrough, RunnableLambda, RunnableBranch, plus legacy LLMChain, a PDF reader, and a RetrievalQA chain example (08.Runnables)
β End-to-end RAG pipeline:
- Document loaders β text, PDF, directory (eager & lazy), web page (
09.RAG/1.Document_Loader) - Text splitters β length-based, structure-based, markdown-based, and semantic chunking (
09.RAG/2.Text_Splitter) - Vector storage with ChromaDB (
09.RAG/3.Vector_Database) - Retrievers β Wikipedia, vector store, MMR, multi-query, and contextual compression retrievers (
09.RAG/4.Retriever)
β
Tool usage β built-in tools (DuckDuckGo search, shell tool, Google search), custom tools (structured & base tool), and toolkits with tool binding/execution (10.Tools)
β
Agents β a search agent and a weather agent built with LangChain (11.Agents)
The repository doesn't ship a single application β it's a set of independent modules. The conceptual flow a learner follows (and the flow a RAG-based script in this repo implements) looks like this:
flowchart TD
A[User / Script Input] --> B[Prompt Layer]
B --> C[Chat Model<br/>OpenAI / Anthropic / Google / HF]
C --> D{Needs External<br/>Knowledge or Tools?}
D -- RAG --> E[Document Loader]
E --> F[Text Splitter]
F --> G[Embedding Model]
G --> H[(ChromaDB<br/>Vector Store)]
H --> I[Retriever<br/>Vector / MMR / MQR / CCR]
I --> C
D -- Tools/Agents --> J[Tools & Toolkits<br/>Search / Shell / Custom]
J --> C
C --> K[Output Parser<br/>String / JSON / Pydantic]
K --> L[Final Response]
Langchain.git/
βββ .gitignore
βββ 01.LLMs/
β βββ 1_LLM_demo.py
β βββ __init__.py
βββ 02.ChatModels/
β βββ 1_chatmodel_openai.py
β βββ 2_chatmodel_anthropic.py
β βββ 3_chatmodels_google.py
β βββ 4_chatmodels_hf_api.py
β βββ 5_chatmodels_hf_local.py
β βββ __init__.py
βββ 03.EmbeddingModels/
β βββ 1_embedding_openai_query.py
β βββ 2_embedding_openai_docs.py
β βββ 3_embedding_hf_local.py
β βββ 4_Document_Similarity.py
β βββ __init__.py
βββ 04.Prompt/
β βββ 1_Static_Prompt.py
β βββ 2_Dynamic_Prompt.py
β βββ 3_Chatbot.py
β βββ 4_Messages.py
β βββ 5_Chat_Template.py
β βββ 6_Message_Placeholder.py
β βββ chat_history.txt
βββ 05.Structure_Output/
β βββ 1_using_TypeDict.py
β βββ 2_with_structured_output_TypeDictAnnoted.py
β βββ 3_Pydantic.py
β βββ 4_Pydantic.py
β βββ 5_with_structured_output_TypeDict.py
β βββ 6_with_structured_output_Pydantic.py
β βββ 7_with_structured_output_JsonScheme.py
β βββ 8_with_structure_output_using_hf.py
β βββ json_schema.json
βββ 06.OutputParser/
β βββ 1_string_output_parser.py
β βββ 2_string_output_parser.py
β βββ 3_json_output_parser.py
β βββ 4_json_output_parser_with_chain.py
β βββ 5_structured_ouput_parser.py
β βββ 6_pydantic_output_parser.py
βββ 07.Chains/
β βββ 1_simple_chain.py
β βββ 2_sequential_chain.py
β βββ 3_parallel_chain.py
β βββ 4_conditional_chain.py
βββ 08.Runnables/
β βββ 1.1_runnable_sequence.py
β βββ 1_runnable_sequence.py
β βββ 2_runnable_parallel.py
β βββ 3.1_simple_runnable_passthrough.py
β βββ 3.2_runnable_passthrough.py
β βββ 4.1_simple_runnable_lambda.py
β βββ 4.2_runnable_lambda.py
β βββ 5_runnable_branch.py
β βββ 6_LCEL.py
β βββ llm_using_llmchain.py
β βββ pdf_reader.py
β βββ retrievalQA_chain.py
β βββ simple_llm.py
βββ 09.RAG/
β βββ 1.Document_Loader/
β β βββ 1_text_loader.py
β β βββ 2_pdf_loader.py
β β βββ 3.1_directory_loader_load.py
β β βββ 3.2_directory_loader_lazyload.py
β β βββ 4.1_WebPage_loader.py
β β βββ 4.2_WebPage_loader_application.py
β β βββ cricket.txt
β β βββ pypdf.pdf
β βββ 2.Text_Splitter/
β β βββ 1.1_length_based_text_splitter.py
β β βββ 1_length_based_text_splitter.py
β β βββ 2_text_structure_based_text_splitter.py
β β βββ 3.1_markdown_splitter_using_text_splitter.py
β β βββ 3_document_structure_based_text_splitter.py
β β βββ 4_semantic_meaning_based_text_splitter.py
β βββ 3.Vector_Database/
β β βββ 1_chromadb_vector_db.py
β β βββ 2_chromadb-using-vector-database.ipynb
β βββ 4.Retriever/
β β βββ 1_wikipedia_retriever.py
β β βββ 2_vector_store_retriever.py
β β βββ 3_MMR_retriever.py
β β βββ 4_mqr.py
β β βββ 5_ccr.py
β βββ Book/
β β βββ 1.pdf
β β βββ SDG_AI-Study-Assistant_Shravan-Kumar-Pandey.pdf
β β βββ aknowledgement6th sem.pdf
β βββ __ini__.py
β βββ dl-curriculum.pdf
βββ 10.Tools/
β βββ Built-in_Tool/
β β βββ 1_duckduckgo_search.py
β β βββ 2_shell_tool.py
β β βββ 3_google_search.py
β βββ Custom_Tool/
β β βββ 1_custom-tool.ipynb
β β βββ 2_structured_tool.py
β β βββ 3_Base_tool.py
β βββ Toolkit/
β β βββ 1_toolkit.py
β β βββ 2_tool_binding.py
β β βββ 3_tool_execution.py
β β βββ 4_complete_toolkit_code.py
β βββ __init__.py
βββ 11.Agents/
β βββ 1_search_agents_in_langchain.py
β βββ 2_weather_agent_langchain.py
βββ README.md
βββ chroma_db/
β βββ 710c71c9-f247-4be4-a4cb-ddd48b7c3de1/
β β βββ data_level0.bin
β β βββ header.bin
β β βββ length.bin
β β βββ link_lists.bin
β βββ chroma.sqlite3
βββ requirements.txt
βββ setup.py
| Category | Technology |
|---|---|
| Language | Python |
| Core Framework | LangChain |
| LLM Providers | OpenAI, Anthropic, Google, Hugging Face (Inference API & local) |
| Embedding Models | OpenAI Embeddings, Hugging Face (local) Embeddings |
| Vector Database | ChromaDB |
| Data Sources | Wikipedia, PDF files, plain text, web pages |
| Structured Output / Validation | Pydantic, TypedDict, JSON Schema |
| Built-in Tools | DuckDuckGo Search, Shell Tool, Google Search |
| Notebook Support | Jupyter Notebooks (.ipynb) |
| Packaging | requirements.txt, setup.py |
Exact package versions could not be determined β see
requirements.txtin the repository for the authoritative list.
# 1. Clone the repository
git clone https://github.com/Shravan4598/Langchain.git
cd Langchain
# 2. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment variables
cp .env.example .env # create this file if not already present
# then fill in your API keys (see table below)
# 5. Run any module script directly, e.g.:
python 01.LLMs/1_LLM_demo.pyThe scripts call multiple LLM/embedding providers and external search tools. Based on the modules present, you will likely need some or all of the following keys (add only the ones relevant to the script you're running):
| Variable | Description | Required | Example |
|---|---|---|---|
OPENAI_API_KEY |
API key for OpenAI chat & embedding models | For OpenAI scripts | sk-... |
ANTHROPIC_API_KEY |
API key for Anthropic (Claude) chat models | For Anthropic scripts | sk-ant-... |
GOOGLE_API_KEY |
API key for Google (Gemini) chat models | For Google scripts | AIza... |
HUGGINGFACEHUB_API_TOKEN |
Token for Hugging Face Inference API models | For HF API scripts | hf_... |
βΉοΈ A
.envfile / dotenv pattern is assumed based on standard LangChain conventions; confirm the exact variable names used by checking each script'sos.getenv(...)calls, since these were not visible in the provided structure.
Each numbered folder is self-contained β pick a concept and run the corresponding script:
# Try a basic chat model call
python 02.ChatModels/2_chatmodel_anthropic.py
# Run a text splitter demo
python 09.RAG/2.Text_Splitter/2_text_structure_based_text_splitter.py
# Build/query the Chroma vector store
python 09.RAG/3.Vector_Database/1_chromadb_vector_db.py
# Run an agent example
python 11.Agents/2_weather_agent_langchain.pyFor notebook-based examples (.ipynb files), launch Jupyter:
jupyter notebookUser Query
β
Document Loader (PDF / Text / Web / Directory)
β
Text Splitter (chunking)
β
Embedding Model (OpenAI / Hugging Face)
β
ChromaDB (vector storage)
β
Retriever (Vector / MMR / Multi-Query / Contextual Compression)
β
Chat Model (LLM generates the final answer)
β
Output Parser β Response
Concepts actually implemented in this repository:
- LangChain Expression Language (LCEL) β
RunnableSequence,RunnableParallel,RunnablePassthrough,RunnableLambda,RunnableBranch - Retrieval-Augmented Generation (RAG) β full loader β splitter β embedding β vector store β retriever pipeline
- Prompt Engineering β static/dynamic prompts, chat prompt templates, message placeholders
- Structured Output β
TypedDict, Pydantic models, JSON Schema - Output Parsing β string, JSON, structured, and Pydantic parsers
- Embeddings & Vector Search β OpenAI & Hugging Face embeddings with ChromaDB, including MMR-based diversity retrieval
- Tools & Toolkits β built-in (DuckDuckGo, Shell, Google Search) and custom tools, with tool binding/execution
- Agents β search agent and weather agent
| File | Purpose |
|---|---|
requirements.txt |
Python package dependencies (exact contents not provided β install via pip install -r requirements.txt) |
setup.py |
Enables installing this repo as a local package |
- Add a top-level
.env.exampledocumenting all required API keys - Add a
LICENSEfile to clarify usage terms - Add unit tests for reusable components (loaders, splitters, parsers)
- Consolidate common utilities used across modules to reduce duplication
- Add a consolidated
requirements.txtwith pinned versions per module
Contributions are welcome!
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "Add: your feature" - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
Please keep new examples consistent with the existing numbered-module structure.
No LICENSE file was present in the provided repository structure. Please check the repository directly, or add one (e.g., MIT) to clarify usage terms for contributors and users.
Shravan Kumar Pandey
- π§ Email: shravankumarpandey825412@gmail.com
- π Portfolio: shravan-kumar-pandey-portfolio.vercel.app
- πΌ LinkedIn: Shravan Kumar Pandey
- π Kaggle / LeetCode: shravankumarpandey
- LangChain β the core framework this repository is built around
- ChromaDB β vector database used for RAG examples
- OpenAI, Anthropic, Google, and Hugging Face β model providers integrated across the modules
Is this a production application?
No β it's a structured, module-by-module learning repository of standalone LangChain examples, not a deployable application.Do I need API keys for every provider?
No. You only need the API key(s) corresponding to the specific script/provider you're running (e.g., only `OPENAI_API_KEY` for OpenAI scripts).Where is the vector store data stored?
Locally, in thechroma_db/ directory, generated when you run the ChromaDB examples in 09.RAG/3.Vector_Database.
| Issue | Likely Cause | Fix |
|---|---|---|
AuthenticationError / 401 |
Missing or invalid API key | Verify the relevant key is set in your .env and loaded correctly |
ModuleNotFoundError |
Dependencies not installed | Run pip install -r requirements.txt inside your virtual environment |
| Chroma errors on rerun | Stale chroma_db/ state |
Delete the chroma_db/ folder and re-run the ingestion script |
| PDF loader fails | Corrupt or unsupported PDF | Confirm the PDF opens normally outside the script; try a different loader |
- Never commit real API keys. Store them in a
.envfile and ensure.envis listed in.gitignore. - The repository's
.gitignoreis present at the root β confirm it excludes.env,__pycache__/, and virtual environment folders. - Treat
chroma_db/as generated/local data; avoid committing large binary vector store files to version control.
If you find this repository useful:
- β Star the repo to bookmark it
- π΄ Fork it to build your own LangChain learning path
- π Open an Issue for bugs or suggestions
- π Submit a Pull Request to add new examples
- π Watch the repo for updates