update get edges by uuids (#307)

* update get edges by uuids

* Update graphiti_core/errors.py

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

* remove sample test

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
Preston Rasmussen 2025-03-27 10:45:06 -04:00 committed by GitHub
parent 80f288102a
commit f91570a359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -26,7 +26,7 @@ from pydantic import BaseModel, Field
from typing_extensions import LiteralString
from graphiti_core.embedder import EmbedderClient
from graphiti_core.errors import EdgeNotFoundError, GroupsEdgesNotFoundError
from graphiti_core.errors import EdgeNotFoundError, EdgesNotFoundError, GroupsEdgesNotFoundError
from graphiti_core.helpers import DEFAULT_DATABASE, parse_db_date
from graphiti_core.models.edges.edge_db_queries import (
COMMUNITY_EDGE_SAVE,
@ -261,6 +261,9 @@ class EntityEdge(Edge):
@classmethod
async def get_by_uuids(cls, driver: AsyncDriver, uuids: list[str]):
if len(uuids) == 0:
return []
records, _, _ = await driver.execute_query(
"""
MATCH (n:Entity)-[e:RELATES_TO]->(m:Entity)
@ -287,7 +290,7 @@ class EntityEdge(Edge):
edges = [get_entity_edge_from_record(record) for record in records]
if len(edges) == 0:
raise EdgeNotFoundError(uuids[0])
raise EdgesNotFoundError(uuids)
return edges
@classmethod

View file

@ -27,6 +27,14 @@ class EdgeNotFoundError(GraphitiError):
super().__init__(self.message)
class EdgesNotFoundError(GraphitiError):
"""Raised when a list of edges is not found."""
def __init__(self, uuids: list[str]):
self.message = f'None of the edges for {uuids} were found.'
super().__init__(self.message)
class GroupsEdgesNotFoundError(GraphitiError):
"""Raised when no edges are found for a list of group ids."""

View file

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