langchain: 0.2.13#

Main entrypoint into package.

agents#

agents.agent.AgentExecutor

Agent that is using tools.

agents.agent.AgentOutputParser

Base class for parsing agent output into agent action/finish.

agents.agent.BaseMultiActionAgent

Base Multi Action Agent class.

agents.agent.BaseSingleActionAgent

Base Single Action Agent class.

agents.agent.ExceptionTool

Tool that just returns the query.

agents.agent.MultiActionAgentOutputParser

Base class for parsing agent output into agent actions/finish.

agents.agent.RunnableAgent

Agent powered by Runnables.

agents.agent.RunnableMultiActionAgent

Agent powered by Runnables.

agents.agent_iterator.AgentExecutorIterator(...)

Iterator for AgentExecutor.

agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo

Information about a VectorStore.

agents.agent_toolkits.vectorstore.toolkit.VectorStoreRouterToolkit

Toolkit for routing between Vector Stores.

agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit

Toolkit for interacting with a Vector Store.

agents.chat.output_parser.ChatOutputParser

Output parser for the chat agent.

agents.conversational.output_parser.ConvoOutputParser

Output parser for the conversational agent.

agents.conversational_chat.output_parser.ConvoOutputParser

Output parser for the conversational agent.

agents.mrkl.base.ChainConfig(action_name, ...)

Configuration for a chain to use in MRKL system.

agents.mrkl.output_parser.MRKLOutputParser

MRKL Output parser for the chat agent.

agents.openai_assistant.base.OpenAIAssistantAction

AgentAction with info needed to submit custom tool output to existing run.

agents.openai_assistant.base.OpenAIAssistantFinish

AgentFinish with run and thread metadata.

agents.openai_assistant.base.OpenAIAssistantRunnable

Run an OpenAI Assistant.

agents.openai_functions_agent.agent_token_buffer_memory.AgentTokenBufferMemory

Memory used to save agent output AND intermediate steps.

agents.output_parsers.json.JSONAgentOutputParser

Parses tool invocations and final answers in JSON format.

agents.output_parsers.openai_functions.OpenAIFunctionsAgentOutputParser

Parses a message into agent action/finish.

agents.output_parsers.openai_tools.OpenAIToolsAgentOutputParser

Parses a message into agent actions/finish.

agents.output_parsers.react_json_single_input.ReActJsonSingleInputOutputParser

Parses ReAct-style LLM calls that have a single tool input in json format.

agents.output_parsers.react_single_input.ReActSingleInputOutputParser

Parses ReAct-style LLM calls that have a single tool input.

agents.output_parsers.self_ask.SelfAskOutputParser

Parses self-ask style LLM calls.

agents.output_parsers.tools.ToolAgentAction

Fields:

agents.output_parsers.tools.ToolsAgentOutputParser

Parses a message into agent actions/finish.

agents.output_parsers.xml.XMLAgentOutputParser

Parses tool invocations and final answers in XML format.

agents.react.output_parser.ReActOutputParser

Output parser for the ReAct agent.

agents.schema.AgentScratchPadChatPromptTemplate

Chat prompt template for the agent scratchpad.

agents.structured_chat.output_parser.StructuredChatOutputParser

Output parser for the structured chat agent.

agents.structured_chat.output_parser.StructuredChatOutputParserWithRetries

Output parser with retries for the structured chat agent.

agents.tools.InvalidTool

Tool that is run when invalid tool name is encountered by agent.

callbacks#

callbacks.streaming_aiter.AsyncIteratorCallbackHandler()

Callback handler that returns an async iterator.

callbacks.streaming_aiter_final_only.AsyncFinalIteratorCallbackHandler(*)

Callback handler that returns an async iterator.

callbacks.streaming_stdout_final_only.FinalStreamingStdOutCallbackHandler(*)

Callback handler for streaming in agents.

callbacks.tracers.logging.LoggingCallbackHandler(logger)

Tracer that logs via the input Logger.

chains#

chains.base.Chain

Abstract base class for creating structured sequences of calls to components.

