LangGraph Checkpoint MongoDB
Implementation of LangGraph CheckpointSaver that uses MongoDB.
Installation
pip install -U langgraph-checkpoint-mongodb
Usage
For more detailed usage examples and documentation, please refer to the MongoDB LangGraph documentation.
from langgraph.checkpoint.mongodb import MongoDBSaver
write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
read_config = {"configurable": {"thread_id": "1"}}
MONGODB_URI = "mongodb://localhost:27017"
DB_NAME = "checkpoint_example"
with MongoDBSaver.from_conn_string(MONGODB_URI, DB_NAME) as checkpointer:
checkpoint = {
"v": 1,
"ts": "2024-07-31T20:14:19.804150+00:00",
"id": "1ef4f797-8335-6428-8001-8a1503f9b875",
"channel_values": {
"my_key": "meow",
"node": "node"
},
"channel_versions": {
"__start__": 2,
"my_key": 3,
"start:node": 3,
"node": 3
},
"versions_seen": {
"__input__": {},
"__start__": {
"__start__": 1
},
"node": {
"start:node": 2
}
},
"pending_sends": [],
}
# store checkpoint
checkpointer.put(write_config, checkpoint, {}, {})
# load checkpoint
checkpointer.get(read_config)
# list checkpoints
list(checkpointer.list(read_config))
Async
from langgraph.checkpoint.mongodb import MongoDBSaver
write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
read_config = {"configurable": {"thread_id": "1"}}
MONGODB_URI = "mongodb://localhost:27017"
DB_NAME = "checkpoint_example"
with MongoDBSaver.from_conn_string(MONGODB_URI, DB_NAME) as checkpointer:
checkpoint = {
"v": 1,
"ts": "2024-07-31T20:14:19.804150+00:00",
"id": "1ef4f797-8335-6428-8001-8a1503f9b875",
"channel_values": {
"my_key": "meow",
"node": "node"
},
"channel_versions": {
"__start__": 2,
"my_key": 3,
"start:node": 3,
"node": 3
},
"versions_seen": {
"__input__": {},
"__start__": {
"__start__": 1
},
"node": {
"start:node": 2
}
},
"pending_sends": [],
}
# store checkpoint
await checkpointer.aput(write_config, checkpoint, {}, {})
# load checkpoint
await checkpointer.aget(read_config)
# list checkpoints
[c async for c in checkpointer.alist(read_config)]
Metadata
Release files for langgraph-checkpoint-mongodb 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langgraph_checkpoint_mongodb-0.5.0.tar.gz | 200.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langgraph_checkpoint_mongodb-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 208.4 kB
Release files / langgraph_checkpoint_mongodb-0.5.0.tar.gz
| Download URL | langgraph_checkpoint_mongodb-0.5.0.tar.gz |
|---|---|
| Size | 200.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac0f1f0f19d4ec28e7f0b21166ff1f2f3a85d8913f570f27ea7b40b6bbc53261
|
|
BLAKE2b-256 checksum How to use checksums |
6c5aea97bf0835cac2ba9a9766c890200d26da466d3dad185af84d4ac4c24e0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / langgraph_checkpoint_mongodb-0.5.0-py3-none-any.whl
| Download URL | langgraph_checkpoint_mongodb-0.5.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76665e5b861a9eb36d9abb873264e795adce34d408719460bb3bdc2bb9783d53
|
|
BLAKE2b-256 checksum How to use checksums |
f9b288ec108f2c7ec5fc4ee78c39398b1fa45ff96106e1c6ad1f62651ed020b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|