LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph.storebase
    Module●Since v1.0

    base

    Base classes and types for persistent key-value stores.

    Stores provide long-term memory that persists across threads and conversations. Supports hierarchical namespaces, key-value storage, and optional vector search.

    Core types:

    • BaseStore: Store interface with sync/async operations
    • Item: Stored key-value pairs with metadata
    • Op: Get/Put/Search/List operations

    Attributes

    attribute
    AEmbeddingsFunc: Callable[[Sequence[str]], Awaitable[list[list[float]]]]
    attribute
    EmbeddingsFunc: Callable[[Sequence[str]], list[list[float]]]
    attribute
    NOT_PROVIDED
    attribute
    NamespacePath: tuple[str | Literal['*'], ...]
    attribute
    NamespaceMatchType: Literal['prefix', 'suffix']

    Functions

    function
    ensure_embeddings
    function
    get_text_at_path
    function
    tokenize_path

    Classes

    Type Aliases

    Modules

    View source on GitHub
    class
    NotProvided
    class
    Item
    class
    SearchItem
    class
    GetOp
    class
    SearchOp
    class
    MatchCondition
    class
    ListNamespacesOp
    class
    PutOp
    class
    InvalidNamespaceError
    class
    TTLConfig
    class
    IndexConfig
    class
    BaseStore
    typeAlias
    Op
    typeAlias
    Result
    module
    batch
    module
    embed

    Type for asynchronous embedding functions.

    Similar to EmbeddingsFunc, but returns an awaitable that resolves to the embeddings.

    Type for synchronous embedding functions.

    The function should take a sequence of strings and return a list of embeddings, where each embedding is a list of floats. The dimensionality of the embeddings should be consistent for all inputs.

    Specifies how to match namespace paths.

    Ensure that an embedding function conforms to LangChain's Embeddings interface.

    This function wraps arbitrary embedding functions to make them compatible with LangChain's Embeddings interface. It handles both synchronous and asynchronous functions.

    Extract text from an object using a path expression or pre-tokenized path.

    Tokenize a path into components.

    Types handled
    • Simple paths: "field1.field2"
    • Array indexing: "[0]", "[*]", "[-1]"
    • Wildcards: "*"
    • Multi-field selection: "{field1,field2}"

    A tuple representing a namespace path that can include wildcards.

    Examples
    ("users",)  # Exact users namespace
    ("documents", "*")  # Any sub-namespace under documents
    ("cache", "*", "v1")  # Any cache category with v1 version

    Sentinel singleton.

    Represents a stored item with metadata.

    Represents an item returned from a search operation with additional metadata.

    Operation to store, update, or delete an item in the store.

    This class represents a single operation to modify the store's contents, whether adding new items, updating existing ones, or removing them.

    Provided namespace is invalid.

    Configuration for TTL (time-to-live) behavior in the store.

    Configuration for indexing documents for semantic search in the store.

    If not provided to the store, the store will not support vector search. In that case, all index arguments to put() and aput() operations will be ignored.

    Abstract base class for persistent key-value stores.

    Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces. Some implementations may support semantic search capabilities through an optional index configuration.

    Utilities for batching operations in a background task.

    Utilities for working with embedding functions and LangChain's Embeddings interface.

    This module provides tools to wrap arbitrary embedding functions (both sync and async) into LangChain's Embeddings interface. This enables using custom embedding functions with LangChain-compatible tools while maintaining support for both synchronous and asynchronous operations.

    Operation to retrieve a specific item by its namespace and key.

    This operation allows precise retrieval of stored items using their full path (namespace) and unique identifier (key) combination.

    Examples

    Basic item retrieval:

    GetOp(namespace=("users", "profiles"), key="user123")
    GetOp(namespace=("cache", "embeddings"), key="doc456")

    Operation to search for items within a specified namespace hierarchy.

    This operation supports both structured filtering and natural language search within a given namespace prefix. It provides pagination through limit and offset parameters.

    Note

    Natural language search support depends on your store implementation.

    Examples

    Search with filters and pagination:

    SearchOp(
        namespace_prefix=("documents",),
        filter={"type": "report", "status": "active"},
        limit=5,
        offset=10
    )

    Natural language search:

    SearchOp(
        namespace_prefix=("users", "content"),
        query="technical documentation about APIs",
        limit=20
    )

    Represents a pattern for matching namespaces in the store.

    This class combines a match type (prefix or suffix) with a namespace path pattern that can include wildcards to flexibly match different namespace hierarchies.

    Examples

    Prefix matching:

    MatchCondition(match_type="prefix", path=("users", "profiles"))

    Suffix matching with wildcard:

    MatchCondition(match_type="suffix", path=("cache", "*"))

    Simple suffix matching:

    MatchCondition(match_type="suffix", path=("v1",))

    Operation to list and filter namespaces in the store.

    This operation allows exploring the organization of data, finding specific collections, and navigating the namespace hierarchy.

    Examples

    List all namespaces under the "documents" path:

    ListNamespacesOp(
        match_conditions=(MatchCondition(match_type="prefix", path=("documents",)),),
        max_depth=2
    )

    List all namespaces that end with "v1":

    ListNamespacesOp(
        match_conditions=(MatchCondition(match_type="suffix", path=("v1",)),),
        limit=50
    )