chains.combine_documents.base.BaseCombineDocumentsChain

Base interface for chains combining documents.

chains.combine_documents.map_reduce.MapReduceDocumentsChain

Combining documents by mapping a chain over them, then combining results.

chains.combine_documents.map_rerank.MapRerankDocumentsChain

Combining documents by mapping a chain over them, then reranking results.

chains.combine_documents.reduce.AsyncCombineDocsProtocol(...)

Interface for the combine_docs method.

chains.combine_documents.reduce.CombineDocsProtocol(...)

Interface for the combine_docs method.

chains.combine_documents.reduce.ReduceDocumentsChain

Combine documents by recursively reducing them.

chains.combine_documents.refine.RefineDocumentsChain

Combine documents by doing a first pass and then refining on more documents.

chains.constitutional_ai.base.ConstitutionalChain

Chain for applying constitutional principles.

chains.constitutional_ai.models.ConstitutionalPrinciple

Class for a constitutional principle.

chains.conversational_retrieval.base.BaseConversationalRetrievalChain

Chain for chatting with an index.

chains.conversational_retrieval.base.ChatVectorDBChain

Chain for chatting with a vector database.

chains.conversational_retrieval.base.InputType

Input type for ConversationalRetrievalChain.

chains.elasticsearch_database.base.ElasticsearchDatabaseChain

Chain for interacting with Elasticsearch Database.

chains.flare.base.FlareChain

Chain that combines a retriever, a question generator, and a response generator.

chains.flare.base.QuestionGeneratorChain

Chain that generates questions from uncertain spans.

chains.flare.prompts.FinishedOutputParser

Output parser that checks if the output is finished.

chains.hyde.base.HypotheticalDocumentEmbedder

Generate hypothetical document for query, and then embed that.

chains.llm_math.base.LLMMathChain

Chain that interprets a prompt and executes python code to do math.

chains.moderation.OpenAIModerationChain

Pass input through a moderation endpoint.

chains.natbot.base.NatBotChain

Implement an LLM driven browser.

chains.natbot.crawler.Crawler()

A crawler for web pages.

chains.natbot.crawler.ElementInViewPort

A typed dictionary containing information about elements in the viewport.

chains.openai_functions.citation_fuzzy_match.FactWithEvidence

Class representing a single statement.

chains.openai_functions.citation_fuzzy_match.QuestionAnswer

A question and its answer as a list of facts each one should have a source.

chains.openai_functions.openapi.SimpleRequestChain

Chain for making a simple request to an API endpoint.

chains.openai_functions.qa_with_structure.AnswerWithSources

An answer to the question, with sources.

chains.prompt_selector.BasePromptSelector

Base class for prompt selectors.

chains.prompt_selector.ConditionalPromptSelector

Prompt collection that goes through conditionals.

chains.qa_with_sources.loading.LoadingCallable(...)

Interface for loading the combine documents chain.

chains.qa_with_sources.retrieval.RetrievalQAWithSourcesChain

Question-answering with sources over an index.

chains.qa_with_sources.vector_db.VectorDBQAWithSourcesChain

Question-answering with sources over a vector database.

chains.query_constructor.base.StructuredQueryOutputParser

Output parser that parses a structured query.

chains.query_constructor.parser.ISO8601Date

A date in ISO 8601 format (YYYY-MM-DD).

chains.query_constructor.schema.AttributeInfo

Information about a data source attribute.

chains.question_answering.chain.LoadingCallable(...)

Interface for loading the combine documents chain.

chains.router.base.MultiRouteChain

Use a single chain to route an input to one of multiple candidate chains.

chains.router.base.Route(destination, ...)

Create new instance of Route(destination, next_inputs)

chains.router.base.RouterChain

Chain that outputs the name of a destination chain and the inputs to it.

chains.router.embedding_router.EmbeddingRouterChain

Chain that uses embeddings to route between options.

chains.router.llm_router.RouterOutputParser

Parser for output of router chain in the multi-prompt chain.

chains.router.multi_retrieval_qa.MultiRetrievalQAChain

