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.1
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.1.tar.gz | 201.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langgraph_checkpoint_mongodb-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 210.4 kB
Release files / langgraph_checkpoint_mongodb-0.5.1.tar.gz
| Download URL | langgraph_checkpoint_mongodb-0.5.1.tar.gz |
|---|---|
| Size | 201.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16f047fe11fe9fd08bbf70a246ea9f17d61d89591f0434426c4ec522a5a8eefd
|
|
BLAKE2b-256 checksum How to use checksums |
23ec288003477574e932429445dcdbd4e4e9f3777175a378b34f6e60049a9ec1
|
| 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.1-py3-none-any.whl
| Download URL | langgraph_checkpoint_mongodb-0.5.1-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
933fa3e7d60465d6af803ece6c0e462a336b74f89ee3a486a1196a3ca52028af
|
|
BLAKE2b-256 checksum How to use checksums |
ec35ed8c5759dab02a259f50c6356a38e2c2047295801988ad1f4183efbc3b00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|