Class AlloyDBSaver (0.17.0)

AlloyDBSaver(
    key: object,
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    checkpoint: langchain_google_alloydb_pg.async_checkpoint.AsyncAlloyDBSaver,
    serde: typing.Optional[langgraph.checkpoint.serde.base.SerializerProtocol] = None,
)

Checkpoint stored in an AlloyDB for PostgreSQL database.

Methods

aget_tuple

aget_tuple(
    config: langchain_core.runnables.config.RunnableConfig,
) -> typing.Optional[langgraph.checkpoint.base.CheckpointTuple]

Asynchronously fetch a checkpoint tuple using the given configuration.

Parameter
Name Description
config RunnableConfig

The config to use for retrieving the checkpoint.

Returns
Type Description
Optional[CheckpointTuple] The retrieved checkpoint tuple, or None if no matching checkpoint was found.

alist

alist(
    config: typing.Optional[langchain_core.runnables.config.RunnableConfig],
    filter: typing.Optional[dict[str, typing.Any]] = None,
    before: typing.Optional[langchain_core.runnables.config.RunnableConfig] = None,
    limit: typing.Optional[int] = None,
) -> typing.AsyncIterator[langgraph.checkpoint.base.CheckpointTuple]

Asynchronously list checkpoints that match the given criteria

Parameters
Name Description
config Optional[RunnableConfig]

Base configuration for filtering checkpoints.

filter Optional[Dict[str, Any]]

Additional filtering criteria for metadata.

before Optional[RunnableConfig]

List checkpoints created before this configuration.

limit Optional[int]

Maximum number of checkpoints to return.

Returns
Type Description
AsyncIterator[CheckpointTuple] Async iterator of matching checkpoint tuples.

aput

aput(
    config: langchain_core.runnables.config.RunnableConfig,
    checkpoint: langgraph.checkpoint.base.Checkpoint,
    metadata: langgraph.checkpoint.base.CheckpointMetadata,
    new_versions: dict[str, str | int | float],
) -> langchain_core.runnables.config.RunnableConfig

Asynchronously store a checkpoint with its configuration and metadata.

Parameters
Name Description
config RunnableConfig

The config to associate with the checkpoint.

checkpoint Checkpoint

The checkpoint to save.

metadata CheckpointMetadata

Additional metadata to save with the checkpoint.

new_versions ChannelVersions

New channel versions as of this write.

Returns
Type Description
RunnableConfig Updated configuration after storing the checkpoint.

aput_writes

aput_writes(
    config: langchain_core.runnables.config.RunnableConfig,
    writes: typing.Sequence[typing.Tuple[str, typing.Any]],
    task_id: str,
    task_path: str = "",
) -> None

Asynchronously store intermediate writes linked to a checkpoint.

Parameters
Name Description
config RunnableConfig

Configuration of the related checkpoint.

writes List[Tuple[str, Any]]

List of writes to store.

task_id str

Identifier for the task creating the writes.

task_path str

Path of the task creating the writes.

create

create(
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    table_name: str = "checkpoints",
    schema_name: str = "public",
    serde: typing.Optional[langgraph.checkpoint.serde.base.SerializerProtocol] = None,
) -> langchain_google_alloydb_pg.checkpoint.AlloyDBSaver

Create a new AlloyDBSaver instance.

Parameters
Name Description
engine AlloyDBEngine

AlloyDB engine to use.

table_name str

Table name that stores the checkpoints (default: "checkpoints").

schema_name str

The schema name where the table is located (default: "public").

serde SerializerProtocol

Serializer for encoding/decoding checkpoints (default: None).

Exceptions
Type Description
IndexError If the table provided does not contain required schema.
Returns
Type Description
AlloyDBSaver A newly created instance of AlloyDBSaver.

create_sync

create_sync(
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    table_name: str = "checkpoints",
    schema_name: str = "public",
    serde: typing.Optional[langgraph.checkpoint.serde.base.SerializerProtocol] = None,
) -> langchain_google_alloydb_pg.checkpoint.AlloyDBSaver

Create a new AlloyDBSaver instance.

Parameters
Name Description
engine AlloyDBEngine

AlloyDB engine to use.

table_name str

Table name that stores the checkpoints (default: "checkpoints").

schema_name str

The schema name where the table is located (default: "public").

serde SerializerProtocol

Serializer for encoding/decoding checkpoints (default: None).

Exceptions
Type Description
IndexError If the table provided does not contain required schema.
Returns
Type Description
AlloyDBSaver A newly created instance of AlloyDBSaver.

get_tuple

get_tuple(
    config: langchain_core.runnables.config.RunnableConfig,
) -> typing.Optional[langgraph.checkpoint.base.CheckpointTuple]

Get a checkpoint tuple from AlloyDB.

Parameter
Name Description
config RunnableConfig

The config to use for retrieving the checkpoint.

Returns
Type Description
Optional[CheckpointTuple] The retrieved checkpoint tuple, or None if no matching checkpoint was found.

list

list(
    config: typing.Optional[langchain_core.runnables.config.RunnableConfig],
    filter: typing.Optional[dict[str, typing.Any]] = None,
    before: typing.Optional[langchain_core.runnables.config.RunnableConfig] = None,
    limit: typing.Optional[int] = None,
) -> typing.Iterator[langgraph.checkpoint.base.CheckpointTuple]

List checkpoints from AlloyDB

Parameters
Name Description
config RunnableConfig

The config to use for listing the checkpoints.

filter Optional[Dict[str, Any]]

Additional filtering criteria for metadata. Defaults to None.

before Optional[RunnableConfig]

If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None.

limit Optional[int] :Yields: *Iterator[CheckpointTuple]* -- An iterator of checkpoint tuples.

The maximum number of checkpoints to return. Defaults to None.

put

put(
    config: langchain_core.runnables.config.RunnableConfig,
    checkpoint: langgraph.checkpoint.base.Checkpoint,
    metadata: langgraph.checkpoint.base.CheckpointMetadata,
    new_versions: dict[str, str | int | float],
) -> langchain_core.runnables.config.RunnableConfig

Save a checkpoint to the database.

Parameters
Name Description
config RunnableConfig

The config to associate with the checkpoint.

checkpoint Checkpoint

The checkpoint to save.

metadata CheckpointMetadata

Additional metadata to save with the checkpoint.

new_versions ChannelVersions

New channel versions as of this write.

Returns
Type Description
RunnableConfig Updated configuration after storing the checkpoint.

put_writes

put_writes(
    config: langchain_core.runnables.config.RunnableConfig,
    writes: typing.Sequence[tuple[str, typing.Any]],
    task_id: str,
    task_path: str = "",
) -> None

Store intermediate writes linked to a checkpoint.

Parameters
Name Description
config RunnableConfig

Configuration of the related checkpoint.

writes List[Tuple[str, Any]]

List of writes to store.

task_id str

Identifier for the task creating the writes.

task_path str

Path of the task creating the writes.