LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-core

    langchain-core

    Description

    🦜🍎️ LangChain Core

    PyPI - Version PyPI - License PyPI - Downloads Twitter

    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.

    Quick Install

    pip install langchain-core

    🤔 What is this?

    LangChain Core contains the base abstractions that power the LangChain ecosystem.

    These abstractions are designed to be as modular and simple as possible.

    The benefit of having these abstractions is that any provider can implement the required interface and then easily be used in the rest of the LangChain ecosystem.

    ⛰️ Why build on top of LangChain Core?

    The LangChain ecosystem is built on top of langchain-core. Some of the benefits:

    • Modularity: We've designed Core around abstractions that are independent of each other, and not tied to any specific model provider.
    • Stability: We are committed to a stable versioning scheme, and will communicate any breaking changes with advance notice and version bumps.
    • Battle-tested: Core components have the largest install base in the LLM ecosystem, and are used in production by many companies.

    📖 Documentation

    For full documentation, see the API reference. For conceptual guides, tutorials, and examples on using LangChain, see the LangChain Docs. You can also chat with the docs using Chat LangChain.

    📕 Releases & Versioning

    See our Releases and Versioning policies.

    💁 Contributing

    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.

    Classes

    Class

    Visitor

    Defines interface for IR translation using a visitor pattern.

    Class

    Expr

    Base class for all expressions.

    Class

    Operator

    Enumerator of the operations.

    Class

    Comparator

    Enumerator of the comparison operators.

    Class

    FilterDirective

    Filtering expression.

    Class

    Comparison

    Comparison to a value.

    Class

    Operation

    Logical operation over other directives.

    Class

    StructuredQuery

    Structured query.

    Class

    BaseRateLimiter

    Base class for rate limiters.

    Class

    InMemoryRateLimiter

    An in memory rate limiter based on a token bucket algorithm.

    Class

    PromptValue

    Base abstract class for inputs to any language model.

    Class

    StringPromptValue

    String prompt value.

    Class

    ChatPromptValue

    Chat prompt value.

    Class

    ImageURL

    Image URL for multimodal model inputs (OpenAI format).

    Class

    ImagePromptValue

    Image prompt value.

    Class

    ChatPromptValueConcrete

    Chat prompt value which explicitly lists out the message types it accepts.

    Class

    ChatSession

    Chat Session.

    Class

    AgentAction

    Represents a request to execute an action by an agent.

    Class

    AgentActionMessageLog

    Representation of an action to be executed by an agent.

    Class

    AgentStep

    Result of running an AgentAction.

    Class

    AgentFinish

    Final return value of an ActionAgent.

    Class

    LangChainException

    General LangChain exception.

    Class

    TracerException

    Base class for exceptions in tracers module.

    Class

    OutputParserException

    Exception that output parsers should raise to signify a parsing error.

    Class

    ContextOverflowError

    Exception raised when input exceeds the model's context limit.

    Class

    ErrorCode

    Error codes.

    Class

    BaseCache

    Interface for a caching layer for LLMs and Chat models.

    Class

    InMemoryCache

    Cache that stores things in memory.

    Class

    BaseChatMessageHistory

    Abstract base class for storing chat message history.

    Class

    InMemoryChatMessageHistory

    In memory implementation of chat message history.

    Class

    LangSmithRetrieverParams

    LangSmith parameters for tracing.

    Class

    BaseRetriever

    Abstract base class for a document retrieval system.

    Class

    BaseChatLoader

    Base class for chat loaders.

    Class

    BaseStore

    Abstract interface for a key-value store.

    Class

    InMemoryBaseStore

    In-memory implementation of the BaseStore using a dictionary.

    Class

    InMemoryStore

    In-memory store for any type of data.

    Class

    InMemoryByteStore

    In-memory store for bytes.

    Class

    InvalidKeyException

    Raised when a key is invalid; e.g., uses incorrect characters.

    Class

    LangSmithLoader

    Load LangSmith Dataset examples as Document objects.

    Class

    BlobLoader

    Abstract interface for blob loaders implementation.

    Class

    BaseLoader

    Interface for document loader.

    Class

    BaseBlobParser

    Abstract interface for blob parsers.

    Class

    Generation

    A single text generation output.

    Class

    GenerationChunk

    GenerationChunk, which can be concatenated with other Generation chunks.

    Class

    LLMResult

    A container for results of an LLM call.

    Class

    RunInfo

    Class that contains metadata for a single execution of a chain or model.

    Class

    ChatGeneration

    A single chat generation output.

    Class

    ChatGenerationChunk

    ChatGeneration chunk.

    Class

    ChatResult

    Use to represent the result of a chat model call with a single prompt.

    Class

    StrictFormatter

    A string formatter that enforces keyword-only argument substitution.

    Class

    NoLock

    Dummy lock that provides the proper interface but no protection.

    Class

    Tee

    Create n separate asynchronous iterators over iterable.

    Class

    aclosing

    Async context manager to wrap an AsyncGenerator that has a aclose() method.

    Class

    FunctionDescription

    Representation of a callable function to send to an LLM.

    Class

    ToolDescription

    Representation of a callable function to the OpenAI API.

    Class

    NoLock

    Dummy lock that provides the proper interface but no protection.

    Class

    Tee

    Create n separate asynchronous iterators over iterable.

    Class

    ChevronError

    Custom exception for Chevron errors.

    Class

    Stringifiable

    Protocol for objects that can be converted to a string.

    Class

    LabelsDict

    Dictionary of labels for nodes and edges in a graph.

    Class

    Edge

    Edge in a graph.

    Class

    Node

    Node in a graph.

    Class

    Branch

    Branch in a graph.

    Class

    CurveStyle

    Enum for different curve styles supported by Mermaid.

    Class

    NodeStyles

    Schema for Hexadecimal color codes for different node types.

    Class

    MermaidDrawMethod

    Enum for different draw methods supported by Mermaid.

    Class

    Graph

    Graph of nodes and edges.

    Class

    ExponentialJitterParams

    Parameters for tenacity.wait_exponential_jitter.

    Class

    RunnableRetry

    Retry a Runnable if it fails.

    Class

    RunnablePassthrough

    Runnable to passthrough inputs unchanged or with additional keys.

    Class

    RunnableAssign

    Runnable that assigns key-value pairs to dict[str, Any] inputs.

    Class

    RunnablePick

    Runnable that picks keys from dict[str, Any] inputs.

    Class

    DynamicRunnable

    Serializable Runnable that can be dynamically configured.

    Class

    RunnableConfigurableFields

    Runnable that can be dynamically configured.

    Class

    StrEnum

    String enum.

    Class

    RunnableConfigurableAlternatives

    Runnable that can be dynamically configured.

    Class

    IsLocalDict

    Check if a name is a local dict.

    Class

    IsFunctionArgDict

    Check if the first argument of a function is a dict.

    Class

    NonLocals

    Get nonlocal variables accessed.

    Class

    FunctionNonLocals

    Get the nonlocal variables accessed of a function.

    Class

    GetLambdaSource

    Get the source code of a lambda function.

    Class

    AddableDict

    Dictionary that can be added to another dictionary.

    Class

    SupportsAdd

    Protocol for objects that support addition.

    Class

    ConfigurableField

    Field that can be configured by the user.

    Class

    ConfigurableFieldSingleOption

    Field that can be configured by the user with a default value.

    Class

    ConfigurableFieldMultiOption

    Field that can be configured by the user with multiple default values.

    Class

    ConfigurableFieldSpec

    Field that can be configured by the user. It is a specification of a field.

    Class

    RunnableBranch

    Runnable that selects which branch to run based on a condition.

    Class

    RunnableWithFallbacks

    Runnable that can fallback to other Runnable objects if it fails.

    Class

    RunnableWithMessageHistory

    Runnable that manages chat message history for another Runnable.

    Class

    VertexViewer

    VertexViewer class.

    Class

    AsciiCanvas

    Class for drawing in ASCII.

    Class

    PngDrawer

    Helper class to draw a state graph into a PNG file.

    Class

    RouterInput

    Router input.

    Class

    RouterRunnable

    Runnable that routes to a set of Runnable based on Input['key'].

    Class

    EmptyDict

    Empty dict type.

    Class

    RunnableConfig

    Configuration for a Runnable.

    Class

    ContextThreadPoolExecutor

    ThreadPoolExecutor that copies the context to the child thread.

    Class

    EventData

    Data associated with a streaming event.

    Class

    BaseStreamEvent

    Streaming event.

    Class

    StandardStreamEvent

    A standard stream event that follows LangChain convention for event data.

    Class

    CustomStreamEvent

    Custom stream event created by the user.

    Class

    Runnable

    A unit of work that can be invoked, batched, streamed, transformed and composed.

    Class

    RunnableSerializable

    Runnable that can be serialized to JSON.

    Class

    RunnableSequence

    Sequence of Runnable objects, where the output of one is the input of the next.

    Class

    RunnableParallel

    Runnable that runs a mapping of Runnables in parallel.

    Class

    RunnableGenerator

    Runnable that runs a generator function.

    Class

    RunnableLambda

    RunnableLambda converts a python callable into a Runnable.

    Class

    RunnableEachBase

    RunnableEachBase class.

    Class

    RunnableEach

    RunnableEach class.

    Class

    RunnableBindingBase

    Runnable that delegates calls to another Runnable with a set of **kwargs.

    Class

    RunnableBinding

    Wrap a Runnable with additional functionality.

    Class

    FakeEmbeddings

    Fake embedding model for unit testing purposes.

    Class

    DeterministicFakeEmbedding

    Deterministic fake embedding model for unit testing purposes.

    Class

    Embeddings

    Interface for embedding models.

    Class

    InMemoryDocumentIndex

    In memory document index.

    Class

    IndexingException

    Raised when an indexing operation fails.

    Class

    IndexingResult

    Return a detailed a breakdown of the result of the indexing operation.

    Class

    RecordManager

    Abstract base class representing the interface for a record manager.

    Class

    InMemoryRecordManager

    An in-memory record manager for testing purposes.

    Class

    UpsertResponse

    A generic response for upsert operations.

    Class

    DeleteResponse

    A generic response for delete operation.

    Class

    DocumentIndex

    A document retriever that supports indexing operations.

    Class

    BaseDocumentCompressor

    Base class for document compressors.

    Class

    BaseDocumentTransformer

    Abstract base class for document transformation.

    Class

    BaseMedia

    Base class for content used in retrieval and data processing workflows.

    Class

    Blob

    Raw data abstraction for document loading and file processing.

    Class

    Document

    Class for storing a piece of text and associated metadata.

    Class

    Reviver

    Reviver for JSON objects.

    Class

    BaseSerialized

    Base class for serialized objects.

    Class

    SerializedConstructor

    Serialized constructor.

    Class

    SerializedSecret

    Serialized secret.

    Class

    SerializedNotImplemented

    Serialized not implemented.

    Class

    Serializable

    Serializable base class.

    Class

    InputTokenDetails

    Breakdown of input token counts.

    Class

    OutputTokenDetails

    Breakdown of output token counts.

    Class

    UsageMetadata

    Usage metadata for a message, such as token counts.

    Class

    AIMessage

    Message from an AI.

    Class

    AIMessageChunk

    Message chunk from an AI (yielded when streaming).

    Class

    ToolOutputMixin

    Mixin for objects that tools can return directly.

    Class

    ToolMessage

    Message for passing the result of executing a tool back to a model.

    Class

    ToolMessageChunk

    Tool Message chunk.

    Class

    ToolCall

    Represents an AI's request to call a tool.

    Class

    ToolCallChunk

    A chunk of a tool call (yielded when streaming).

    Class

    FunctionMessage

    Message for passing the result of executing a tool back to a model.

    Class

    FunctionMessageChunk

    Function Message chunk.

    Class

    ChatMessage

    Message that can be assigned an arbitrary speaker (i.e. role).

    Class

    ChatMessageChunk

    Chat Message chunk.

    Class

    HumanMessage

    Message from the user.

    Class

    HumanMessageChunk

    Human Message chunk.

    Class

    RemoveMessage

    Message responsible for deleting other messages.

    Class

    Citation

    Annotation for citing data from a document.

    Class

    NonStandardAnnotation

    Provider-specific annotation format.

    Class

    TextContentBlock

    Text output from a LLM.

    Class

    ToolCall

    Represents an AI's request to call a tool.

    Class

    ToolCallChunk

    A chunk of a tool call (yielded when streaming).

    Class

    InvalidToolCall

    Allowance for errors made by LLM.

    Class

    ServerToolCall

    Tool call that is executed server-side.

    Class

    ServerToolCallChunk

    A chunk of a server-side tool call (yielded when streaming).

    Class

    ServerToolResult

    Result of a server-side tool call.

    Class

    ReasoningContentBlock

    Reasoning output from a LLM.

    Class

    ImageContentBlock

    Image data.

    Class

    VideoContentBlock

    Video data.

    Class

    AudioContentBlock

    Audio data.

    Class

    PlainTextContentBlock

    Plaintext data (e.g., from a .txt or .md document).

    Class

    FileContentBlock

    File data that doesn't fit into other multimodal block types.

    Class

    NonStandardContentBlock

    Provider-specific content data.

    Class

    SystemMessage

    Message for priming AI behavior.

    Class

    SystemMessageChunk

    System Message chunk.

    Class

    TextAccessor

    String-like object that supports both property and method access patterns.

    Class

    BaseMessage

    Base abstract message class.

    Class

    BaseMessageChunk

    Message chunk, which can be concatenated with other Message chunks.

    Class

    ListOutputParser

    Parse the output of a model to a list.

    Class

    CommaSeparatedListOutputParser

    Parse the output of a model to a comma-separated list.

    Class

    NumberedListOutputParser

    Parse a numbered list.

    Class

    MarkdownListOutputParser

    Parse a Markdown list.

    Class

    BaseTransformOutputParser

    Base class for an output parser that can handle streaming input.

    Class

    BaseCumulativeTransformOutputParser

    Base class for an output parser that can handle streaming input.

    Class

    StrOutputParser

    Extract text content from model outputs as a string.

    Class

    OutputFunctionsParser

    Parse an output that is one of sets of values.

    Class

    JsonOutputFunctionsParser

    Parse an output as the JSON object.

    Class

    JsonKeyOutputFunctionsParser

    Parse an output as the element of the JSON object.

    Class

    PydanticOutputFunctionsParser

    Parse an output as a Pydantic object.

    Class

    PydanticAttrOutputFunctionsParser

    Parse an output as an attribute of a Pydantic object.

    Class

    PydanticOutputParser

    Parse an output using a Pydantic model.

    Class

    JsonOutputToolsParser

    Parse tools from OpenAI response.

    Class

    JsonOutputKeyToolsParser

    Parse tools from OpenAI response.

    Class

    PydanticToolsParser

    Parse tools from OpenAI response.

    Class

    JsonOutputParser

    Parse the output of an LLM call to a JSON object.

    Class

    XMLOutputParser

    Parse an output using xml format.

    Class

    BaseLLMOutputParser

    Abstract base class for parsing the outputs of a model.

    Class

    BaseGenerationOutputParser

    Base class to parse the output of an LLM call.

    Class

    BaseOutputParser

    Base class to parse the output of an LLM call.

    Class

    Tool

    Tool that takes in function or coroutine directly.

    Class

    RetrieverInput

    Input to the retriever.

    Class

    StructuredTool

    Tool that can operate on any number of inputs.

    Class

    SchemaAnnotationError

    Raised when args_schema is missing or has an incorrect type annotation.

    Class

    ToolException

    Exception thrown when a tool execution error occurs.

    Class

    BaseTool

    Base class for all LangChain tools.

    Class

    InjectedToolArg

    Annotation for tool arguments that are injected at runtime.

    Class

    InjectedToolCallId

    Annotation for injecting the tool call ID.

    Class

    BaseToolkit

    Base class for toolkits containing related tools.

    Class

    RootListenersTracer

    Tracer that calls listeners on run start, end, and error.

    Class

    AsyncRootListenersTracer

    Async tracer that calls listeners on run start, end, and error.

    Class

    RunInfo

    Information about a run.

    Class

    RunCollectorCallbackHandler

    Tracer that collects all nested runs in a list.

    Class

    EvaluatorCallbackHandler

    Tracer that runs a run evaluator whenever a run is persisted.

    Class

    FunctionCallbackHandler

    Tracer that calls a function with a single str parameter.

    Class

    ConsoleCallbackHandler

    Tracer that prints to the console.

    Class

    LangChainTracer

    Implementation of the SharedTracer that POSTS to the LangChain endpoint.

    Class

    LogEntry

    A single entry in the run log.

    Class

    RunState

    State of the run.

    Class

    RunLogPatch

    Patch to the run log.

    Class

    RunLog

    Run log.

    Class

    LogStreamCallbackHandler

    Tracer that streams run logs to a stream.

    Class

    BaseTracer

    Base interface for tracers.

    Class

    AsyncBaseTracer

    Async base interface for tracers.

    Class

    LengthBasedExampleSelector

    Select examples based on length.

    Class

    SemanticSimilarityExampleSelector

    Select examples based on semantic similarity.

    Class

    MaxMarginalRelevanceExampleSelector

    Select examples based on Max Marginal Relevance.

    Class

    BaseExampleSelector

    Interface for selecting examples to include in prompts.

    Class

    DictPromptTemplate

    Template represented by a dictionary.

    Class

    MessagesPlaceholder

    Prompt template that assumes variable is already list of messages.

    Class

    BaseStringMessagePromptTemplate

    Base class for message prompt templates that use a string prompt template.

    Class

    ChatMessagePromptTemplate

    Chat message prompt template.

    Class

    HumanMessagePromptTemplate

    Human message prompt template.

    Class

    AIMessagePromptTemplate

    AI message prompt template.

    Class

    SystemMessagePromptTemplate

    System message prompt template.

    Class

    BaseChatPromptTemplate

    Base class for chat prompt templates.

    Class

    ChatPromptTemplate

    Prompt template for chat models.

    Class

    StructuredPrompt

    Structured prompt template for a language model.

    Class

    PromptTemplate

    Prompt template for a language model.

    Class

    StringPromptTemplate

    String prompt that exposes the format method, returning a prompt.

    Class

    FewShotPromptWithTemplates

    Prompt template that contains few shot examples.

    Class

    BaseMessagePromptTemplate

    Base class for message prompt templates.

    Class

    ImagePromptTemplate

    Image prompt template for a multimodal model.

    Class

    FewShotPromptTemplate

    Prompt template that contains few shot examples.

    Class

    FewShotChatMessagePromptTemplate

    Chat prompt template that supports few-shot examples.

    Class

    BasePromptTemplate

    Base class for all prompt templates, returning a prompt.

    Class

    StreamingStdOutCallbackHandler

    Callback handler for streaming.

    Class

    FileCallbackHandler

    Callback handler that writes to a file.

    Class

    StdOutCallbackHandler

    Callback handler that prints to std out.

    Class

    BaseRunManager

    Base class for run manager (a bound callback manager).

    Class

    RunManager

    Synchronous run manager.

    Class

    ParentRunManager

    Synchronous parent run manager.

    Class

    AsyncRunManager

    Async run manager.

    Class

    AsyncParentRunManager

    Async parent run manager.

    Class

    CallbackManagerForLLMRun

    Callback manager for LLM run.

    Class

    AsyncCallbackManagerForLLMRun

    Async callback manager for LLM run.

    Class

    CallbackManagerForChainRun

    Callback manager for chain run.

    Class

    AsyncCallbackManagerForChainRun

    Async callback manager for chain run.

    Class

    CallbackManagerForToolRun

    Callback manager for tool run.

    Class

    AsyncCallbackManagerForToolRun

    Async callback manager for tool run.

    Class

    CallbackManagerForRetrieverRun

    Callback manager for retriever run.

    Class

    AsyncCallbackManagerForRetrieverRun

    Async callback manager for retriever run.

    Class

    CallbackManager

    Callback manager for LangChain.

    Class

    CallbackManagerForChainGroup

    Callback manager for the chain group.

    Class

    AsyncCallbackManager

    Async callback manager that handles callbacks from LangChain.

    Class

    AsyncCallbackManagerForChainGroup

    Async callback manager for the chain group.

    Class

    UsageMetadataCallbackHandler

    Callback Handler that tracks AIMessage.usage_metadata.

    Class

    RetrieverManagerMixin

    Mixin for Retriever callbacks.

    Class

    LLMManagerMixin

    Mixin for LLM callbacks.

    Class

    ChainManagerMixin

    Mixin for chain callbacks.

    Class

    ToolManagerMixin

    Mixin for tool callbacks.

    Class

    CallbackManagerMixin

    Mixin for callback manager.

    Class

    RunManagerMixin

    Mixin for run manager.

    Class

    BaseCallbackHandler

    Base callback handler.

    Class

    AsyncCallbackHandler

    Base async callback handler.

    Class

    BaseCallbackManager

    Base callback manager.

    Class

    InMemoryVectorStore

    In-memory vector store implementation.

    Class

    VectorStore

    Interface for vector store.

    Class

    VectorStoreRetriever

    Base Retriever class for VectorStore.

    Class

    LangChainDeprecationWarning

    A class for issuing deprecation warnings for LangChain users.

    Class

    LangChainPendingDeprecationWarning

    A class for issuing deprecation warnings for LangChain users.

    Class

    LangChainBetaWarning

    A class for issuing beta warnings for LangChain users.

    Class

    FakeMessagesListChatModel

    Fake chat model for testing purposes.

    Class

    FakeListChatModelError

    Fake error for testing purposes.

    Class

    FakeListChatModel

    Fake chat model for testing purposes.

    Class

    FakeChatModel

    Fake Chat Model wrapper for testing purposes.

    Class

    GenericFakeChatModel

    Generic fake chat model that can be used to test the chat model interface.

    Class

    ParrotFakeChatModel

    Generic fake chat model that can be used to test the chat model interface.

    Class

    BaseLLM

    Base LLM abstract interface.

    Class

    LLM

    Simple interface for implementing a custom LLM.

    Class

    FakeListLLM

    Fake LLM for testing purposes.

    Class

    FakeListLLMError

    Fake error for testing purposes.

    Class

    FakeStreamingListLLM

    Fake streaming list LLM for testing purposes.

    Class

    ParsedDataUri

    Class

    BaseChatModel

    Base class for chat models.

    Class

    SimpleChatModel

    Simplified implementation for a chat model to inherit from.

    Class

    ModelProfile

    Model profile.

    Class

    LangSmithParams

    LangSmith parameters for tracing.

    Class

    BaseLanguageModel

    Abstract base class for interfacing with language models.

    Functions

    Function

    print_sys_info

    Print information about the environment for debugging purposes.

    Function

    get_runtime_environment

    Get information about the LangChain runtime environment.

    Function

    create_message

    Create a message with a link to the LangChain troubleshooting guide.

    Function

    set_verbose

    Set a new value for the verbose global setting.

    Function

    get_verbose

    Get the value of the verbose global setting.

    Function

    set_debug

    Set a new value for the debug global setting.

    Function

    get_debug

    Get the value of the debug global setting.

    Function

    set_llm_cache

    Set a new LLM cache, overwriting the previous value, if any.

    Function

    get_llm_cache

    Get the value of the llm_cache global setting.

    Function

    import_attr

    Import an attribute from a module located in a package.

    Function

    merge_chat_generation_chunks

    Merge a list of ChatGenerationChunks into a single ChatGenerationChunk.

    Function

    xor_args

    Validate specified keyword args are mutually exclusive.

    Function

    raise_for_status_with_text

    Raise an error with the response text.

    Function

    mock_now

    Context manager for mocking out datetime.now() in unit tests.

    Function

    guard_import

    Dynamically import a module.

    Function

    check_package_version

    Check the version of a package.

    Function

    get_pydantic_field_names

    Get field names, including aliases, for a pydantic class.

    Function

    build_extra_kwargs

    Build extra kwargs from values and extra_kwargs.

    Function

    convert_to_secret_str

    Convert a string to a SecretStr if needed.

    Function

    from_env

    Create a factory method that gets a value from an environment variable.

    Function

    secret_from_env

    Secret from env.

    Function

    ensure_id

    Ensure the ID is a valid string, generating a new UUID if not provided.

    Function

    env_var_is_set

    Check if an environment variable is set.

    Function

    get_from_dict_or_env

    Get a value from a dictionary or an environment variable.

    Function

    get_from_env

    Get a value from a dictionary or an environment variable.

    Function

    merge_dicts

    Merge dictionaries.

    Function

    merge_lists

    Add many lists, handling None.

    Function

    merge_obj

    Merge two objects.

    Function

    dereference_refs

    Resolve and inline JSON Schema $ref references in a schema object.

    Function

    tee_peer

    An individual iterator of a tee.

    Function

    abatch_iterate

    Utility batching function for async iterables.

    Function

    convert_to_openai_function

    Convert a raw function/class to an OpenAI function.

    Function

    convert_to_openai_tool

    Convert a tool-like object to an OpenAI tool schema.

    Function

    convert_to_json_schema

    Convert a schema representation to a JSON schema.

    Function

    tool_example_to_messages

    Convert an example into a list of messages that can be fed into an LLM.

    Function

    is_interactive_env

    Determine if running within IPython or Jupyter.

    Function

    stringify_value

    Stringify a value.

    Function

    stringify_dict

    Stringify a dictionary.

    Function

    comma_list

    Convert an iterable to a comma-separated string.

    Function

    sanitize_for_postgres

    Sanitize text by removing NUL bytes that are incompatible with PostgreSQL.

    Function

    is_pydantic_v1_subclass

    Check if the given class is Pydantic v1-like.

    Function

    is_pydantic_v2_subclass

    Check if the given class is Pydantic v2-like.

    Function

    is_basemodel_subclass

    Check if the given class is a subclass of Pydantic BaseModel.

    Function

    is_basemodel_instance

    Check if the given class is an instance of Pydantic BaseModel.

    Function

    pre_init

    Decorator to run a function before model initialization.

    Function

    get_fields

    Return the field names of a Pydantic model.

    Function

    create_model

    Create a Pydantic model with the given field definitions.

    Function

    create_model_v2

    Create a Pydantic model with the given field definitions.

    Function

    parse_partial_json

    Parse a JSON string that may be missing closing braces.

    Function

    parse_json_markdown

    Parse a JSON string from a Markdown string.

    Function

    parse_and_check_json_markdown

    Parse and check a JSON string from a Markdown string.

    Function

    get_color_mapping

    Get mapping for items to a support color.

    Function

    get_colored_text

    Get colored text.

    Function

    get_bolded_text

    Get bolded text.

    Function

    print_text

    Print text with highlighting and no end characters.

    Function

    tee_peer

    An individual iterator of a .tee.

    Function

    batch_iterate

    Utility batching function.

    Function

    find_all_links

    Extract all links from a raw HTML string.

    Function

    extract_sub_links

    Extract all links from a raw HTML string and convert into absolute paths.

    Function

    grab_literal

    Parse a literal from the template.

    Function

    l_sa_check

    Do a preliminary check to see if a tag could be a standalone.

    Function

    r_sa_check

    Do a final check to see if a tag could be a standalone.

    Function

    parse_tag

    Parse a tag from a template.

    Function

    tokenize

    Tokenize a mustache template.

    Function

    render

    Render a mustache template.

    Function

    uuid7

    Generate a UUID from a Unix timestamp in nanoseconds and random bits.

    Function

    is_uuid

    Check if a string is a valid UUID.

    Function

    node_data_str

    Convert the data of a node to a string.

    Function

    node_data_json

    Convert the data of a node to a JSON-serializable format.

    Function

    identity

    Identity function.

    Function

    aidentity

    Async identity function.

    Function

    prefix_config_spec

    Prefix the id of a ConfigurableFieldSpec.

    Function

    make_options_spec

    Make options spec.

    Function

    gated_coro

    Run a coroutine with a semaphore.

    Function

    gather_with_concurrency

    Gather coroutines with a limit on the number of concurrent coroutines.

    Function

    accepts_run_manager

    Check if a callable accepts a run_manager argument.

    Function

    accepts_config

    Check if a callable accepts a config argument.

    Function

    accepts_context

    Check if a callable accepts a context argument.

    Function

    asyncio_accepts_context

    Check if asyncio.create_task accepts a context arg.

    Function

    coro_with_context

    Await a coroutine with a context.

    Function

    get_function_first_arg_dict_keys

    Get the keys of the first argument of a function if it is a dict.

    Function

    get_lambda_source

    Get the source code of a lambda function.

    Function

    get_function_nonlocals

    Get the nonlocal variables accessed by a function.

    Function

    indent_lines_after_first

    Indent all lines of text after the first line.

    Function

    add

    Add a sequence of addable objects together.

    Function

    aadd

    Asynchronously add a sequence of addable objects together.

    Function

    get_unique_config_specs

    Get the unique config specs from a sequence of config specs.

    Function

    is_async_generator

    Check if a function is an async generator.

    Function

    is_async_callable

    Check if a function is async.

    Function

    draw_mermaid

    Draws a Mermaid graph using the provided graph data.

    Function

    draw_mermaid_png

    Draws a Mermaid graph as PNG using provided syntax.

    Function

    draw_ascii

    Build a DAG and draw it in ASCII.

    Function

    set_config_context

    Set the child Runnable config + tracing context.

    Function

    ensure_config

    Ensure that a config is a dict with all keys present.

    Function

    get_config_list

    Get a list of configs from a single config or a list of configs.

    Function

    patch_config

    Patch a config with new values.

    Function

    merge_configs

    Merge multiple configs into one.

    Function

    call_func_with_variable_args

    Call function that may optionally accept a run_manager and/or config.

    Function

    acall_func_with_variable_args

    Async call function that may optionally accept a run_manager and/or config.

    Function

    get_callback_manager_for_config

    Get a callback manager for a config.

    Function

    get_async_callback_manager_for_config

    Get an async callback manager for a config.

    Function

    get_executor_for_config

    Get an executor for a config.

    Function

    run_in_executor

    Run a function in an executor.

    Function

    coerce_to_runnable

    Coerce a Runnable-like object into a Runnable.

    Function

    chain

    Decorate a function to make it a Runnable.

    Function

    index

    Index data from the loader into the vector store.

    Function

    aindex

    Async index data from the loader into the vector store.

    Function

    default_init_validator

    Default init validator that blocks jinja2 templates.

    Function

    loads

    Revive a LangChain class from a JSON string.

    Function

    load

    Revive a LangChain class from a JSON object.

    Function

    default

    Return a default value for an object.

    Function

    dumps

    Return a JSON string representation of an object.

    Function

    dumpd

    Return a dict representation of an object.

    Function

    try_neq_default

    Try to determine if a value is different from the default.

    Function

    to_json_not_implemented

    Serialize a "not implemented" object.

    Function

    add_ai_message_chunks

    Add multiple AIMessageChunks together.

    Function

    add_usage

    Recursively add two UsageMetadata objects.

    Function

    subtract_usage

    Recursively subtract two UsageMetadata objects.

    Function

    get_buffer_string

    Convert a sequence of messages to strings and concatenate them into one string.

    Function

    messages_from_dict

    Convert a sequence of messages from dicts to Message objects.

    Function

    message_chunk_to_message

    Convert a message chunk to a Message.

    Function

    convert_to_messages

    Convert a sequence of messages to a list of messages.

    Function

    filter_messages

    Filter messages based on name, type or id.

    Function

    merge_message_runs

    Merge consecutive Messages of the same type.

    Function

    trim_messages

    Trim messages to be below a token count.

    Function

    convert_to_openai_messages

    Convert LangChain messages into OpenAI message dicts.

    Function

    count_tokens_approximately

    Approximate the total number of tokens in messages.

    Function

    tool_call

    Create a tool call.

    Function

    tool_call_chunk

    Create a tool call chunk.

    Function

    invalid_tool_call

    Create an invalid tool call.

    Function

    default_tool_parser

    Best-effort parsing of tools.

    Function

    default_tool_chunk_parser

    Best-effort parsing of tool chunks.

    Function

    is_data_content_block

    Check if the provided content block is a data content block.

    Function

    create_text_block

    Create a TextContentBlock.

    Function

    create_image_block

    Create an ImageContentBlock.

    Function

    create_video_block

    Create a VideoContentBlock.

    Function

    create_audio_block

    Create an AudioContentBlock.

    Function

    create_file_block

    Create a FileContentBlock.

    Function

    create_plaintext_block

    Create a PlainTextContentBlock.

    Function

    create_tool_call

    Create a ToolCall.

    Function

    create_reasoning_block

    Create a ReasoningContentBlock.

    Function

    create_citation

    Create a Citation.

    Function

    create_non_standard_block

    Create a NonStandardContentBlock.

    Function

    merge_content

    Merge multiple message contents.

    Function

    message_to_dict

    Convert a Message to a dictionary.

    Function

    messages_to_dict

    Convert a sequence of Messages to a list of dictionaries.

    Function

    get_msg_title_repr

    Get a title representation for a message.

    Function

    register_translator

    Register content translators for a provider in PROVIDER_TRANSLATORS.

    Function

    get_translator

    Get the translator functions for a provider.

    Function

    convert_to_openai_image_block

    Convert ImageContentBlock to format expected by OpenAI Chat Completions.

    Function

    convert_to_openai_data_block

    Format standard data content block to format expected by OpenAI.

    Function

    translate_content

    Derive standard content blocks from a message with OpenAI content.

    Function

    translate_content_chunk

    Derive standard content blocks from a message chunk with OpenAI content.

    Function

    translate_grounding_metadata_to_citations

    Translate Google AI grounding metadata to LangChain Citations.

    Function

    translate_content

    Derive standard content blocks from a message with Google (GenAI) content.

    Function

    translate_content_chunk

    Derive standard content blocks from a chunk with Google (GenAI) content.

    Function

    translate_content

    Derive standard content blocks from a message with Bedrock Converse content.

    Function

    translate_content_chunk

    Derive standard content blocks from a chunk with Bedrock Converse content.

    Function

    translate_content

    Derive standard content blocks from a message with Bedrock content.

    Function

    translate_content_chunk

    Derive standard content blocks from a message chunk with Bedrock content.

    Function

    translate_content

    Derive standard content blocks from a message with groq content.

    Function

    translate_content_chunk

    Derive standard content blocks from a message chunk with groq content.

    Function

    translate_content

    Derive standard content blocks from a message with Anthropic content.

    Function

    translate_content_chunk

    Derive standard content blocks from a message chunk with Anthropic content.

    Function

    droplastn

    Drop the last n elements of an iterator.

    Function

    parse_tool_call

    Parse a single tool call.

    Function

    make_invalid_tool_call

    Create an InvalidToolCall from a raw tool call.

    Function

    parse_tool_calls

    Parse a list of tool calls.

    Function

    nested_element

    Get nested element from path.

    Function

    tool

    Convert Python functions and Runnables to LangChain tools.

    Function

    convert_runnable_to_tool

    Convert a Runnable into a BaseTool.

    Function

    create_retriever_tool

    Create a tool to do retrieval of documents.

    Function

    render_text_description

    Render the tool name and description in plain text.

    Function

    render_text_description_and_args

    Render the tool name, description, and args in plain text.

    Function

    create_schema_from_function

    Create a Pydantic schema from a function's signature.

    Function

    get_all_basemodel_annotations

    Get all annotations from a Pydantic BaseModel and its parents.

    Function

    is_private_ip

    Check if an IP address is in a private range.

    Function

    is_cloud_metadata

    Check if hostname or IP is a cloud metadata endpoint.

    Function

    is_localhost

    Check if hostname or IP is localhost.

    Function

    validate_safe_url

    Validate a URL for SSRF protection.

    Function

    is_safe_url

    Check if a URL is safe (non-throwing version of validate_safe_url).

    Function

    tracing_v2_enabled

    Instruct LangChain to log all runs in context to LangSmith.

    Function

    collect_runs

    Collect all run traces in context.

    Function

    register_configure_hook

    Register a configure hook.

    Function

    wait_for_all_evaluators

    Wait for all tracers to finish.

    Function

    try_json_stringify

    Try to stringify an object to JSON.

    Function

    elapsed

    Get the elapsed time of a run.

    Function

    log_error_once

    Log an error once.

    Function

    wait_for_all_tracers

    Wait for all tracers to finish.

    Function

    get_client

    Get the client.

    Function

    run_to_dict

    Convert run to dict, compatible with both Pydantic v1 and v2.

    Function

    run_copy

    Copy run, compatible with both Pydantic v1 and v2.

    Function

    run_construct

    Construct run without validation, compatible with both Pydantic v1 and v2.

    Function

    pydantic_to_dict

    Convert any Pydantic model to dict, compatible with both v1 and v2.

    Function

    pydantic_copy

    Copy any Pydantic model, compatible with both v1 and v2.

    Function

    sorted_values

    Return a list of values in dict sorted by key.

    Function

    load_prompt_from_config

    Load prompt from config dict.

    Function

    load_prompt

    Unified method for loading a prompt from LangChainHub or local filesystem.

    Function

    jinja2_formatter

    Format a template using jinja2.

    Function

    validate_jinja2

    Validate that the input variables are valid for the template.

    Function

    mustache_formatter

    Format a template using mustache.

    Function

    mustache_template_vars

    Get the top-level variables from a mustache template.

    Function

    mustache_schema

    Get the variables from a mustache template.

    Function

    check_valid_template

    Check that template string is valid.

    Function

    get_template_variables

    Get the variables from the template.

    Function

    is_subsequence

    Return True if child is subsequence of parent.

    Function

    format_document

    Format a document into a string based on a prompt template.

    Function

    aformat_document

    Async format a document into a string based on a prompt template.

    Function

    trace_as_chain_group

    Get a callback manager for a chain group in a context manager.

    Function

    atrace_as_chain_group

    Get an async callback manager for a chain group in a context manager.

    Function

    shielded

    Makes so an awaitable method is always shielded from cancellation.

    Function

    handle_event

    Generic event handler for CallbackManager.

    Function

    ahandle_event

    Async generic event handler for AsyncCallbackManager.

    Function

    adispatch_custom_event

    Dispatch an adhoc event to the handlers.

    Function

    dispatch_custom_event

    Dispatch an adhoc event.

    Function

    get_usage_metadata_callback

    Get usage metadata callback.

    Function

    maximal_marginal_relevance

    Calculate maximal marginal relevance.

    Function

    deprecated

    Decorator to mark a function, a class, or a property as deprecated.

    Function

    suppress_langchain_deprecation_warning

    Context manager to suppress LangChainDeprecationWarning.

    Function

    warn_deprecated

    Display a standardized deprecation.

    Function

    surface_langchain_deprecation_warnings

    Unmute LangChain deprecation warnings.

    Function

    rename_parameter

    Decorator indicating that parameter old of func is renamed to new.

    Function

    beta

    Decorator to mark a function, a class, or a property as beta.

    Function

    suppress_langchain_beta_warning

    Context manager to suppress LangChainDeprecationWarning.

    Function

    warn_beta

    Display a standardized beta annotation.

    Function

    surface_langchain_beta_warnings

    Unmute LangChain beta warnings.

    Function

    is_caller_internal

    Return whether the caller at depth of this function is internal.

    Function

    get_relative_path

    Get the path of the file as a relative path to the package directory.

    Function

    as_import_path

    Path of the file as a LangChain import exclude langchain top namespace.

    Function

    create_base_retry_decorator

    Create a retry decorator for a given LLM and provided a list of error types.

    Function

    get_prompts

    Get prompts that are already cached.

    Function

    aget_prompts

    Get prompts that are already cached. Async version.

    Function

    update_cache

    Update the cache and get the LLM output.

    Function

    aupdate_cache

    Update the cache and get the LLM output. Async version.

    Function

    is_openai_data_block

    Check whether a block contains multimodal data in OpenAI Chat Completions format.

    Function

    generate_from_stream

    Generate from a stream.

    Function

    agenerate_from_stream

    Async generate from a stream.

    Function

    get_tokenizer

    Get a GPT-2 tokenizer instance.

    Function

    py_anext

    deprecated

    Pure-Python implementation of anext() for testing purposes.

    Function

    get_pydantic_major_version

    deprecated

    DEPRECATED - Get the major version of Pydantic.

    Modules

    Module

    langchain_core

    langchain-core defines the base abstractions for the LangChain ecosystem.

    Module

    sys_info

    Print information about the system and langchain packages for debugging purposes.

    Module

    structured_query

    Internal representation of a structured query language.

    Module

    rate_limiters

    Interface for a rate limiter and an in-memory rate limiter.

    Module

    prompt_values

    Prompt values for language model prompts.

    Module

    version

    langchain-core version information and utilities.

    Module

    env

    Utilities for getting information about the runtime environment.

    Module

    chat_sessions

    Chat Sessions are a collection of messages and function calls.

    Module

    agents

    Schema definitions for representing agent actions, observations, and return values.

    Module

    exceptions

    Custom exceptions for LangChain.

    Module

    caches

    Optional caching layer for language models.

    Module

    chat_history

    Chat message history stores a history of the message interactions in a chat.

    Module

    retrievers

    Retriever class returns Document objects given a text query.

    Module

    globals

    Global values and configuration that apply to all of LangChain.

    Module

    chat_loaders

    Chat loaders.

    Module

    stores

    Store implements the key-value stores and storage helpers.

    Module

    document_loaders

    Document loaders.

    Module

    langsmith

    LangSmith document loader.

    Module

    blob_loaders

    Schema for Blobs and Blob Loaders.

    Module

    base

    Abstract interface for document loader implementations.

    Module

    outputs

    Output classes.

    Module

    generation

    Generation output schema.

    Module

    llm_result

    LLMResult class.

    Module

    run_info

    RunInfo class.

    Module

    chat_generation

    Chat generation output classes.

    Module

    chat_result

    Chat result schema.

    Module

    utils

    Utility functions for LangChain.

    Module

    formatting

    Utilities for formatting strings.

    Module

    utils

    Generic utility functions.

    Module

    env

    Utilities for environment variables.

    Module

    json_schema

    Utilities for JSON Schema.

    Module

    aiter

    Asynchronous iterator utilities.

    Module

    function_calling

    Methods for creating function specs in the style of OpenAI Functions.

    Module

    interactive_env

    Utilities for working with interactive environments.

    Module

    strings

    String utilities.

    Module

    pydantic

    Utilities for pydantic.

    Module

    json

    Utilities for JSON.

    Module

    image

    Utilities for image processing.

    Module

    input

    Handle chained inputs.

    Module

    usage

    Usage utilities.

    Module

    iter

    Utilities for working with iterators.

    Module

    html

    Utilities for working with HTML.

    Module

    mustache

    Adapted from https://github.com/noahmorrison/chevron.

    Module

    uuid

    UUID utility functions.

    Module

    runnables

    LangChain Runnable and the LangChain Expression Language (LCEL).

    Module

    graph

    Graph used in Runnable objects.

    Module

    retry

    Runnable that retries a Runnable if it fails.

    Module

    passthrough

    Implementation of the RunnablePassthrough.

    Module

    configurable

    Runnable objects that can be dynamically configured.

    Module

    utils

    Utility code for Runnable objects.

    Module

    branch

    Runnable that selects which branch to run based on a condition.

    Module

    fallbacks

    Runnable that can fallback to other Runnable objects if it fails.

    Module

    history

    Runnable that manages chat message history for another Runnable.

    Module

    graph_mermaid

    Mermaid graph drawing utilities.

    Module

    graph_ascii

    Draws DAG in ASCII.

    Module

    graph_png

    Helper class to draw a state graph into a PNG file.

    Module

    router

    Runnable that routes to a set of Runnable objects.

    Module

    config

    Configuration utilities for Runnable objects.

    Module

    schema

    Module contains typedefs that are used with Runnable objects.

    Module

    base

    Base classes and utilities for Runnable objects.

    Module

    embeddings

    Embeddings.

    Module

    fake

    Module contains a few fake embedding models for testing purposes.

    Module

    embeddings

    Embeddings interface.

    Module

    indexing

    Code to help indexing data into a vectorstore.

    Module

    in_memory

    In memory document index.

    Module

    api

    Module contains logic for indexing documents into vector stores.

    Module

    base

    Base classes for indexing.

    Module

    documents

    Documents module for data retrieval and processing workflows.

    Module

    compressor

    Document compressor.

    Module

    transformers

    Document transformers.

    Module

    base

    Base classes for media and documents.

    Module

    load

    Load module helps with serialization and deserialization.

    Module

    load

    Load LangChain objects from JSON strings or objects.

    Module

    mapping

    Serialization mapping.

    Module

    dump

    Serialize LangChain objects to JSON.

    Module

    serializable

    Serializable base class.

    Module

    messages

    Messages are objects used in prompts and chat conversations.

    Module

    ai

    AI message.

    Module

    utils

    Module contains utility functions for working with messages.

    Module

    tool

    Messages for tools.

    Module

    function

    Function Message.

    Module

    chat

    Chat Message.

    Module

    human

    Human message.

    Module

    modifier

    Message responsible for deleting other messages.

    Module

    content

    Standard, multimodal content blocks for Large Language Model I/O.

    Module

    system

    System message.

    Module

    base

    Base message.

    Module

    block_translators

    Derivations of standard content blocks from provider content.

    Module

    google_vertexai

    Derivations of standard content blocks from Google (VertexAI) content.

    Module

    openai

    Derivations of standard content blocks from OpenAI content.

    Module

    google_genai

    Derivations of standard content blocks from Google (GenAI) content.

    Module

    bedrock_converse

    Derivations of standard content blocks from Amazon (Bedrock Converse) content.

    Module

    bedrock

    Derivations of standard content blocks from Bedrock content.

    Module

    groq

    Derivations of standard content blocks from Groq content.

    Module

    anthropic

    Derivations of standard content blocks from Anthropic content.

    Module

    langchain_v0

    Derivations of standard content blocks from LangChain v0 multimodal content.

    Module

    output_parsers

    OutputParser classes parse the output of an LLM call into structured data.

    Module

    list

    Parsers for list output.

    Module

    transform

    Base classes for output parsers that can handle streaming input.

    Module

    format_instructions

    Format instructions.

    Module

    string

    String output parser.

    Module

    openai_functions

    Parsers for OpenAI functions output.

    Module

    pydantic

    Output parsers using Pydantic.

    Module

    openai_tools

    Parse tools for OpenAI tools output.

    Module

    json

    Parser for JSON output.

    Module

    xml

    Output parser for XML format.

    Module

    base

    Base parser for language model outputs.

    Module

    tools

    Tools are classes that an Agent uses to interact with the world.

    Module

    simple

    Tool that takes in function or coroutine directly.

    Module

    convert

    Convert functions and runnables to tools.

    Module

    retriever

    Retriever tool.

    Module

    structured

    Structured tool.

    Module

    render

    Utilities to render tools.

    Module

    base

    Base classes and utilities for LangChain tools.

    Module

    tracers

    Tracers are classes for tracing runs.

    Module

    context

    Context management for tracers.

    Module

    memory_stream

    Module implements a memory stream for communication between two co-routines.

    Module

    root_listeners

    Tracers that call listeners.

    Module

    event_stream

    Internal tracer to power the event stream API.

    Module

    run_collector

    A tracer that collects all nested runs in a list.

    Module

    evaluation

    A tracer that runs evaluators over completed runs.

    Module

    stdout

    Tracers that print to the console.

    Module

    langchain

    A tracer implementation that records to LangChain endpoint.

    Module

    schemas

    Schemas for tracers.

    Module

    core

    Utilities for the root listener.

    Module

    log_stream

    Tracer that streams run logs to a stream.

    Module

    base

    Base interfaces for tracing runs.

    Module

    example_selectors

    Example selectors.

    Module

    length_based

    Select examples based on length.

    Module

    semantic_similarity

    Example selector that selects examples based on SemanticSimilarity.

    Module

    base

    Interface for selecting examples to include in prompts.

    Module

    prompts

    A prompt is the input to the model.

    Module

    dict

    Dictionary prompt template.

    Module

    loading

    Load prompts.

    Module

    chat

    Chat prompt template.

    Module

    structured

    Structured prompt template for a language model.

    Module

    prompt

    Prompt schema definition.

    Module

    string

    BasePrompt schema definition.

    Module

    few_shot_with_templates

    Prompt template that contains few shot examples.

    Module

    message

    Message prompt templates.

    Module

    image

    Image prompt template for a multimodal model.

    Module

    few_shot

    Prompt template that contains few shot examples.

    Module

    base

    Base class for prompt templates.

    Module

    callbacks

    Callback handlers allow listening to events in LangChain.

    Module

    streaming_stdout

    Callback Handler streams to stdout on new llm token.

    Module

    file

    Callback handler that writes to a file.

    Module

    stdout

    Callback handler that prints to std out.

    Module

    manager

    Run managers.

    Module

    usage

    Callback Handler that tracks AIMessage.usage_metadata.

    Module

    base

    Base callback handler for LangChain.

    Module

    vectorstores

    Vector stores.

    Module

    in_memory

    In-memory vector store.

    Module

    utils

    Internal utilities for the in memory implementation of VectorStore.

    Module

    base

    A vector store stores embedded data and performs vector search.

    Module

    deprecation

    Helper functions for deprecating parts of the LangChain API.

    Module

    beta_decorator

    Helper functions for marking parts of the LangChain API as beta.

    Module

    internal

    Module

    path

    Module

    language_models

    Core language model abstractions.

    Module

    fake_chat_models

    Fake chat models for testing purposes.

    Module

    llms

    Base interface for traditional large language models (LLMs) to expose.

    Module

    fake

    Fake LLMs for testing purposes.

    Module

    chat_models

    Chat models for conversational AI.

    Module

    model_profile

    Model profile types and utilities.

    Module

    base

    Base language models class.

    Types

    Type

    Scopes

    Type

    AnyConfigurableField

    Type

    MessagesOrDictWithMessages

    Type

    StreamEvent

    Type

    RunnableLike

    Type

    PathLike

    Type

    MessageLikeRepresentation

    A type representing the various ways a message can be represented.

    Type

    Annotation

    A union of all defined Annotation types.

    Type

    DataContentBlock

    A union of all defined multimodal data ContentBlock types.

    Type

    ToolContentBlock

    Type

    ContentBlock

    A union of all defined ContentBlock types and aliases.

    Type

    PydanticBaseModel

    Type

    ArgsSchema

    Type

    Listener

    Type

    AsyncListener

    Type

    MessageLike

    Type

    MessageLikeRepresentation

    Type

    Callbacks

    Type

    Matrix

    Type

    LanguageModelInput

    Input to a language model.

    Type

    LanguageModelOutput

    Output from a language model.