Open-Source Wikis

/

LangChain

/

Packages

/

langchain-classic

langchain-ai/langchain

langchain-classic

The legacy implementation layer. PyPI distribution is langchain-classic. Source root: libs/langchain/langchain_classic/. Current version: 1.0.4.

Purpose

langchain-classic carries the implementations from before the v1 rebuild: chains, the legacy agent framework (MRKL/ReAct/OpenAI-functions/structured-chat/etc.), retrievers, evaluation harnesses, graph-QA tools, the Memory class hierarchy, the Indexing API, and re-exports from langchain-community. It is in maintenance mode — bugfixes and security patches only — but it remains widely used in production codebases.

In most cases, new code should not use langchain-classic. Modern equivalents:

Old (langchain-classic) New
chains.LLMChain, RetrievalQA, … LCEL pipelines (prompt | model | parser) or a custom langgraph graph
agents.AgentExecutor, MRKLChain, ReActChain, … langchain.agents.create_agent
memory.ConversationBufferMemory, … langgraph.checkpoint / agent state
indexes.SQLRecordManager langchain_core.indexing
langchain_classic.evaluation langsmith evaluation SDK

Directory layout

libs/langchain/langchain_classic/
├── __init__.py
├── _api/                  # Deprecation utilities
├── adapters/              # Cross-framework adapters
├── agents/                # MRKL, ReAct, OpenAI-functions, structured-chat, ...
├── base_language.py
├── base_memory.py
├── cache.py
├── callbacks/             # File, run-collector, streaming-stdout, ...
├── chains/                # 30+ chain types: LLMChain, RetrievalQA, MapReduce, ...
├── chat_loaders/          # Load conversations from files
├── chat_models/           # Re-exports of provider chat models
├── docstore/              # Document store abstractions
├── document_loaders/      # 100+ loaders
├── document_transformers/ # HTML cleaners, embeddings filters, ...
├── embeddings/            # Re-exports of provider embeddings
├── evaluation/            # QA correctness, criteria, agents, embedding distance
├── example_generator.py
├── graphs/                # Graph-QA: Cypher, NebulaGraph, Neo4j, FalkorDB, Kuzu, ...
├── hub.py                 # LangSmith Hub wrappers
├── indexes/               # Indexing API
├── llms/                  # Re-exports of provider LLMs
├── load/                  # Serialization helpers
├── memory/                # ConversationBufferMemory, summary, vectorstore, ...
├── model_laboratory.py    # Side-by-side model comparison
├── output_parsers/        # Re-exports + a few extras
├── prompts/
├── python.py              # PythonREPL helpers
├── retrievers/            # 40+ retrievers including self-query and ensemble
├── runnables/
├── schema/
├── serpapi.py             # Shim for langchain_classic.utilities.serpapi
├── smith/                 # LangSmith integration utilities
├── sql_database.py
├── storage/               # File / in-memory KV stores
├── text_splitter.py       # Shim for langchain-text-splitters
├── tools/                 # 60+ tools (search, file, shell, BashREPL, ...)
├── utilities/             # SerpAPI, Wikipedia, ArXiv, GitHub, ...
├── utils/
└── vectorstores/          # Vector store base + many provider integrations

Key abstractions

Symbol File Description
Chain libs/langchain/langchain_classic/chains/base.py The legacy chain base class; LLMChain, RetrievalQA, etc. all extend it
LLMChain libs/langchain/langchain_classic/chains/llm.py Prompt → LLM → output parser, the original chain
AgentExecutor libs/langchain/langchain_classic/agents/agent.py The legacy agent runner
MRKLChain, ReActChain, SelfAskWithSearchChain libs/langchain/langchain_classic/agents/ Prompt-driven legacy agents
BaseMemory libs/langchain/langchain_classic/base_memory.py Memory base class — superseded by LangGraph checkpointers
BaseRetriever consumers libs/langchain/langchain_classic/retrievers/ Self-query, ensemble, multi-query, multi-vector, parent-document, time-weighted, contextual-compression
evaluation.load_evaluator libs/langchain/langchain_classic/evaluation/loading.py QA correctness, criteria, embedding distance evaluators
hub.pull(...) libs/langchain/langchain_classic/hub.py Pull a prompt from the LangSmith Hub
SQLRecordManager libs/langchain/langchain_classic/indexes/_sql_record_manager.py Tracks documents indexed into a vector store

What's still actively used

Even in maintenance mode, several pieces of langchain-classic are still common in modern codebases:

  • RetrieversEnsembleRetriever, MultiQueryRetriever, MultiVectorRetriever, SelfQueryRetriever, ContextualCompressionRetriever, ParentDocumentRetriever, TimeWeightedVectorStoreRetriever. There is no v1 equivalent for many of these.
  • Document loaders under langchain-community are re-exported here.
  • hub.pull for fetching prompts from the LangSmith Hub.
  • The Indexing API for incremental vector-store updates (though langchain-core.indexing is the new home).
  • Evaluation harnesses for offline LLM evaluation, especially when LangSmith eval doesn't fit.

Integration points

  • Imports from langchain-core for every base class.
  • Re-exports from langchain-community (a separate repository) for community-contributed integrations.
  • Imports from langchain-text-splitters, langchain-openai, partner packages on demand.
  • Indirect coupling to langgraph via the Runnable interface, but no direct dependency.

Deprecations and warnings

libs/langchain/langchain_classic/__init__.py carries a __getattr__ that routes legacy top-level imports (MRKLChain, ReActChain, SelfAskWithSearchChain, …) to their new explicit paths and emits a DeprecationWarning outside of interactive environments. This is the project's standard pattern for soft-removing top-level symbols without breaking older user code.

Entry points for modification

  • For a bugfix in a legacy chain or agent, edit the relevant module and add a regression test under tests/unit_tests/.
  • For a new chain or agent type, do not add it here — the project's policy is no new features in langchain-classic. Build it on top of LCEL or langgraph instead.
  • For a community integration that should live in langchain-community, open the PR there; this package only re-exports.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

langchain-classic – LangChain wiki | Factory