Working through this module?0 of 17 done
Module 01 · Page 2 of 20 · 5 sections

Introduction to LangChain

What LangChain is, why developers use it, its high-level architecture, the core concepts and how it compares with calling an LLM API directly.

1.1

What is LangChain?

  • LangChain is an open-source framework designed to build applications with Large Language Models (LLMs).
  • It provides tools, abstractions and modules to connect LLMs with external data, tools and real-world actions.
  • It simplifies the development of complex LLM applications like chatbots, agents, RAG systems and document analysis.
  • LangChain is language-agnostic but most popular with Python.
1.2

Why LangChain?

  • Provides high-level abstractions for LLM apps.
  • Easy integration with multiple LLM providers (OpenAI, Anthropic, Google, etc.).
  • Built-in support for document loaders, text splitters, vector stores and tools.
  • Helps in building production-ready applications.
  • Modular and extensible architecture.
  • Large community and active development.
  • Useful for building RAG, agents, chatbots and multi-step workflows.
1.3

High Level Architecture

User Query
LangChain FrameworkPrompts, chains, agents, memory, loaders, vector stores, tools
LLMOpenAI, Claude, Gemini
Response to User

The framework also reaches out to external data such as PDFs, databases and APIs.

1.4

Core Concepts in LangChain

1
Models
LLMs and chat models.
2
Prompts
Templates to create structured inputs.
3
Chains
Sequence of operations using LLMs.
4
Agents
Use tools to perform actions.
5
Memory
Maintain conversation history.
6
Document Loaders
Load data from various sources.
7
Text Splitters
Split large documents.
8
Vector Stores
Store and search embeddings.
9
Retrievers
Fetch relevant documents.
10
Tools
Integrate with external APIs, DBs, etc.
11
Callbacks
Track and monitor token usage.
12
Output Parsers
Structure the LLM output.
1.5

LangChain vs Direct LLM API Calls

AspectDirect LLM API CallsLangChain
Ease of UseManual implementationHigh-level abstractions
Prompt ManagementHard-codedPrompt templates and chains
Document HandlingCustom implementationBuilt-in document loaders and splitters
Vector Store IntegrationManual integrationDirect support (FAISS, Chroma, etc.)
Agents and ToolsComplex to implementBuilt-in agents and tool integration
MemoryManual handlingBuilt-in memory modules
Production ReadyMore effortReady-to-use components