langchain_core
0.1.16¶
langchain_core.agents
¶
Classes¶
A full description of an action for an ActionAgent to execute. |
|
Override init to support instantiation by position for backward compat. |
|
The final return value of an ActionAgent. |
|
The result of running an AgentAction. |
Functions¶
langchain_core.beta
¶
Classes¶
Context for a runnable. |
|
[Beta] Get a context value.[Beta] Get a context value. |
|
[Beta] Set a context value.[Beta] Set a context value. |
|
|
Context for a runnable with a prefix. |
Functions¶
Asynchronously patch a runnable config with context getters and setters. |
|
Patch a runnable config with context getters and setters. |
langchain_core.caches
¶
Classes¶
Base interface for cache. |
langchain_core.callbacks
¶
Classes¶
Async callback handler that handles callbacks from LangChain. |
|
Base callback handler that handles callbacks from LangChain. |
|
|
Base callback manager that handles callbacks from LangChain. |
Mixin for callback manager. |
|
Mixin for chain callbacks. |
|
Mixin for LLM callbacks. |
|
Mixin for Retriever callbacks. |
|
Mixin for run manager. |
|
Mixin for tool callbacks. |
|
|
Async callback manager that handles callbacks from LangChain. |
Async callback manager for the chain group. |
|
Async callback manager for chain run. |
|
Async callback manager for LLM run. |
|
|
Async callback manager for retriever run. |
Async callback manager for tool run. |
|
Async Parent Run Manager. |
|
|
Async Run Manager. |
|
Base class for run manager (a bound callback manager). |
|
Callback manager that handles callbacks from LangChain. |
Callback manager for the chain group. |
|
Callback manager for chain run. |
|
Callback manager for LLM run. |
|
Callback manager for retriever run. |
|
Callback manager for tool run. |
|
|
Sync Parent Run Manager. |
|
Sync Run Manager. |
Callback Handler that prints to std out. |
|
Callback handler for streaming. |
Functions¶
|
Generic event handler for AsyncCallbackManager. |
Get an async callback manager for a chain group in a context manager. |
|
|
Generic event handler for CallbackManager. |
Get a callback manager for a chain group in a context manager. |
langchain_core.chat_history
¶
Classes¶
Abstract base class for storing chat message history. |
langchain_core.chat_sessions
¶
Classes¶
Chat Session represents a single conversation, channel, or other group of messages. |
langchain_core.documents
¶
Classes¶
Class for storing a piece of text and associated metadata. |
|
Abstract base class for document transformation systems. |
langchain_core.embeddings
¶
Classes¶
Interface for embedding models. |
langchain_core.example_selectors
¶
Logic for selecting examples to include in prompts.
Classes¶
Interface for selecting examples to include in prompts. |
|
Select examples based on length. |
|
|
ExampleSelector that selects examples based on Max Marginal Relevance. |
|
Example selector that selects examples based on SemanticSimilarity. |
Functions¶
Return a list of values in dict sorted by key. |
langchain_core.exceptions
¶
Classes¶
General LangChain exception. |
|
|
Exception that output parsers should raise to signify a parsing error. |
Base class for exceptions in tracers module. |
langchain_core.language_models
¶
Classes¶
Abstract base class for interfacing with language models. |
|
Base class for Chat models. |
|
Simple Chat Model. |
|
Base LLM abstract interface. |
|
Base LLM abstract class. |
Functions¶
Async generate from a stream. |
|
Generate from a stream. |
|
Create a retry decorator for a given LLM and provided list of error types. |
|
|
Get prompts that are already cached. |
Update the cache and get the LLM output. |
langchain_core.load
¶
Serialization and deserialization.
Classes¶
|
Reviver for JSON objects. |
Base class for serialized objects. |
|
Serializable base class. |
|
Serialized constructor. |
|
Serialized not implemented. |
|
Serialized secret. |
Functions¶
|
Return a default value for a Serializable object or a SerializedNotImplemented object. |
|
Return a json dict representation of an object. |
|
Return a json string representation of an object. |
|
[Beta] Revive a LangChain class from a JSON object. |
|
[Beta] Revive a LangChain class from a JSON string. |
Serialize a "not implemented" object. |
|
|
Try to determine if a value is different from the default. |
langchain_core.memory
¶
Classes¶
Abstract base class for memory in Chains. |
langchain_core.messages
¶
Classes¶
A Message from an AI. |
|
A Message chunk from an AI. |
|
The base abstract Message class. |
|
A Message chunk, which can be concatenated with other Message chunks. |
|
A Message that can be assigned an arbitrary speaker (i.e. |
|
A Chat Message chunk. |
|
A Message for passing the result of executing a function back to a model. |
|
A Function Message chunk. |
|
A Message from a human. |
|
A Human Message chunk. |
|
A Message for priming AI behavior, usually passed in as the first of a sequence of input messages. |
|
A System Message chunk. |
|
A Message for passing the result of executing a tool back to a model. |
|
A Tool Message chunk. |
Functions¶
|
|
|
Merge two message contents. |
|
Convert a Message to a dictionary. |
|
Convert a sequence of Messages to a list of dictionaries. |
langchain_core.output_parsers
¶
Classes¶
Base class to parse the output of an LLM call. |
|
Abstract base class for parsing the outputs of a model. |
|
Base class to parse the output of an LLM call. |
|
Parse the output of an LLM call to a JSON object. |
|
alias of |
|
Parse the output of an LLM call to a comma-separated list. |
|
Parse the output of an LLM call to a list. |
|
Parse a markdown list. |
|
Parse a numbered list. |
|
OutputParser that parses LLMResult into the top likely string. |
|
|
Base class for an output parser that can handle streaming input. |
Base class for an output parser that can handle streaming input. |
|
Parse an output using xml format. |
Functions¶
Parse a JSON string from a Markdown string and check that it contains the expected keys. |
|
Parse a JSON string from a Markdown string. |
|
Parse a JSON string that may be missing closing braces. |
|
|
Drop the last n elements of an iterator. |
|
Get nested element from path. |
langchain_core.outputs
¶
Classes¶
A single chat generation output. |
|
A ChatGeneration chunk, which can be concatenated with other |
|
Class that contains all results for a single chat model call. |
|
A single text generation output. |
|
A Generation chunk, which can be concatenated with other Generation chunks. |
|
Class that contains all results for a batched LLM call. |
|
Class that contains metadata for a single execution of a Chain or model. |
langchain_core.prompt_values
¶
Classes¶
Chat prompt value. |
|
Chat prompt value which explicitly lists out the message types it accepts. |
|
Base abstract class for inputs to any language model. |
|
String prompt value. |
langchain_core.prompts
¶
Prompt is the input to the model.
Prompt is often constructed from multiple components. Prompt classes and functions make constructing
and working with prompts easy.
Class hierarchy:
BasePromptTemplate --> PipelinePromptTemplate
StringPromptTemplate --> PromptTemplate
FewShotPromptTemplate
FewShotPromptWithTemplates
BaseChatPromptTemplate --> AutoGPTPrompt
ChatPromptTemplate --> AgentScratchPadChatPromptTemplate
BaseMessagePromptTemplate --> MessagesPlaceholder
BaseStringMessagePromptTemplate --> ChatMessagePromptTemplate
HumanMessagePromptTemplate
AIMessagePromptTemplate
SystemMessagePromptTemplate
Classes¶
Base class for all prompt templates, returning a prompt. |
|
AI message prompt template. |
|
Base class for chat prompt templates. |
|
Base class for message prompt templates. |
|
Base class for message prompt templates that use a string prompt template. |
|
Chat message prompt template. |
|
A prompt template for chat models. |
|
Human message prompt template. |
|
Prompt template that assumes variable is already list of messages. |
|
System message prompt template. |
|
Chat prompt template that supports few-shot examples. |
|
Prompt template that contains few shot examples. |
|
Prompt template that contains few shot examples. |
|
A prompt template for composing multiple prompt templates together. |
|
A prompt template for a language model. |
|
String prompt that exposes the format method, returning a prompt. |
Functions¶
|
Format a document into a string based on a prompt template. |
Unified method for loading a prompt from LangChainHub or local fs. |
|
Load prompt from Config Dict. |
|
Check that template string is valid. |
|
Get the variables from the template. |
|
|
Format a template using jinja2. |
|
Validate that the input variables are valid for the template. |
langchain_core.retrievers
¶
Classes¶
Abstract base class for a Document retrieval system. |
langchain_core.runnables
¶
LangChain Runnable and the LangChain Expression Language (LCEL).
The LangChain Expression Language (LCEL) offers a declarative method to build production-grade programs that harness the power of LLMs.
Programs created using LCEL and LangChain Runnables inherently support synchronous, asynchronous, batch, and streaming operations.
Support for async allows servers hosting LCEL based programs to scale better for higher concurrent loads.
Streaming of intermediate outputs as they’re being generated allows for creating more responsive UX.
This module contains schema and implementation of LangChain Runnables primitives.
Classes¶
A unit of work that can be invoked, batched, streamed, transformed and composed. |
|
Wrap a runnable with additional functionality. |
|
A runnable that delegates calls to another runnable with a set of kwargs. |
|
A runnable that delegates calls to another runnable with each element of the input sequence. |
|
A runnable that delegates calls to another runnable with each element of the input sequence. |
|
|
A runnable that runs a generator function. |
|
RunnableLambda converts a python callable into a Runnable. |
alias of |
|
A runnable that runs a mapping of runnables in parallel, and returns a mapping of their outputs. |
|
A sequence of runnables, where the output of each is the input of the next. |
|
A Runnable that can be serialized to JSON. |
|
A Runnable that selects which branch to run based on a condition. |
|
ThreadPoolExecutor that copies the context to the child thread. |
|
Empty dict type. |
|
Configuration for a Runnable. |
|
A Serializable Runnable that can be dynamically configured. |
|
A Runnable that can be dynamically configured. |
|
A Runnable that can be dynamically configured. |
|
|
A string enum. |
A Runnable that can fallback to other Runnables if it fails. |
|
|
Create new instance of Edge(source, target) |
|
|
|
Create new instance of Node(id, data) |
|
Class for drawing in ASCII. |
Class to define vertex box boundaries that will be accounted for during graph building by grandalf. |
|
A runnable that manages chat message history for another runnable. |
|
A runnable that assigns key-value pairs to Dict[str, Any] inputs. |
|
A runnable to passthrough inputs unchanged or with additional keys. |
|
A runnable that picks keys from Dict[str, Any] inputs. |
|
Retry a Runnable if it fails. |
|
A Router input. |
|
A runnable that routes to a set of runnables based on Input['key']. |
|
Data associated with a streaming event. |
|
A streaming event. |
|
Dictionary that can be added to another dictionary. |
|
|
A field that can be configured by the user. |
A field that can be configured by the user with multiple default values. |
|
A field that can be configured by the user with a default value. |
|
A field that can be configured by the user. |
|
Get the nonlocal variables accessed of a function. |
|
Get the source code of a lambda function. |
|
Check if the first argument of a function is a dict. |
|
|
Check if a name is a local dict. |
Get nonlocal variables accessed. |
|
|
Protocol for objects that support addition. |
Functions¶
Decorate a function to make it a Runnable. |
|
Coerce a runnable-like object into a Runnable. |
|
Call function that may optionally accept a run_manager and/or config. |
|
Call function that may optionally accept a run_manager and/or config. |
|
|
Ensure that a config is a dict with all keys present. |
|
Get an async callback manager for a config. |
Get a callback manager for a config. |
|
|
Get a list of configs from a single config or a list of configs. |
Get an executor for a config. |
|
|
Merge multiple configs into one. |
|
Patch a config with new values. |
Run a function in an executor. |
|
Make a ConfigurableFieldSpec for a ConfigurableFieldSingleOption or ConfigurableFieldMultiOption. |
|
Prefix the id of a ConfigurableFieldSpec. |
|
|
Build a DAG and draw it in ASCII. |
An async identity function |
|
An identity function |
|
|
Asynchronously add a sequence of addable objects together. |
|
Check if a callable accepts a config argument. |
|
Check if a callable accepts a context argument. |
|
Check if a callable accepts a run_manager argument. |
|
Add a sequence of addable objects together. |
|
Run a coroutine with a semaphore. |
Gather coroutines with a limit on the number of concurrent coroutines. |
|
Get the keys of the first argument of a function if it is a dict. |
|
Get the nonlocal variables accessed by a function. |
|
Get the source code of a lambda function. |
|
Get the unique config specs from a sequence of config specs. |
|
Indent all lines of text after the first line. |
langchain_core.stores
¶
Classes¶
Abstract interface for a key-value store. |
langchain_core.sys_info
¶
Print information about the system and langchain packages for debugging purposes.
Functions¶
|
Print information about the environment for debugging purposes. |
langchain_core.tools
¶
Base implementation for tools or skills.
Classes¶
Interface LangChain tools must implement. |
|
Raised when 'args_schema' is missing or has an incorrect type annotation. |
|
Tool that can operate on any number of inputs. |
|
Tool that takes in function or coroutine directly. |
|
An optional exception that tool throws when execution error occurs. |
Functions¶
Create a pydantic schema from a function's signature. |
|
|
Make tools out of functions, can be used with or without arguments. |
langchain_core.tracers
¶
Classes¶
|
Base interface for tracers. |
A tracer that runs a run evaluator whenever a run is persisted. |
|
An implementation of the SharedTracer that POSTS to the langchain endpoint. |
|
|
[Deprecated] An implementation of the SharedTracer that POSTS to the langchain endpoint.[Deprecated] An implementation of the SharedTracer that POSTS to the langchain endpoint. |
A single entry in the run log. |
|
A tracer that streams run logs to a stream. |
|
|
A run log. |
A patch to the run log. |
|
State of the run. |
|
A tracer that calls listeners on run start, end, and error. |
|
A tracer that collects all nested runs in a list. |
|
[Deprecated] Base class for Run.[Deprecated] Base class for Run. |
|
[Deprecated] Class for ChainRun.[Deprecated] Class for ChainRun. |
|
[Deprecated] Class for LLMRun.[Deprecated] Class for LLMRun. |
|
Run schema for the V2 API in the Tracer. |
|
[Deprecated] Class for ToolRun.[Deprecated] Class for ToolRun. |
|
[Deprecated] TracerSessionV1 schema for the V2 API.[Deprecated] TracerSessionV1 schema for the V2 API. |
|
[Deprecated] Base class for TracerSession.[Deprecated] Base class for TracerSession. |
|
[Deprecated] TracerSessionV1 schema.[Deprecated] TracerSessionV1 schema. |
|
[Deprecated] Base class for TracerSessionV1.[Deprecated] Base class for TracerSessionV1. |
|
[Deprecated] Create class for TracerSessionV1.[Deprecated] Create class for TracerSessionV1. |
|
|
Tracer that prints to the console. |
Tracer that calls a function with a single str parameter. |
Functions¶
Collect all run traces in context. |
|
Register a configure hook. |
|
|
[Deprecated] Get the Deprecated LangChainTracer in a context manager. |
Instruct LangChain to log all runs in context to LangSmith. |
|
Wait for all tracers to finish. |
|
Get the client. |
|
|
Log an error once. |
Wait for all tracers to finish. |
|
Get the headers for the LangChain API. |
|
[Deprecated] RunTypeEnum.[Deprecated] RunTypeEnum. |
|
Get the elapsed time of a run. |
|
|
Try to stringify an object to JSON. |
langchain_core.utils
¶
Utility functions for LangChain.
These functions do not depend on any other LangChain module.
Classes¶
Dummy lock that provides the proper interface but no protection |
|
|
Create |
alias of |
|
A subclass of formatter that checks for extra keys. |
|
Representation of a callable function to send to an LLM. |
|
Representation of a callable function to the OpenAI API. |
|
Dummy lock that provides the proper interface but no protection |
|
|
Create |
alias of |
Functions¶
|
Pure-Python implementation of anext() for testing purposes. |
|
An individual iterator of a |
|
Check if an environment variable is set. |
|
Get a value from a dictionary or an environment variable. |
|
Get a value from a dictionary or an environment variable. |
|
[Deprecated] Converts a Pydantic model to a function description for the OpenAI API.[Deprecated] Converts a Pydantic model to a function description for the OpenAI API. |
[Deprecated] Converts a Pydantic model to a function description for the OpenAI API.[Deprecated] Converts a Pydantic model to a function description for the OpenAI API. |
|
|
[Deprecated] Convert a Python function to an OpenAI function-calling API compatible dict. |
Convert a raw function/class to an OpenAI function. |
|
Convert a raw function/class to an OpenAI tool. |
|
[Deprecated] Format tool into the OpenAI function API.[Deprecated] Format tool into the OpenAI function API. |
|
[Deprecated] Format tool into the OpenAI function API.[Deprecated] Format tool into the OpenAI function API. |
|
|
Extract all links from a raw html string and convert into absolute paths. |
|
Extract all links from a raw html string. |
Get bolded text. |
|
|
Get mapping for items to a support color. |
|
Get colored text. |
|
Print text with highlighting and no end characters. |
Determine if running within IPython or Jupyter. |
|
|
Utility batching function. |
|
An individual iterator of a |
|
Try to substitute $refs in JSON Schema. |
|
Load configuration from hub. |
Get the major version of Pydantic. |
|
|
Convert a list to a comma-separated string. |
Stringify a dictionary. |
|
Stringify a value. |
|
|
Build extra kwargs from values and extra_kwargs. |
|
Check the version of a package. |
Convert a string to a SecretStr if needed. |
|
Get field names, including aliases, for a pydantic class. |
|
|
Dynamically imports a module and raises a helpful exception if the module is not installed. |
|
Context manager for mocking out datetime.now() in unit tests. |
|
Raise an error with the response text. |
|
Validate specified keyword args are mutually exclusive. |
langchain_core.vectorstores
¶
Classes¶
Interface for vector store. |
|
Base Retriever class for VectorStore. |