initial commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,103 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: langgraph-checkpoint
|
||||
Version: 4.0.1
|
||||
Summary: Library with base interfaces for LangGraph checkpoint savers.
|
||||
Project-URL: Source, https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint
|
||||
Project-URL: Twitter, https://x.com/LangChain
|
||||
Project-URL: Slack, https://www.langchain.com/join-community
|
||||
Project-URL: Reddit, https://www.reddit.com/r/LangChain/
|
||||
License-Expression: MIT
|
||||
License-File: LICENSE
|
||||
Requires-Python: >=3.10
|
||||
Requires-Dist: langchain-core>=0.2.38
|
||||
Requires-Dist: ormsgpack>=1.12.0
|
||||
Description-Content-Type: text/markdown
|
||||
|
||||
# LangGraph Checkpoint
|
||||
|
||||
This library defines the base interface for LangGraph checkpointers. Checkpointers provide a persistence layer for LangGraph. They allow you to interact with and manage the graph's state. When you use a graph with a checkpointer, the checkpointer saves a _checkpoint_ of the graph state at every superstep, enabling several powerful capabilities like human-in-the-loop, "memory" between interactions and more.
|
||||
|
||||
## Key concepts
|
||||
|
||||
### Checkpoint
|
||||
|
||||
Checkpoint is a snapshot of the graph state at a given point in time. Checkpoint tuple refers to an object containing checkpoint and the associated config, metadata and pending writes.
|
||||
|
||||
### Thread
|
||||
|
||||
Threads enable the checkpointing of multiple different runs, making them essential for multi-tenant chat applications and other scenarios where maintaining separate states is necessary. A thread is a unique ID assigned to a series of checkpoints saved by a checkpointer. When using a checkpointer, you must specify a `thread_id` and optionally `checkpoint_id` when running the graph.
|
||||
|
||||
- `thread_id` is simply the ID of a thread. This is always required.
|
||||
- `checkpoint_id` can optionally be passed. This identifier refers to a specific checkpoint within a thread. This can be used to kick off a run of a graph from some point halfway through a thread.
|
||||
|
||||
You must pass these when invoking the graph as part of the configurable part of the config, e.g.
|
||||
|
||||
```python
|
||||
{"configurable": {"thread_id": "1"}} # valid config
|
||||
{"configurable": {"thread_id": "1", "checkpoint_id": "0c62ca34-ac19-445d-bbb0-5b4984975b2a"}} # also valid config
|
||||
```
|
||||
|
||||
### Serde
|
||||
|
||||
`langgraph_checkpoint` also defines protocol for serialization/deserialization (serde) and provides an default implementation (`langgraph.checkpoint.serde.jsonplus.JsonPlusSerializer`) that handles a wide variety of types, including LangChain and LangGraph primitives, datetimes, enums and more.
|
||||
|
||||
### Pending writes
|
||||
|
||||
When a graph node fails mid-execution at a given superstep, LangGraph stores pending checkpoint writes from any other nodes that completed successfully at that superstep, so that whenever we resume graph execution from that superstep we don't re-run the successful nodes.
|
||||
|
||||
## Interface
|
||||
|
||||
Each checkpointer should conform to `langgraph.checkpoint.base.BaseCheckpointSaver` interface and must implement the following methods:
|
||||
|
||||
- `.put` - Store a checkpoint with its configuration and metadata.
|
||||
- `.put_writes` - Store intermediate writes linked to a checkpoint (i.e. pending writes).
|
||||
- `.get_tuple` - Fetch a checkpoint tuple using for a given configuration (`thread_id` and `checkpoint_id`).
|
||||
- `.list` - List checkpoints that match a given configuration and filter criteria.
|
||||
- `.delete_thread()` - Delete all checkpoints and writes associated with a thread.
|
||||
- `.get_next_version()` - Generate the next version ID for a channel.
|
||||
|
||||
If the checkpointer will be used with asynchronous graph execution (i.e. executing the graph via `.ainvoke`, `.astream`, `.abatch`), checkpointer must implement asynchronous versions of the above methods (`.aput`, `.aput_writes`, `.aget_tuple`, `.alist`). Similarly, the checkpointer must implement `.adelete_thread()` if asynchronous thread cleanup is desired. The base class provides a default implementation of `.get_next_version()` that generates an integer sequence starting from 1, but this method should be overridden for custom versioning schemes.
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
from langgraph.checkpoint.memory import InMemorySaver
|
||||
|
||||
write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
|
||||
read_config = {"configurable": {"thread_id": "1"}}
|
||||
|
||||
checkpointer = InMemorySaver()
|
||||
checkpoint = {
|
||||
"v": 4,
|
||||
"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
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
# store checkpoint
|
||||
checkpointer.put(write_config, checkpoint, {}, {})
|
||||
|
||||
# load checkpoint
|
||||
checkpointer.get(read_config)
|
||||
|
||||
# list checkpoints
|
||||
list(checkpointer.list(read_config))
|
||||
```
|
||||
@@ -0,0 +1,45 @@
|
||||
langgraph/cache/base/__init__.py,sha256=sNpXpKFba2eiZlJvFnq3003Zl9_RXPv2_OCuP9AvXdQ,1835
|
||||
langgraph/cache/base/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/cache/base/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph/cache/memory/__init__.py,sha256=g5zJhXOSRrA1UyabMAQpajWT3ax4KmpqdLFwuV9cM2c,3071
|
||||
langgraph/cache/memory/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/cache/redis/__init__.py,sha256=jBbusZYXEavxz47mJdk1r-TFAtdFv9K5ql4iacTk0g0,5188
|
||||
langgraph/cache/redis/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/checkpoint/base/__init__.py,sha256=MwfBd3mlgxnE1h9C-dVp52eRyYPRllf48wLRvEpoRFI,20047
|
||||
langgraph/checkpoint/base/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/checkpoint/base/__pycache__/id.cpython-311.pyc,,
|
||||
langgraph/checkpoint/base/id.py,sha256=9GNdj18ecTwPVesRGtMqMjEhsxjhskVutdYbMFwleFs,3647
|
||||
langgraph/checkpoint/base/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph/checkpoint/memory/__init__.py,sha256=xg_FHRi7GPCR1xZV9U4p7WQ4VN3Y658G_TrMMUnOIWs,22290
|
||||
langgraph/checkpoint/memory/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/checkpoint/memory/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph/checkpoint/serde/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph/checkpoint/serde/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/__pycache__/_msgpack.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/__pycache__/base.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/__pycache__/encrypted.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/__pycache__/event_hooks.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/__pycache__/jsonplus.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/__pycache__/types.cpython-311.pyc,,
|
||||
langgraph/checkpoint/serde/_msgpack.py,sha256=C3_ppPf0GWBVG_PUSMXoGgLUsUldomBzSa2nEr3_xF0,3180
|
||||
langgraph/checkpoint/serde/base.py,sha256=HzvYGU28Ja5vjiTBQwRjKGjRukK8uccy3EXtth3ZK8s,1933
|
||||
langgraph/checkpoint/serde/encrypted.py,sha256=0aFe2PnZf5FrvAKtUduWWZTuc2yB3Wr4h9TyzRdWi-A,3180
|
||||
langgraph/checkpoint/serde/event_hooks.py,sha256=Q3xRhP7VLiKdr7Nn7Kk2tSz0-Bia9Jp56SYTRNLv_JI,1235
|
||||
langgraph/checkpoint/serde/jsonplus.py,sha256=AQvdIti8f6LUGwYQxlXX0LelfO_pUr91b7pxi894m_U,28731
|
||||
langgraph/checkpoint/serde/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph/checkpoint/serde/types.py,sha256=Ma_N0HYZ2H2UPv3CVaGIVTGf2Mx-1evuBwCOzLY51mI,1068
|
||||
langgraph/store/base/__init__.py,sha256=1LlbDlGdozVzCZGTmbnH2iKxfH8mZ1gUdPT1KkF5dsU,42764
|
||||
langgraph/store/base/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/store/base/__pycache__/batch.cpython-311.pyc,,
|
||||
langgraph/store/base/__pycache__/embed.cpython-311.pyc,,
|
||||
langgraph/store/base/batch.py,sha256=z5J8uDTTVbV6_6kcYUUFODXx1s2KVQXN-5JspVLSk8U,10934
|
||||
langgraph/store/base/embed.py,sha256=65QLyvvKQGWtWd2U6lCZHEthg_bBxXaUwWcMNfLq4ao,14497
|
||||
langgraph/store/base/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph/store/memory/__init__.py,sha256=KZ28-D648U1dybs5_mJiqS2TE0f6okai9K8-WPM9YR8,21155
|
||||
langgraph/store/memory/__pycache__/__init__.cpython-311.pyc,,
|
||||
langgraph/store/memory/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
langgraph_checkpoint-4.0.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
langgraph_checkpoint-4.0.1.dist-info/METADATA,sha256=p-WnA_tkDmfk81uw7cwb5sJOXupmysfmeRR144bJgxI,4861
|
||||
langgraph_checkpoint-4.0.1.dist-info/RECORD,,
|
||||
langgraph_checkpoint-4.0.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
||||
langgraph_checkpoint-4.0.1.dist-info/licenses/LICENSE,sha256=2btS8uNUDWD_UNjw9ba6ZJt_00aUjEw9CGyK-xIHY8c,1072
|
||||
@@ -0,0 +1,4 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: hatchling 1.29.0
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 LangChain, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Reference in New Issue
Block a user