langgraph-checkpoint 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/PKG-INFO +1 -1
  2. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/base/__init__.py +1 -1
  3. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/serde/jsonplus.py +3 -1
  4. langgraph_checkpoint-2.0.2/langgraph/checkpoint/serde/py.typed +0 -0
  5. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/store/base/__init__.py +22 -3
  6. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/store/base/batch.py +10 -1
  7. langgraph_checkpoint-2.0.2/langgraph/store/base/py.typed +0 -0
  8. langgraph_checkpoint-2.0.2/langgraph/store/memory/py.typed +0 -0
  9. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/pyproject.toml +1 -1
  10. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/LICENSE +0 -0
  11. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/README.md +0 -0
  12. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/base/id.py +0 -0
  13. {langgraph_checkpoint-2.0.0/langgraph/checkpoint → langgraph_checkpoint-2.0.2/langgraph/checkpoint/base}/py.typed +0 -0
  14. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/memory/__init__.py +0 -0
  15. {langgraph_checkpoint-2.0.0/langgraph/store → langgraph_checkpoint-2.0.2/langgraph/checkpoint/memory}/py.typed +0 -0
  16. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/serde/__init__.py +0 -0
  17. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/serde/base.py +0 -0
  18. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/checkpoint/serde/types.py +0 -0
  19. {langgraph_checkpoint-2.0.0 → langgraph_checkpoint-2.0.2}/langgraph/store/memory/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langgraph-checkpoint
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Library with base interfaces for LangGraph checkpoint savers.
5
5
  Home-page: https://www.github.com/langchain-ai/langgraph
6
6
  License: MIT
@@ -178,7 +178,7 @@ CheckpointNS = ConfigurableFieldSpec(
178
178
  annotation=str,
179
179
  name="Checkpoint NS",
180
180
  description='Checkpoint namespace. Denotes the path to the subgraph node the checkpoint originates from, separated by `|` character, e.g. `"child|grandchild"`. Defaults to "" (root graph).',
181
- default=None,
181
+ default="",
182
182
  is_shared=True,
183
183
  )
184
184
 
@@ -206,7 +206,9 @@ class JsonPlusSerializer(SerializerProtocol):
206
206
  elif type_ == "json":
207
207
  return self.loads(data_)
208
208
  elif type_ == "msgpack":
209
- return msgpack.unpackb(data_, ext_hook=_msgpack_ext_hook)
209
+ return msgpack.unpackb(
210
+ data_, ext_hook=_msgpack_ext_hook, strict_map_key=False
211
+ )
210
212
  else:
211
213
  raise NotImplementedError(f"Unknown serialization type: {type_}")
212
214
 
@@ -14,7 +14,7 @@ class Item:
14
14
 
15
15
  Args:
16
16
  value (dict[str, Any]): The stored data as a dictionary. Keys are filterable.
17
- (str): Unique identifier within the namespace.
17
+ key (str): Unique identifier within the namespace.
18
18
  namespace (tuple[str, ...]): Hierarchical path defining the collection in which this document resides.
19
19
  Represented as a tuple of strings, allowing for nested categorization.
20
20
  For example: ("documents", 'user123')
@@ -159,15 +159,34 @@ class InvalidNamespaceError(ValueError):
159
159
 
160
160
 
161
161
  def _validate_namespace(namespace: tuple[str, ...]) -> None:
162
+ if not namespace:
163
+ raise InvalidNamespaceError("Namespace cannot be empty.")
162
164
  for label in namespace:
165
+ if not isinstance(label, str):
166
+ raise InvalidNamespaceError(
167
+ f"Invalid namespace label '{label}' found in {namespace}. Namespace labels"
168
+ f" must be strings, but got {type(label).__name__}."
169
+ )
163
170
  if "." in label:
164
171
  raise InvalidNamespaceError(
165
- f"Invalid namespace label '{label}'. Namespace labels cannot contain periods ('.')."
172
+ f"Invalid namespace label '{label}' found in {namespace}. Namespace labels cannot contain periods ('.')."
173
+ )
174
+ elif not label:
175
+ raise InvalidNamespaceError(
176
+ f"Namespace labels cannot be empty strings. Got {label} in {namespace}"
166
177
  )
178
+ if namespace[0] == "langgraph":
179
+ raise InvalidNamespaceError(
180
+ f'Root label for namespace cannot be "langgraph". Got: {namespace}'
181
+ )
167
182
 
168
183
 
169
184
  class BaseStore(ABC):
170
- """Abstract base class for key-value stores."""
185
+ """Abstract base class for persistent key-value stores.
186
+
187
+ Stores enable persistence and memory that can be shared across threads,
188
+ scoped to user IDs, assistant IDs, or other arbitrary namespaces.
189
+ """
171
190
 
172
191
  __slots__ = ("__weakref__",)
173
192
 
@@ -2,7 +2,15 @@ import asyncio
2
2
  import weakref
3
3
  from typing import Any, Optional
4
4
 
5
- from langgraph.store.base import BaseStore, GetOp, Item, Op, PutOp, SearchOp
5
+ from langgraph.store.base import (
6
+ BaseStore,
7
+ GetOp,
8
+ Item,
9
+ Op,
10
+ PutOp,
11
+ SearchOp,
12
+ _validate_namespace,
13
+ )
6
14
 
7
15
 
8
16
  class AsyncBatchedBaseStore(BaseStore):
@@ -46,6 +54,7 @@ class AsyncBatchedBaseStore(BaseStore):
46
54
  key: str,
47
55
  value: dict[str, Any],
48
56
  ) -> None:
57
+ _validate_namespace(namespace)
49
58
  fut = self._loop.create_future()
50
59
  self._aqueue[fut] = PutOp(namespace, key, value)
51
60
  return await fut
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langgraph-checkpoint"
3
- version = "2.0.0"
3
+ version = "2.0.2"
4
4
  description = "Library with base interfaces for LangGraph checkpoint savers."
5
5
  authors = []
6
6
  license = "MIT"