A multi-route chain that uses an LLM router chain to choose amongst retrieval qa chains.

chains.sequential.SequentialChain

Chain where the outputs of one chain feed directly into next.

chains.sequential.SimpleSequentialChain

Simple chain where the outputs of one step feed directly into next.

chains.sql_database.query.SQLInput

Input for a SQL Chain.

chains.sql_database.query.SQLInputWithTables

Input for a SQL Chain.

chains.summarize.chain.LoadingCallable(...)

Interface for loading the combine documents chain.

chains.transform.TransformChain

Chain that transforms the chain output.

chat_models#

embeddings#

embeddings.cache.CacheBackedEmbeddings(...)

Interface for caching results from embedding models.

evaluation#

evaluation.agents.trajectory_eval_chain.TrajectoryEval

A named tuple containing the score and reasoning for a trajectory.

evaluation.agents.trajectory_eval_chain.TrajectoryEvalChain

A chain for evaluating ReAct style agents.

evaluation.agents.trajectory_eval_chain.TrajectoryOutputParser

Trajectory output parser.

evaluation.comparison.eval_chain.LabeledPairwiseStringEvalChain

A chain for comparing two outputs, such as the outputs

evaluation.comparison.eval_chain.PairwiseStringEvalChain

A chain for comparing two outputs, such as the outputs

evaluation.comparison.eval_chain.PairwiseStringResultOutputParser

A parser for the output of the PairwiseStringEvalChain.

evaluation.criteria.eval_chain.Criteria(value)

A Criteria to evaluate.

evaluation.criteria.eval_chain.CriteriaEvalChain

LLM Chain for evaluating runs against criteria.

evaluation.criteria.eval_chain.CriteriaResultOutputParser

A parser for the output of the CriteriaEvalChain.

evaluation.criteria.eval_chain.LabeledCriteriaEvalChain

Criteria evaluation chain that requires references.

evaluation.embedding_distance.base.EmbeddingDistance(value)

Embedding Distance Metric.

evaluation.embedding_distance.base.EmbeddingDistanceEvalChain

Use embedding distances to score semantic difference between a prediction and reference.

evaluation.embedding_distance.base.PairwiseEmbeddingDistanceEvalChain

Use embedding distances to score semantic difference between two predictions.

evaluation.exact_match.base.ExactMatchStringEvaluator(*)

Compute an exact match between the prediction and the reference.

evaluation.parsing.base.JsonEqualityEvaluator([...])

Evaluate whether the prediction is equal to the reference after

evaluation.parsing.base.JsonValidityEvaluator(...)

Evaluate whether the prediction is valid JSON.

evaluation.parsing.json_distance.JsonEditDistanceEvaluator([...])

An evaluator that calculates the edit distance between JSON strings.

evaluation.parsing.json_schema.JsonSchemaEvaluator(...)

An evaluator that validates a JSON prediction against a JSON schema reference.

evaluation.qa.eval_chain.ContextQAEvalChain

LLM Chain for evaluating QA w/o GT based on context

evaluation.qa.eval_chain.CotQAEvalChain

LLM Chain for evaluating QA using chain of thought reasoning.

evaluation.qa.eval_chain.QAEvalChain

LLM Chain for evaluating question answering.

evaluation.qa.generate_chain.QAGenerateChain

LLM Chain for generating examples for question answering.

evaluation.regex_match.base.RegexMatchStringEvaluator(*)

Compute a regex match between the prediction and the reference.

evaluation.schema.AgentTrajectoryEvaluator()

Interface for evaluating agent trajectories.

evaluation.schema.EvaluatorType(value[, ...])

The types of the evaluators.

evaluation.schema.LLMEvalChain

A base class for evaluators that use an LLM.

evaluation.schema.PairwiseStringEvaluator()

Compare the output of two models (or two outputs of the same model).

evaluation.schema.StringEvaluator()

Grade, tag, or otherwise evaluate predictions relative to their inputs and/or reference labels.

