DynamoDB Saver for LangGraph Checkpoints
Project description
langgraph-checkpoint-dynamodb
Implementation of a LangGraph CheckpointSaver that uses a AWS's DynamoDB
Inspiration
Based on: https://github.com/researchwiseai/langgraphjs-checkpoint-dynamodb
Required DynamoDB Tables
To be able to use this checkpointer, two DynamoDB table's are needed, one to store checkpoints and the other to store writes. Below are some examples of how you can create the required tables.
Terraform
# Variables for table names
variable "checkpoints_table_name" {
type = string
}
variable "writes_table_name" {
type = string
}
# Checkpoints Table
resource "aws_dynamodb_table" "checkpoints_table" {
name = var.checkpoints_table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = "thread_id"
range_key = "checkpoint_id"
attribute {
name = "thread_id"
type = "S"
}
attribute {
name = "checkpoint_id"
type = "S"
}
}
# Writes Table
resource "aws_dynamodb_table" "writes_table" {
name = var.writes_table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = "thread_id_checkpoint_id_checkpoint_ns"
range_key = "task_id_idx"
attribute {
name = "thread_id_checkpoint_id_checkpoint_ns"
type = "S"
}
attribute {
name = "task_id_idx"
type = "S"
}
}
AWS CDK
from aws_cdk import (
Stack,
aws_dynamodb as dynamodb,
)
from constructs import Construct
class DynamoDbStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs):
super().__init__(scope, id, **kwargs)
checkpoints_table_name = 'YourCheckpointsTableName'
writes_table_name = 'YourWritesTableName'
# Checkpoints Table
dynamodb.Table(
self,
'CheckpointsTable',
table_name=checkpoints_table_name,
billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,
partition_key=dynamodb.Attribute(
name='thread_id',
type=dynamodb.AttributeType.STRING,
),
sort_key=dynamodb.Attribute(
name='checkpoint_id',
type=dynamodb.AttributeType.STRING,
),
)
# Writes Table
dynamodb.Table(
self,
'WritesTable',
table_name=writes_table_name,
billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,
partition_key=dynamodb.Attribute(
name='thread_id_checkpoint_id_checkpoint_ns',
type=dynamodb.AttributeType.STRING,
),
sort_key=dynamodb.Attribute(
name='task_id_idx',
type=dynamodb.AttributeType.STRING,
),
)
Using the Checkpoint Saver
Default
To use the DynamoDB checkpoint saver, you only need to specify the names of the checkpoints and writes tables. In this scenario the DynamoDB client will be instantiated with the default configuration, great for running on AWS Lambda.
from langgraph_checkpoint_dynamodb import DynamoDBSaver
...
checkpoints_table_name = 'YourCheckpointsTableName'
writes_table_name = 'YourWritesTableName'
memory = DynamoDBSaver(
checkpoints_table_name=checkpoints_table_name,
writes_table_name=writes_table_name,
)
graph = workflow.compile(checkpointer=memory)
Providing Client Configuration
If you need to provide custom configuration to the DynamoDB client, you can pass in an object with the configuration options. Below is an example of how you can provide custom configuration.
memory = DynamoDBSaver(
checkpoints_table_name=checkpoints_table_name,
writes_table_name=writes_table_name,
client_config={
'region': 'us-west-2',
'accessKeyId': 'your-access-key-id',
'secretAccessKey': 'your-secret-access-key',
}
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langgraph_checkpoint_dynamodb-0.1.0.tar.gz.
File metadata
- Download URL: langgraph_checkpoint_dynamodb-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7135d6ee58b1388421a0ef17c6659f031d1d42e1a33b3a5907b8deebe781e1d7
|
|
| MD5 |
4f44a9db071e0af4c4d281c5e4cd63bb
|
|
| BLAKE2b-256 |
0758400d36651e29726a9d552b8d09d73baf70a48f70d86dab64894a28d927ce
|
Provenance
The following attestation bundles were made for langgraph_checkpoint_dynamodb-0.1.0.tar.gz:
Publisher:
publish.yml on justinram11/langgraph-checkpoint-dynamodb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langgraph_checkpoint_dynamodb-0.1.0.tar.gz -
Subject digest:
7135d6ee58b1388421a0ef17c6659f031d1d42e1a33b3a5907b8deebe781e1d7 - Sigstore transparency entry: 155153898
- Sigstore integration time:
-
Permalink:
justinram11/langgraph-checkpoint-dynamodb@7a1b5f5cea86b0ded3e8054677f9e770503857d8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/justinram11
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a1b5f5cea86b0ded3e8054677f9e770503857d8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langgraph_checkpoint_dynamodb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langgraph_checkpoint_dynamodb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5992954728862b2a4b2f9947c989cedc9e945c526b9f6ecf42eb21f787fc6ce2
|
|
| MD5 |
05bbccbf1690be6d4784a92eabcfe9e1
|
|
| BLAKE2b-256 |
c9f354da77f0242523c1908481bcd99134cb413cdab63b933c7c214c5cb1fbea
|
Provenance
The following attestation bundles were made for langgraph_checkpoint_dynamodb-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on justinram11/langgraph-checkpoint-dynamodb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langgraph_checkpoint_dynamodb-0.1.0-py3-none-any.whl -
Subject digest:
5992954728862b2a4b2f9947c989cedc9e945c526b9f6ecf42eb21f787fc6ce2 - Sigstore transparency entry: 155153901
- Sigstore integration time:
-
Permalink:
justinram11/langgraph-checkpoint-dynamodb@7a1b5f5cea86b0ded3e8054677f9e770503857d8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/justinram11
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a1b5f5cea86b0ded3e8054677f9e770503857d8 -
Trigger Event:
release
-
Statement type: