Use UUID as cursor (#335)

* update pagination

* update pagination

* Update graphiti_core/edges.py

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* uuid_cursor

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
Preston Rasmussen 2025-04-08 17:59:40 -04:00 committed by GitHub
parent 65b5eeae88
commit 6c0def79d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 25 deletions

View file

@ -143,9 +143,9 @@ class EpisodicEdge(Edge):
driver: AsyncDriver,
group_ids: list[str],
limit: int | None = None,
created_at: datetime | None = None,
uuid_cursor: str | None = None,
):
cursor_query: LiteralString = 'AND e.created_at < $created_at' if created_at else ''
cursor_query: LiteralString = 'AND e.uuid < $uuid' if uuid_cursor else ''
limit_query: LiteralString = 'LIMIT $limit' if limit is not None else ''
records, _, _ = await driver.execute_query(
@ -161,11 +161,11 @@ class EpisodicEdge(Edge):
n.uuid AS source_node_uuid,
m.uuid AS target_node_uuid,
e.created_at AS created_at
ORDER BY e.created_at, e.uuid DESC
ORDER BY e.uuid DESC
"""
+ limit_query,
group_ids=group_ids,
created_at=created_at,
uuid=uuid_cursor,
limit=limit,
database_=DEFAULT_DATABASE,
routing_='r',
@ -297,9 +297,9 @@ class EntityEdge(Edge):
driver: AsyncDriver,
group_ids: list[str],
limit: int | None = None,
created_at: datetime | None = None,
uuid_cursor: str | None = None,
):
cursor_query: LiteralString = 'AND e.created_at < $created_at' if created_at else ''
cursor_query: LiteralString = 'AND e.uuid < $uuid' if uuid_cursor else ''
limit_query: LiteralString = 'LIMIT $limit' if limit is not None else ''
records, _, _ = await driver.execute_query(
@ -322,11 +322,11 @@ class EntityEdge(Edge):
e.expired_at AS expired_at,
e.valid_at AS valid_at,
e.invalid_at AS invalid_at
ORDER BY e.created_at, e.uuid DESC
ORDER BY e.uuid DESC
"""
+ limit_query,
group_ids=group_ids,
created_at=created_at,
uuid=uuid_cursor,
limit=limit,
database_=DEFAULT_DATABASE,
routing_='r',
@ -430,9 +430,9 @@ class CommunityEdge(Edge):
driver: AsyncDriver,
group_ids: list[str],
limit: int | None = None,
created_at: datetime | None = None,
uuid_cursor: str | None = None,
):
cursor_query: LiteralString = 'AND e.created_at < $created_at' if created_at else ''
cursor_query: LiteralString = 'AND e.uuid < $uuid' if uuid_cursor else ''
limit_query: LiteralString = 'LIMIT $limit' if limit is not None else ''
records, _, _ = await driver.execute_query(
@ -448,11 +448,11 @@ class CommunityEdge(Edge):
n.uuid AS source_node_uuid,
m.uuid AS target_node_uuid,
e.created_at AS created_at
ORDER BY e.created_at, e.uuid DESC
ORDER BY e.uuid DESC
"""
+ limit_query,
group_ids=group_ids,
created_at=created_at,
uuid=uuid_cursor,
limit=limit,
database_=DEFAULT_DATABASE,
routing_='r',

View file

@ -216,9 +216,9 @@ class EpisodicNode(Node):
driver: AsyncDriver,
group_ids: list[str],
limit: int | None = None,
created_at: datetime | None = None,
uuid_cursor: str | None = None,
):
cursor_query: LiteralString = 'AND e.created_at < $created_at' if created_at else ''
cursor_query: LiteralString = 'AND e.uuid < $uuid' if uuid_cursor else ''
limit_query: LiteralString = 'LIMIT $limit' if limit is not None else ''
records, _, _ = await driver.execute_query(
@ -237,11 +237,11 @@ class EpisodicNode(Node):
e.source_description AS source_description,
e.source AS source,
e.entity_edges AS entity_edges
ORDER BY e.created_at, e.uuid DESC
ORDER BY e.uuid DESC
"""
+ limit_query,
group_ids=group_ids,
created_at=created_at,
uuid=uuid_cursor,
limit=limit,
database_=DEFAULT_DATABASE,
routing_='r',
@ -348,9 +348,9 @@ class EntityNode(Node):
driver: AsyncDriver,
group_ids: list[str],
limit: int | None = None,
created_at: datetime | None = None,
uuid_cursor: str | None = None,
):
cursor_query: LiteralString = 'AND n.created_at < $created_at' if created_at else ''
cursor_query: LiteralString = 'AND n.uuid < $uuid' if uuid_cursor else ''
limit_query: LiteralString = 'LIMIT $limit' if limit is not None else ''
records, _, _ = await driver.execute_query(
@ -368,11 +368,11 @@ class EntityNode(Node):
n.summary AS summary,
labels(n) AS labels,
properties(n) AS attributes
ORDER BY n.created_at DESC
ORDER BY n.uuid DESC
"""
+ limit_query,
group_ids=group_ids,
created_at=created_at,
uuid=uuid_cursor,
limit=limit,
database_=DEFAULT_DATABASE,
routing_='r',
@ -465,9 +465,9 @@ class CommunityNode(Node):
driver: AsyncDriver,
group_ids: list[str],
limit: int | None = None,
created_at: datetime | None = None,
uuid_cursor: str | None = None,
):
cursor_query: LiteralString = 'AND n.created_at < $created_at' if created_at else ''
cursor_query: LiteralString = 'AND n.uuid < $uuid' if uuid_cursor else ''
limit_query: LiteralString = 'LIMIT $limit' if limit is not None else ''
records, _, _ = await driver.execute_query(
@ -483,11 +483,11 @@ class CommunityNode(Node):
n.group_id AS group_id,
n.created_at AS created_at,
n.summary AS summary
ORDER BY n.created_at DESC
ORDER BY n.uuid DESC
"""
+ limit_query,
group_ids=group_ids,
created_at=created_at,
uuid=uuid_cursor,
limit=limit,
database_=DEFAULT_DATABASE,
routing_='r',

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "graphiti-core"
version = "0.9.0"
version = "0.9.1"
description = "A temporal graph building library"
authors = [
"Paul Paliychuk <paul@getzep.com>",