evaluation.scoring.eval_chain.LabeledScoreStringEvalChain

A chain for scoring the output of a model on a scale of 1-10.

evaluation.scoring.eval_chain.ScoreStringEvalChain

A chain for scoring on a scale of 1-10 the output of a model.

evaluation.scoring.eval_chain.ScoreStringResultOutputParser

A parser for the output of the ScoreStringEvalChain.

evaluation.string_distance.base.PairwiseStringDistanceEvalChain

Compute string edit distances between two predictions.

evaluation.string_distance.base.StringDistance(value)

Distance metric to use.

evaluation.string_distance.base.StringDistanceEvalChain

Compute string distances between the prediction and the reference.

globals#

hub#

indexes#

indexes.vectorstore.VectorStoreIndexWrapper

Wrapper around a vectorstore for easy access.

indexes.vectorstore.VectorstoreIndexCreator

Logic for creating indexes.

memory#

memory.buffer.ConversationBufferMemory

Buffer for storing conversation memory.

memory.buffer.ConversationStringBufferMemory

Buffer for storing conversation memory.

memory.buffer_window.ConversationBufferWindowMemory

Buffer for storing conversation memory inside a limited size window.

memory.chat_memory.BaseChatMemory

Abstract base class for chat memory.

memory.combined.CombinedMemory

Combining multiple memories' data together.

memory.entity.BaseEntityStore

Abstract base class for Entity store.

memory.entity.ConversationEntityMemory

Entity extractor & summarizer memory.

memory.entity.InMemoryEntityStore

In-memory Entity store.

memory.entity.RedisEntityStore

Redis-backed Entity store.

memory.entity.SQLiteEntityStore

SQLite-backed Entity store

memory.entity.UpstashRedisEntityStore

Upstash Redis backed Entity store.

memory.readonly.ReadOnlySharedMemory

Memory wrapper that is read-only and cannot be changed.

memory.simple.SimpleMemory

Simple memory for storing context or other information that shouldn't ever change between prompts.

memory.summary.ConversationSummaryMemory

Conversation summarizer to chat memory.

memory.summary_buffer.ConversationSummaryBufferMemory

Buffer with summarizer for storing conversation memory.

memory.token_buffer.ConversationTokenBufferMemory

Conversation chat memory with token limit.

memory.vectorstore.VectorStoreRetrieverMemory

VectorStoreRetriever-backed memory.

memory.vectorstore_token_buffer_memory.ConversationVectorStoreTokenBufferMemory

Conversation chat memory with token limit and vectordb backing.

model_laboratory#

model_laboratory.ModelLaboratory(chains[, names])

Experiment with different models.

output_parsers#

output_parsers.boolean.BooleanOutputParser

Parse the output of an LLM call to a boolean.

output_parsers.combining.CombiningOutputParser

Combine multiple output parsers into one.

output_parsers.datetime.DatetimeOutputParser

Parse the output of an LLM call to a datetime.

output_parsers.enum.EnumOutputParser

Parse an output that is one of a set of values.

output_parsers.fix.OutputFixingParser

Wrap a parser and try to fix parsing errors.

output_parsers.fix.OutputFixingParserRetryChainInput

output_parsers.pandas_dataframe.PandasDataFrameOutputParser

Parse an output using Pandas DataFrame format.

output_parsers.regex.RegexParser

Parse the output of an LLM call using a regex.

output_parsers.regex_dict.RegexDictParser

Parse the output of an LLM call into a Dictionary using a regex.

output_parsers.retry.RetryOutputParser

Wrap a parser and try to fix parsing errors.

output_parsers.retry.RetryOutputParserRetryChainInput

output_parsers.retry.RetryWithErrorOutputParser

Wrap a parser and try to fix parsing errors.

output_parsers.retry.RetryWithErrorOutputParserRetryChainInput

output_parsers.structured.ResponseSchema

Schema for a response from a structured output parser.

output_parsers.structured.StructuredOutputParser

Parse the output of an LLM call to a structured output.

output_parsers.yaml.YamlOutputParser

Parse YAML output using a pydantic model.

