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:
parent
80f288102a
commit
f91570a359
3 changed files with 14 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ from pydantic import BaseModel, Field
|
||||||
from typing_extensions import LiteralString
|
from typing_extensions import LiteralString
|
||||||
|
|
||||||
from graphiti_core.embedder import EmbedderClient
|
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.helpers import DEFAULT_DATABASE, parse_db_date
|
||||||
from graphiti_core.models.edges.edge_db_queries import (
|
from graphiti_core.models.edges.edge_db_queries import (
|
||||||
COMMUNITY_EDGE_SAVE,
|
COMMUNITY_EDGE_SAVE,
|
||||||
|
|
@ -261,6 +261,9 @@ class EntityEdge(Edge):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_by_uuids(cls, driver: AsyncDriver, uuids: list[str]):
|
async def get_by_uuids(cls, driver: AsyncDriver, uuids: list[str]):
|
||||||
|
if len(uuids) == 0:
|
||||||
|
return []
|
||||||
|
|
||||||
records, _, _ = await driver.execute_query(
|
records, _, _ = await driver.execute_query(
|
||||||
"""
|
"""
|
||||||
MATCH (n:Entity)-[e:RELATES_TO]->(m:Entity)
|
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]
|
edges = [get_entity_edge_from_record(record) for record in records]
|
||||||
|
|
||||||
if len(edges) == 0:
|
if len(edges) == 0:
|
||||||
raise EdgeNotFoundError(uuids[0])
|
raise EdgesNotFoundError(uuids)
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ class EdgeNotFoundError(GraphitiError):
|
||||||
super().__init__(self.message)
|
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):
|
class GroupsEdgesNotFoundError(GraphitiError):
|
||||||
"""Raised when no edges are found for a list of group ids."""
|
"""Raised when no edges are found for a list of group ids."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "graphiti-core"
|
name = "graphiti-core"
|
||||||
version = "0.8.3"
|
version = "0.8.4"
|
||||||
description = "A temporal graph building library"
|
description = "A temporal graph building library"
|
||||||
authors = [
|
authors = [
|
||||||
"Paul Paliychuk <paul@getzep.com>",
|
"Paul Paliychuk <paul@getzep.com>",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue