What is LangChain?
LangChain is a framework for developing applications powered by large language models (LLMs). It enables LLM applications that are context-aware — connecting a language model to sources of context (prompt instructions, few-shot examples, content to ground its response in). It also enables applications that can reason — relying on a language model to reason about how to answer based on provided context.
Key Concepts
- Chains — Sequences of calls to LLMs or other utilities. You compose chains to build complex workflows.
- Agents — LLMs that decide which tools to call and in what order, at runtime.
- Memory — Persist state between calls so conversations feel continuous.
- Retrievers — Interfaces that return relevant documents from a data store given a query.
Common Use Cases
- Document Q&A (chat with your PDF, codebase, or knowledge base)
- Conversational chatbots with memory
- Autonomous agents that can browse the web, run code, or call APIs
- Data extraction and structured output from unstructured text
- RAG (Retrieval-Augmented Generation) pipelines
Getting Started
pip install langchain langchain-openai
LangChain has a large ecosystem: LangSmith for tracing/debugging, LangGraph for stateful multi-actor apps, and LangServe for deploying chains as REST APIs.