langgraph-checkpoint-postgres 2.0.13__tar.gz → 2.0.15__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.13 → langgraph_checkpoint_postgres-2.0.15}/PKG-INFO +2 -2
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/__init__.py +2 -1
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/aio.py +2 -1
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/shallow.py +3 -2
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/store/postgres/aio.py +16 -13
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/store/postgres/base.py +37 -18
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/pyproject.toml +9 -3
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/README.md +0 -0
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/_ainternal.py +0 -0
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/_internal.py +0 -0
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/base.py +0 -0
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/checkpoint/postgres/py.typed +0 -0
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/store/postgres/__init__.py +0 -0
- {langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/langgraph/store/postgres/py.typed +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.15
|
|
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.15,<3.0.0)
|
|
15
15
|
Requires-Dist: orjson (>=3.10.1)
|
|
16
16
|
Requires-Dist: psycopg (>=3.2.0,<4.0.0)
|
|
17
17
|
Requires-Dist: psycopg-pool (>=3.2.0,<4.0.0)
|
|
@@ -16,6 +16,7 @@ from langgraph.checkpoint.base import (
|
|
|
16
16
|
CheckpointMetadata,
|
|
17
17
|
CheckpointTuple,
|
|
18
18
|
get_checkpoint_id,
|
|
19
|
+
get_checkpoint_metadata,
|
|
19
20
|
)
|
|
20
21
|
from langgraph.checkpoint.postgres import _internal
|
|
21
22
|
from langgraph.checkpoint.postgres.base import BasePostgresSaver
|
|
@@ -317,7 +318,7 @@ class PostgresSaver(BasePostgresSaver):
|
|
|
317
318
|
checkpoint["id"],
|
|
318
319
|
checkpoint_id,
|
|
319
320
|
Jsonb(self._dump_checkpoint(copy)),
|
|
320
|
-
self._dump_metadata(metadata),
|
|
321
|
+
self._dump_metadata(get_checkpoint_metadata(config, metadata)),
|
|
321
322
|
),
|
|
322
323
|
)
|
|
323
324
|
return next_config
|
|
@@ -16,6 +16,7 @@ from langgraph.checkpoint.base import (
|
|
|
16
16
|
CheckpointMetadata,
|
|
17
17
|
CheckpointTuple,
|
|
18
18
|
get_checkpoint_id,
|
|
19
|
+
get_checkpoint_metadata,
|
|
19
20
|
)
|
|
20
21
|
from langgraph.checkpoint.postgres import _ainternal
|
|
21
22
|
from langgraph.checkpoint.postgres.base import BasePostgresSaver
|
|
@@ -275,7 +276,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
|
|
|
275
276
|
checkpoint["id"],
|
|
276
277
|
checkpoint_id,
|
|
277
278
|
Jsonb(self._dump_checkpoint(copy)),
|
|
278
|
-
self._dump_metadata(metadata),
|
|
279
|
+
self._dump_metadata(get_checkpoint_metadata(config, metadata)),
|
|
279
280
|
),
|
|
280
281
|
)
|
|
281
282
|
return next_config
|
|
@@ -24,6 +24,7 @@ from langgraph.checkpoint.base import (
|
|
|
24
24
|
Checkpoint,
|
|
25
25
|
CheckpointMetadata,
|
|
26
26
|
CheckpointTuple,
|
|
27
|
+
get_checkpoint_metadata,
|
|
27
28
|
)
|
|
28
29
|
from langgraph.checkpoint.postgres import _ainternal, _internal
|
|
29
30
|
from langgraph.checkpoint.postgres.base import BasePostgresSaver
|
|
@@ -423,7 +424,7 @@ class ShallowPostgresSaver(BasePostgresSaver):
|
|
|
423
424
|
thread_id,
|
|
424
425
|
checkpoint_ns,
|
|
425
426
|
Jsonb(self._dump_checkpoint(copy)),
|
|
426
|
-
self._dump_metadata(metadata),
|
|
427
|
+
self._dump_metadata(get_checkpoint_metadata(config, metadata)),
|
|
427
428
|
),
|
|
428
429
|
)
|
|
429
430
|
return next_config
|
|
@@ -742,7 +743,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver):
|
|
|
742
743
|
thread_id,
|
|
743
744
|
checkpoint_ns,
|
|
744
745
|
Jsonb(self._dump_checkpoint(copy)),
|
|
745
|
-
self._dump_metadata(metadata),
|
|
746
|
+
self._dump_metadata(get_checkpoint_metadata(config, metadata)),
|
|
746
747
|
),
|
|
747
748
|
)
|
|
748
749
|
return next_config
|
|
@@ -39,14 +39,14 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con
|
|
|
39
39
|
"""Asynchronous Postgres-backed store with optional vector search using pgvector.
|
|
40
40
|
|
|
41
41
|
!!! example "Examples"
|
|
42
|
-
Basic setup and
|
|
42
|
+
Basic setup and usage:
|
|
43
43
|
```python
|
|
44
44
|
from langgraph.store.postgres import AsyncPostgresStore
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
) as store:
|
|
49
|
-
await store.setup()
|
|
46
|
+
conn_string = "postgresql://user:pass@localhost:5432/dbname"
|
|
47
|
+
|
|
48
|
+
async with AsyncPostgresStore.from_conn_string(conn_string) as store:
|
|
49
|
+
await store.setup() # Run migrations. Done once
|
|
50
50
|
|
|
51
51
|
# Store and retrieve data
|
|
52
52
|
await store.aput(("users", "123"), "prefs", {"theme": "dark"})
|
|
@@ -58,38 +58,41 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con
|
|
|
58
58
|
from langchain.embeddings import init_embeddings
|
|
59
59
|
from langgraph.store.postgres import AsyncPostgresStore
|
|
60
60
|
|
|
61
|
+
conn_string = "postgresql://user:pass@localhost:5432/dbname"
|
|
62
|
+
|
|
61
63
|
async with AsyncPostgresStore.from_conn_string(
|
|
62
|
-
|
|
64
|
+
conn_string,
|
|
63
65
|
index={
|
|
64
66
|
"dims": 1536,
|
|
65
67
|
"embed": init_embeddings("openai:text-embedding-3-small"),
|
|
66
68
|
"fields": ["text"] # specify which fields to embed. Default is the whole serialized value
|
|
67
69
|
}
|
|
68
70
|
) as store:
|
|
69
|
-
await store.setup() #
|
|
71
|
+
await store.setup() # Run migrations. Done once
|
|
70
72
|
|
|
71
73
|
# Store documents
|
|
72
74
|
await store.aput(("docs",), "doc1", {"text": "Python tutorial"})
|
|
73
75
|
await store.aput(("docs",), "doc2", {"text": "TypeScript guide"})
|
|
74
|
-
#
|
|
75
|
-
await store.aput(("docs",), "doc3", {"text": "Other guide"}, index=False)
|
|
76
|
+
await store.aput(("docs",), "doc3", {"text": "Other guide"}, index=False) # don't index
|
|
76
77
|
|
|
77
78
|
# Search by similarity
|
|
78
|
-
results = await store.asearch(("docs",),
|
|
79
|
+
results = await store.asearch(("docs",), "programming guides", limit=2)
|
|
79
80
|
```
|
|
80
81
|
|
|
81
82
|
Using connection pooling for better performance:
|
|
82
83
|
```python
|
|
83
84
|
from langgraph.store.postgres import AsyncPostgresStore, PoolConfig
|
|
84
85
|
|
|
86
|
+
conn_string = "postgresql://user:pass@localhost:5432/dbname"
|
|
87
|
+
|
|
85
88
|
async with AsyncPostgresStore.from_conn_string(
|
|
86
|
-
|
|
89
|
+
conn_string,
|
|
87
90
|
pool_config=PoolConfig(
|
|
88
91
|
min_size=5,
|
|
89
92
|
max_size=20
|
|
90
93
|
)
|
|
91
94
|
) as store:
|
|
92
|
-
await store.setup()
|
|
95
|
+
await store.setup() # Run migrations. Done once
|
|
93
96
|
# Use store with connection pooling...
|
|
94
97
|
```
|
|
95
98
|
|
|
@@ -102,7 +105,7 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con
|
|
|
102
105
|
Note:
|
|
103
106
|
Semantic search is disabled by default. You can enable it by providing an `index` configuration
|
|
104
107
|
when creating the store. Without this configuration, all `index` arguments passed to
|
|
105
|
-
`put` or `aput`will have no effect.
|
|
108
|
+
`put` or `aput` will have no effect.
|
|
106
109
|
"""
|
|
107
110
|
|
|
108
111
|
__slots__ = (
|
|
@@ -536,18 +536,35 @@ class PostgresStore(BaseStore, BasePostgresStore[_pg_internal.Conn]):
|
|
|
536
536
|
"""Postgres-backed store with optional vector search using pgvector.
|
|
537
537
|
|
|
538
538
|
!!! example "Examples"
|
|
539
|
-
Basic setup and
|
|
539
|
+
Basic setup and usage:
|
|
540
540
|
```python
|
|
541
541
|
from langgraph.store.postgres import PostgresStore
|
|
542
|
+
from psycopg import Connection
|
|
542
543
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
544
|
+
conn_string = "postgresql://user:pass@localhost:5432/dbname"
|
|
545
|
+
|
|
546
|
+
# Using direct connection
|
|
547
|
+
with Connection.connect(conn_string) as conn:
|
|
548
|
+
store = PostgresStore(conn)
|
|
549
|
+
store.setup() # Run migrations. Done once
|
|
547
550
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
+
# Store and retrieve data
|
|
552
|
+
store.put(("users", "123"), "prefs", {"theme": "dark"})
|
|
553
|
+
item = store.get(("users", "123"), "prefs")
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
Or using the convenient from_conn_string helper:
|
|
557
|
+
```python
|
|
558
|
+
from langgraph.store.postgres import PostgresStore
|
|
559
|
+
|
|
560
|
+
conn_string = "postgresql://user:pass@localhost:5432/dbname"
|
|
561
|
+
|
|
562
|
+
with PostgresStore.from_conn_string(conn_string) as store:
|
|
563
|
+
store.setup()
|
|
564
|
+
|
|
565
|
+
# Store and retrieve data
|
|
566
|
+
store.put(("users", "123"), "prefs", {"theme": "dark"})
|
|
567
|
+
item = store.get(("users", "123"), "prefs")
|
|
551
568
|
```
|
|
552
569
|
|
|
553
570
|
Vector search using LangChain embeddings:
|
|
@@ -555,23 +572,25 @@ class PostgresStore(BaseStore, BasePostgresStore[_pg_internal.Conn]):
|
|
|
555
572
|
from langchain.embeddings import init_embeddings
|
|
556
573
|
from langgraph.store.postgres import PostgresStore
|
|
557
574
|
|
|
558
|
-
|
|
559
|
-
|
|
575
|
+
conn_string = "postgresql://user:pass@localhost:5432/dbname"
|
|
576
|
+
|
|
577
|
+
with PostgresStore.from_conn_string(
|
|
578
|
+
conn_string,
|
|
560
579
|
index={
|
|
561
580
|
"dims": 1536,
|
|
562
581
|
"embed": init_embeddings("openai:text-embedding-3-small"),
|
|
563
582
|
"fields": ["text"] # specify which fields to embed. Default is the whole serialized value
|
|
564
583
|
}
|
|
565
|
-
)
|
|
566
|
-
|
|
584
|
+
) as store:
|
|
585
|
+
store.setup() # Do this once to run migrations
|
|
567
586
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
587
|
+
# Store documents
|
|
588
|
+
store.put(("docs",), "doc1", {"text": "Python tutorial"})
|
|
589
|
+
store.put(("docs",), "doc2", {"text": "TypeScript guide"})
|
|
590
|
+
store.put(("docs",), "doc2", {"text": "Other guide"}, index=False) # don't index
|
|
572
591
|
|
|
573
|
-
|
|
574
|
-
|
|
592
|
+
# Search by similarity
|
|
593
|
+
results = store.search(("docs",), "programming guides", limit=2)
|
|
575
594
|
```
|
|
576
595
|
|
|
577
596
|
Note:
|
{langgraph_checkpoint_postgres-2.0.13 → langgraph_checkpoint_postgres-2.0.15}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "langgraph-checkpoint-postgres"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.15"
|
|
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.15"
|
|
14
14
|
orjson = ">=3.10.1"
|
|
15
15
|
psycopg = "^3.2.0"
|
|
16
16
|
psycopg-pool = "^3.2.0"
|
|
@@ -22,10 +22,10 @@ pytest = "^7.2.1"
|
|
|
22
22
|
anyio = "^4.4.0"
|
|
23
23
|
pytest-asyncio = "^0.21.1"
|
|
24
24
|
pytest-mock = "^3.11.1"
|
|
25
|
-
pytest-watch = "^4.2.0"
|
|
26
25
|
mypy = "^1.10.0"
|
|
27
26
|
psycopg = {extras = ["binary"], version = ">=3.0.0"}
|
|
28
27
|
langgraph-checkpoint = {path = "../checkpoint", develop = true}
|
|
28
|
+
pytest-watcher = "^0.4.3"
|
|
29
29
|
|
|
30
30
|
[tool.pytest.ini_options]
|
|
31
31
|
# --strict-markers will raise errors on unknown marks.
|
|
@@ -61,3 +61,9 @@ warn_unused_ignores = "True"
|
|
|
61
61
|
warn_redundant_casts = "True"
|
|
62
62
|
allow_redefinition = "True"
|
|
63
63
|
disable_error_code = "typeddict-item, return-value"
|
|
64
|
+
|
|
65
|
+
[tool.pytest-watcher]
|
|
66
|
+
now = true
|
|
67
|
+
delay = 0.1
|
|
68
|
+
runner_args = ["--ff", "-x", "-v", "--tb", "short"]
|
|
69
|
+
patterns = ["*.py"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|