langgraph-checkpoint-postgres 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.
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/PKG-INFO +2 -2
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/langgraph/checkpoint/postgres/__init__.py +1 -1
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/langgraph/checkpoint/postgres/base.py +1 -1
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/langgraph/store/postgres/aio.py +6 -3
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/langgraph/store/postgres/base.py +10 -15
- langgraph_checkpoint_postgres-2.0.2/langgraph/store/postgres/py.typed +0 -0
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/pyproject.toml +2 -2
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/README.md +0 -0
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/langgraph/checkpoint/postgres/aio.py +0 -0
- {langgraph_checkpoint_postgres-2.0.0/langgraph/checkpoint → langgraph_checkpoint_postgres-2.0.2/langgraph/checkpoint/postgres}/py.typed +0 -0
- {langgraph_checkpoint_postgres-2.0.0 → langgraph_checkpoint_postgres-2.0.2}/langgraph/store/postgres/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langgraph-checkpoint-postgres
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Library with a Postgres implementation of LangGraph checkpoint saver.
|
|
5
5
|
Home-page: https://www.github.com/langchain-ai/langgraph
|
|
6
6
|
License: MIT
|
|
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Requires-Dist: langgraph-checkpoint (>=2.0.
|
|
14
|
+
Requires-Dist: langgraph-checkpoint (>=2.0.2,<3.0.0)
|
|
15
15
|
Requires-Dist: orjson (>=3.10.1)
|
|
16
16
|
Requires-Dist: psycopg (>=3.0.0,<4.0.0)
|
|
17
17
|
Requires-Dist: psycopg-pool (>=3.0.0,<4.0.0)
|
|
@@ -287,7 +287,7 @@ class PostgresSaver(BasePostgresSaver):
|
|
|
287
287
|
>>> DB_URI = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
|
|
288
288
|
>>> with PostgresSaver.from_conn_string(DB_URI) as memory:
|
|
289
289
|
>>> config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
|
|
290
|
-
>>> checkpoint = {"ts": "2024-05-04T06:32:42.235444+00:00", "id": "1ef4f797-8335-6428-8001-8a1503f9b875", "
|
|
290
|
+
>>> checkpoint = {"ts": "2024-05-04T06:32:42.235444+00:00", "id": "1ef4f797-8335-6428-8001-8a1503f9b875", "channel_values": {"key": "value"}}
|
|
291
291
|
>>> saved_config = memory.put(config, checkpoint, {"source": "input", "step": 1, "writes": {"key": "value"}}, {})
|
|
292
292
|
>>> print(saved_config)
|
|
293
293
|
{'configurable': {'thread_id': '1', 'checkpoint_ns': '', 'checkpoint_id': '1ef4f797-8335-6428-8001-8a1503f9b875'}}
|
|
@@ -249,7 +249,7 @@ class BasePostgresSaver(BaseCheckpointSaver[str]):
|
|
|
249
249
|
filter: MetadataInput,
|
|
250
250
|
before: Optional[RunnableConfig] = None,
|
|
251
251
|
) -> Tuple[str, List[Any]]:
|
|
252
|
-
"""Return WHERE clause predicates for alist() given config, filter,
|
|
252
|
+
"""Return WHERE clause predicates for alist() given config, filter, before.
|
|
253
253
|
|
|
254
254
|
This method returns a tuple of a string and a tuple of values. The string
|
|
255
255
|
is the parametered WHERE clause predicate (including the WHERE keyword):
|
|
@@ -18,6 +18,7 @@ from psycopg.errors import UndefinedTable
|
|
|
18
18
|
from psycopg.rows import dict_row
|
|
19
19
|
|
|
20
20
|
from langgraph.store.base import GetOp, ListNamespacesOp, Op, PutOp, Result, SearchOp
|
|
21
|
+
from langgraph.store.base.batch import AsyncBatchedBaseStore
|
|
21
22
|
from langgraph.store.postgres.base import (
|
|
22
23
|
BasePostgresStore,
|
|
23
24
|
Row,
|
|
@@ -29,7 +30,9 @@ from langgraph.store.postgres.base import (
|
|
|
29
30
|
logger = logging.getLogger(__name__)
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
class AsyncPostgresStore(BasePostgresStore[AsyncConnection]):
|
|
33
|
+
class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[AsyncConnection]):
|
|
34
|
+
__slots__ = ("_deserializer",)
|
|
35
|
+
|
|
33
36
|
def __init__(
|
|
34
37
|
self,
|
|
35
38
|
conn: AsyncConnection[Any],
|
|
@@ -38,8 +41,8 @@ class AsyncPostgresStore(BasePostgresStore[AsyncConnection]):
|
|
|
38
41
|
Callable[[Union[bytes, orjson.Fragment]], dict[str, Any]]
|
|
39
42
|
] = None,
|
|
40
43
|
) -> None:
|
|
41
|
-
super().__init__(
|
|
42
|
-
self.
|
|
44
|
+
super().__init__()
|
|
45
|
+
self._deserializer = deserializer
|
|
43
46
|
self.conn = conn
|
|
44
47
|
self.loop = asyncio.get_running_loop()
|
|
45
48
|
|
|
@@ -59,20 +59,10 @@ CREATE INDEX IF NOT EXISTS store_prefix_idx ON store USING btree (prefix text_pa
|
|
|
59
59
|
C = TypeVar("C", bound=BaseConnection)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
class BasePostgresStore(
|
|
62
|
+
class BasePostgresStore(Generic[C]):
|
|
63
63
|
MIGRATIONS = MIGRATIONS
|
|
64
64
|
conn: C
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def __init__(
|
|
68
|
-
self,
|
|
69
|
-
*,
|
|
70
|
-
deserializer: Optional[
|
|
71
|
-
Callable[[Union[bytes, orjson.Fragment]], dict[str, Any]]
|
|
72
|
-
] = None,
|
|
73
|
-
) -> None:
|
|
74
|
-
super().__init__()
|
|
75
|
-
self._deserializer = deserializer
|
|
65
|
+
_deserializer: Optional[Callable[[Union[bytes, orjson.Fragment]], dict[str, Any]]]
|
|
76
66
|
|
|
77
67
|
def _get_batch_GET_ops_queries(
|
|
78
68
|
self,
|
|
@@ -166,7 +156,9 @@ class BasePostgresStore(BaseStore, Generic[C]):
|
|
|
166
156
|
params.extend([key, json.dumps(value)])
|
|
167
157
|
query += " AND " + " AND ".join(filter_conditions)
|
|
168
158
|
|
|
169
|
-
|
|
159
|
+
# Note: we will need to not do this if sim/keyword search
|
|
160
|
+
# is used
|
|
161
|
+
query += " ORDER BY updated_at DESC LIMIT %s OFFSET %s"
|
|
170
162
|
params.extend([op.limit, op.offset])
|
|
171
163
|
|
|
172
164
|
queries.append((query, params))
|
|
@@ -227,7 +219,9 @@ class BasePostgresStore(BaseStore, Generic[C]):
|
|
|
227
219
|
return queries
|
|
228
220
|
|
|
229
221
|
|
|
230
|
-
class PostgresStore(BasePostgresStore[Connection]):
|
|
222
|
+
class PostgresStore(BaseStore, BasePostgresStore[Connection]):
|
|
223
|
+
__slots__ = ("_deserializer",)
|
|
224
|
+
|
|
231
225
|
def __init__(
|
|
232
226
|
self,
|
|
233
227
|
conn: Connection[Any],
|
|
@@ -236,7 +230,8 @@ class PostgresStore(BasePostgresStore[Connection]):
|
|
|
236
230
|
Callable[[Union[bytes, orjson.Fragment]], dict[str, Any]]
|
|
237
231
|
] = None,
|
|
238
232
|
) -> None:
|
|
239
|
-
super().__init__(
|
|
233
|
+
super().__init__()
|
|
234
|
+
self._deserializer = deserializer
|
|
240
235
|
self.conn = conn
|
|
241
236
|
|
|
242
237
|
def batch(self, ops: Iterable[Op]) -> list[Result]:
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "langgraph-checkpoint-postgres"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.2"
|
|
4
4
|
description = "Library with a Postgres implementation of LangGraph checkpoint saver."
|
|
5
5
|
authors = []
|
|
6
6
|
license = "MIT"
|
|
@@ -10,7 +10,7 @@ packages = [{ include = "langgraph" }]
|
|
|
10
10
|
|
|
11
11
|
[tool.poetry.dependencies]
|
|
12
12
|
python = "^3.9.0,<4.0"
|
|
13
|
-
langgraph-checkpoint = "^2.0.
|
|
13
|
+
langgraph-checkpoint = "^2.0.2"
|
|
14
14
|
orjson = ">=3.10.1"
|
|
15
15
|
psycopg = "^3.0.0"
|
|
16
16
|
psycopg-pool = "^3.0.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|