langgraph-checkpoint-postgres 2.0.0__tar.gz → 2.0.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langgraph-checkpoint-postgres
3
- Version: 2.0.0
3
+ Version: 2.0.1
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
@@ -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,7 +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__(deserializer=deserializer)
44
+ super().__init__()
45
+ self._deserializer = deserializer
42
46
  self.conn = conn
43
47
  self.conn = conn
44
48
  self.loop = asyncio.get_running_loop()
@@ -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(BaseStore, Generic[C]):
62
+ class BasePostgresStore(Generic[C]):
63
63
  MIGRATIONS = MIGRATIONS
64
64
  conn: C
65
- __slots__ = ("_deserializer",)
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
- query += " LIMIT %s OFFSET %s"
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__(deserializer=deserializer)
233
+ super().__init__()
234
+ self._deserializer = deserializer
240
235
  self.conn = conn
241
236
 
242
237
  def batch(self, ops: Iterable[Op]) -> list[Result]:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langgraph-checkpoint-postgres"
3
- version = "2.0.0"
3
+ version = "2.0.1"
4
4
  description = "Library with a Postgres implementation of LangGraph checkpoint saver."
5
5
  authors = []
6
6
  license = "MIT"