retrievers#

retrievers.contextual_compression.ContextualCompressionRetriever

Retriever that wraps a base retriever and compresses the results.

retrievers.document_compressors.base.DocumentCompressorPipeline

Document compressor that uses a pipeline of Transformers.

retrievers.document_compressors.chain_extract.LLMChainExtractor

Document compressor that uses an LLM chain to extract the relevant parts of documents.

retrievers.document_compressors.chain_extract.NoOutputParser

Parse outputs that could return a null string of some sort.

retrievers.document_compressors.chain_filter.LLMChainFilter

Filter that drops documents that aren't relevant to the query.

retrievers.document_compressors.cross_encoder.BaseCrossEncoder()

Interface for cross encoder models.

retrievers.document_compressors.cross_encoder_rerank.CrossEncoderReranker

Document compressor that uses CrossEncoder for reranking.

retrievers.document_compressors.embeddings_filter.EmbeddingsFilter

Document compressor that uses embeddings to drop documents unrelated to the query.

retrievers.document_compressors.listwise_rerank.LLMListwiseRerank

Document compressor that uses Zero-Shot Listwise Document Reranking.

retrievers.ensemble.EnsembleRetriever

Retriever that ensembles the multiple retrievers.

retrievers.merger_retriever.MergerRetriever

Retriever that merges the results of multiple retrievers.

retrievers.multi_query.LineListOutputParser

Output parser for a list of lines.

retrievers.multi_query.MultiQueryRetriever

Given a query, use an LLM to write a set of queries.

retrievers.multi_vector.MultiVectorRetriever

Retrieve from a set of multiple embeddings for the same document.

retrievers.multi_vector.SearchType(value[, ...])

Enumerator of the types of search to perform.

retrievers.parent_document_retriever.ParentDocumentRetriever

Retrieve small chunks then retrieve their parent documents.

retrievers.re_phraser.RePhraseQueryRetriever

Given a query, use an LLM to re-phrase it.

retrievers.self_query.base.SelfQueryRetriever

Retriever that uses a vector store and an LLM to generate the vector store queries.

retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever

Retriever that combines embedding similarity with recency in retrieving values.

runnables#

runnables.hub.HubRunnable

An instance of a runnable stored in the LangChain Hub.

runnables.openai_functions.OpenAIFunction

A function description for ChatOpenAI

runnables.openai_functions.OpenAIFunctionsRouter

A runnable that routes to the selected function.

smith#

smith.evaluation.config.EvalConfig

Configuration for a given run evaluator.

smith.evaluation.config.RunEvalConfig

Configuration for a run evaluation.

smith.evaluation.config.SingleKeyEvalConfig

Configuration for a run evaluator that only requires a single key.

smith.evaluation.progress.ProgressBarCallback(total)

A simple progress bar for the console.

smith.evaluation.runner_utils.ChatModelInput

Input for a chat model.

smith.evaluation.runner_utils.EvalError(...)

Your architecture raised an error.

smith.evaluation.runner_utils.InputFormatError

Raised when the input format is invalid.

smith.evaluation.runner_utils.TestResult

A dictionary of the results of a single test run.

smith.evaluation.string_run_evaluator.ChainStringRunMapper

Extract items to evaluate from the run object from a chain.

smith.evaluation.string_run_evaluator.LLMStringRunMapper

Extract items to evaluate from the run object.

smith.evaluation.string_run_evaluator.StringExampleMapper

Map an example, or row in the dataset, to the inputs of an evaluation.

smith.evaluation.string_run_evaluator.StringRunEvaluatorChain

Evaluate Run and optional examples.

smith.evaluation.string_run_evaluator.StringRunMapper

Extract items to evaluate from the run object.

smith.evaluation.string_run_evaluator.ToolStringRunMapper

Map an input to the tool.

storage#

storage.encoder_backed.EncoderBackedStore(...)

Wraps a store with key and value encoders/decoders.

storage.file_system.LocalFileStore(root_path, *)

BaseStore interface that works on the local file system.