Looking for the JS/TS version? Check out LangChain.js.
To help you ship LangChain apps to production faster, check out LangSmith. LangSmith is a unified developer platform for building, testing, and monitoring LLM applications.
uv add langchain-classic
Legacy chains, langchain-community re-exports, indexing API, deprecated functionality, and more.
In most cases, you should be using the main langchain package.
For full documentation, see the API reference. For conceptual guides, tutorials, and examples on using LangChain, see the LangChain Docs.
See our Releases and Versioning policies.
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the Contributing Guide.
A utility to experiment with and compare the performance of different models.
BaseStore interface that works on the local file system.
Wraps a store with key and value encoders/decoders.
Interface for caching results from embedding models.
Callback handler that returns an async iterator.
Callback handler that returns an async iterator.
Callback handler for streaming in agents.
Tracer that logs via the input Logger.
Base class for prompt selectors.
Prompt collection that goes through conditionals.
Pass input through a moderation endpoint.
Chain where the outputs of one chain feed directly into next.
Simple chain where the outputs of one step feed directly into next.
Chain that transforms the chain output.
Abstract base class for creating structured sequences of calls to components.
Multi Retrieval QA Chain.
Chain that uses embeddings to route between options.
A route to a destination chain.
Chain that outputs the name of a destination chain and the inputs to it.
Use a single chain to route an input to one of multiple candidate chains.
Parser for output of router chain in the multi-prompt chain.
Input for a SQL Chain.
Input for a SQL Chain.
Chain for interacting with Elasticsearch Database.
Input type for ConversationalRetrievalChain.
Chain for chatting with an index.
Chain for chatting with a vector database.
Generate hypothetical document for query, and then embed that.
A typed dictionary containing information about elements in the viewport.
A crawler for web pages.
Class for a constitutional principle.
Interface for loading the combine documents chain.
Raise an ImportError if APIChain is used without langchain_community.
Interface for loading the combine documents chain.
Information about a data source attribute.
A date in ISO 8601 format (YYYY-MM-DD).
A datetime in ISO 8601 format (YYYY-MM-DDTHH:MM:SS).
Transform a query string into an intermediate representation.
Output parser that parses a structured query.
Class representing a single statement.
A question and its answer as a list of facts.
An answer to the question, with sources.
Output parser that checks if the output is finished.
Chain that generates questions from uncertain spans.
Flare chain.
Interface for the combine_docs method.
Interface for the combine_docs method.
Base interface for chains combining documents.
Interface for loading the combine documents chain.
Question-answering with sources over a vector database.
Question-answering with sources over an index.
Chat prompt template for the agent scratchpad.
Base Single Action Agent class.
Base Multi Action Agent class.
Base class for parsing agent output into agent action/finish.
Base class for parsing agent output into agent actions/finish.
Agent powered by Runnables.
Agent powered by Runnables.
Tool that just returns the query.
Agent that is using tools.
Iterator for AgentExecutor.
Tool that is run when invalid tool name is encountered by agent.
Memory used to save agent output AND intermediate steps.
AgentFinish with run and thread metadata.
AgentAction with info needed to submit custom tool output to existing run.
Run an OpenAI Assistant.
Output parser for the chat agent.
Output parser for the ReAct agent.
Output parser for the structured chat agent.
Output parser with retries for the structured chat agent.
MRKL Output parser for the chat agent.
Configuration for a chain to use in MRKL system.
Information about a VectorStore.
Toolkit for interacting with a VectorStore.
Toolkit for routing between Vector Stores.
Output parser for the conversational agent.
Output parser for the conversational agent.
Parses tool invocations and final answers from XML-formatted agent output.
Parses ReAct-style LLM calls that have a single tool input in json format.
Parses a message into agent actions/finish.
Parses ReAct-style LLM calls that have a single tool input.
Tool agent action.
Parses a message into agent actions/finish.
Parses tool invocations and final answers in JSON format.
Parses a message into agent action/finish.
Parses self-ask style LLM calls.
The types of the evaluators.
A base class for evaluators that use an LLM.
String evaluator interface.
Compare the output of two models (or two outputs of the same model).
Interface for evaluating agent trajectories.
A parser for the output of the PairwiseStringEvalChain.
Pairwise String Evaluation Chain.
Labeled Pairwise String Evaluation Chain.
LLM Chain for generating examples for question answering.
LLM Chain for evaluating question answering.
LLM Chain for evaluating QA w/o GT based on context.
LLM Chain for evaluating QA using chain of thought reasoning.
Compute a regex match between the prediction and the reference.
Embedding Distance Metric.
Embedding distance evaluation chain.
Use embedding distances to score semantic difference between two predictions.
A named tuple containing the score and reasoning for a trajectory.
Trajectory output parser.
A chain for evaluating ReAct style agents.
Distance metric to use.
Compute string distances between the prediction and the reference.
Compute string edit distances between two predictions.
An evaluator that validates a JSON prediction against a JSON schema reference.
Evaluate whether the prediction is valid JSON.
Json Equality Evaluator.
An evaluator that calculates the edit distance between JSON strings.
A Criteria to evaluate.
A parser for the output of the CriteriaEvalChain.
LLM Chain for evaluating runs against criteria.
Criteria evaluation chain that requires references.
A parser for the output of the ScoreStringEvalChain.
A chain for scoring on a scale of 1-10 the output of a model.
A chain for scoring the output of a model on a scale of 1-10.
Compute an exact match between the prediction and the reference.
A function description for ChatOpenAI.
A runnable that routes to the selected function.
Simple Memory.
Conversation chat memory with token limit and vectordb backing.
Combining multiple memories' data together.
Memory wrapper that is read-only and cannot be changed.
Table used to keep track of when a key was last updated.
A SQL Alchemy based implementation of the record manager.
Wrapper around a VectorStore for easy access.
Logic for creating indexes.
Retriever that ensembles the multiple retrievers.
Retrieve small chunks then retrieve their parent documents.
Output parser for a list of lines.
Given a query, use an LLM to write a set of queries.
Enumerator of the types of search to perform.
Retriever that supports multiple embeddings per parent document.
Given a query, use an LLM to re-phrase it.
Retriever that wraps a base retriever and compresses the results.
Retriever that merges the results of multiple retrievers.
Time Weighted Vector Store Retriever.
Embeddings Filter.
Document compressor that uses CrossEncoder for reranking.
Document compressor that uses Zero-Shot Listwise Document Reranking.
Parse outputs that could return a null string of some sort.
LLM Chain Extractor.
Filter that drops documents that aren't relevant to the query.
Document compressor that uses a pipeline of Transformers.
Self Query Retriever.
Parse the output of an LLM call to a datetime.
Schema for a response from a structured output parser.
Parse the output of an LLM call to a structured output.
Input for the retry chain of the OutputFixingParser.
Wrap a parser and try to fix parsing errors.
Parse the output of an LLM call using a regex.
Combine multiple output parsers into one.
Parse the output of an LLM call into a Dictionary using a regex.
Parse YAML output using a Pydantic model.
Retry chain input for RetryOutputParser.
Retry chain input for RetryWithErrorOutputParser.
Wrap a parser and try to fix parsing errors.
Wrap a parser and try to fix parsing errors.
Parse an output using Pandas DataFrame format.
Parse an output that is one of a set of values.
Parse the output of an LLM call to a boolean.
Raised when the input format is invalid.
A dictionary of the results of a single test run.
Your architecture raised an error.
Input for a chat model.
Extract items to evaluate from the run object.
Extract items to evaluate from the run object.
Extract items to evaluate from the run object from a chain.
Map an input to the tool.
Map an example, or row in the dataset, to the inputs of an evaluation.
Evaluate Run and optional examples.
Configuration for a given run evaluator.
Configuration for a run evaluator that only requires a single key.
Configuration for a run evaluation.
Configuration for a reference-free criteria evaluator.
Configuration for a labeled (with references) criteria evaluator.
Configuration for an embedding distance evaluator.
Configuration for a string distance evaluator.
Configuration for a QA evaluator.
Configuration for a context-based QA evaluator.
Configuration for a context-based QA evaluator.
Configuration for a json validity evaluator.
Configuration for a json equality evaluator.
Configuration for an exact match string evaluator.
Configuration for a regex match string evaluator.
Configuration for a score string evaluator.
Configuration for a labeled score string evaluator.
A simple progress bar for the console.
Abstract base class for memory in Chains.
Chain to run queries against LLMs.
Map-reduce chain.
A multi-route chain that uses an LLM router chain to choose amongst prompts.
A router chain that uses an LLM chain to perform routing.
Chain for having a conversation based on retrieved documents.
Chain for question-answering with self-verification.
Chain that interprets a prompt and executes python code to do math.
Implement an LLM driven browser.
Chain for applying constitutional principles.
Base class for question-answering chains.
Chain for question-answering against an index.
Chain for question-answering against a vector database.
Base class for question-answer generation chains.
Chain to have a conversation and load context from memory.
Chain for making a simple request to an API endpoint.
Chain that combines documents by stuffing into context.
Combine documents by doing a first pass and then refining on more documents.
Combining documents by mapping a chain over them, then reranking results.
Combining documents by mapping a chain over them, then combining results.
Combine documents by recursively reducing them.
Chain that splits documents, then analyzes it in pieces.
Chain for question-answering with self-verification.
Question answering chain with sources over documents.
Question answering with sources over documents.
Base class for single action agents.
Agent that calls the language model and deciding the action.
An enum for agent types.
Agent that uses XML tags.
An Agent driven by OpenAIs function powered API.
Chat Agent.
Agent for the ReAct chain.
Class to assist with exploration of a document store.
Agent for the ReAct TextWorld chain.
[Deprecated] Chain that implements the ReAct paper.
Structured Chat Agent.
Agent for the MRKL chain.
Chain that implements the MRKL system.
Agent driven by OpenAIs function powered API.
Agent for the self-ask-with-search paper.
[Deprecated] Chain that does self-ask with search.
An agent that holds a conversation in addition to using tools.
An agent designed to hold a conversation in addition to using tools.
An instance of a runnable stored in the LangChain Hub.
Use to keep track of the last k turns of a conversation.
Abstract base class for chat memory.
Conversation chat memory with token limit.
A basic memory implementation that simply stores the conversation history.
A basic memory implementation that simply stores the conversation history.
Mixin for summarizer.
Continually summarizes the conversation history.
Abstract base class for Entity store.
In-memory Entity store.
Upstash Redis backed Entity store.
Redis-backed Entity store.
SQLite-backed Entity store with safe query construction.
Entity extractor & summarizer memory.
Vector Store Retriever Memory.
Buffer with summarizer for storing conversation memory.
Document compressor that uses Cohere Rerank API.
Get the appropriate function output parser given the user functions.
Parse an AI message potentially containing tool_calls.
Use a single chain to route an input to one of multiple retrieval qa chains.