parent
e83bcbb435
commit
daf14a6509
4 changed files with 30 additions and 7 deletions
|
|
@ -337,6 +337,32 @@ class EntityEdge(Edge):
|
||||||
raise GroupsEdgesNotFoundError(group_ids)
|
raise GroupsEdgesNotFoundError(group_ids)
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
async def get_by_node_uuid(cls, driver: AsyncDriver, node_uuid: str):
|
||||||
|
query: LiteralString = """
|
||||||
|
MATCH (n:Entity {uuid: $node_uuid})-[e:RELATES_TO]-(m:Entity)
|
||||||
|
RETURN DISTINCT
|
||||||
|
e.uuid AS uuid,
|
||||||
|
n.uuid AS source_node_uuid,
|
||||||
|
m.uuid AS target_node_uuid,
|
||||||
|
e.created_at AS created_at,
|
||||||
|
e.name AS name,
|
||||||
|
e.group_id AS group_id,
|
||||||
|
e.fact AS fact,
|
||||||
|
e.fact_embedding AS fact_embedding,
|
||||||
|
e.episodes AS episodes,
|
||||||
|
e.expired_at AS expired_at,
|
||||||
|
e.valid_at AS valid_at,
|
||||||
|
e.invalid_at AS invalid_at
|
||||||
|
"""
|
||||||
|
records, _, _ = await driver.execute_query(
|
||||||
|
query, node_uuid=node_uuid, database_=DEFAULT_DATABASE, routing_='r'
|
||||||
|
)
|
||||||
|
|
||||||
|
edges = [get_entity_edge_from_record(record) for record in records]
|
||||||
|
|
||||||
|
return edges
|
||||||
|
|
||||||
|
|
||||||
class CommunityEdge(Edge):
|
class CommunityEdge(Edge):
|
||||||
async def save(self, driver: AsyncDriver):
|
async def save(self, driver: AsyncDriver):
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ from graphiti_core.search.search_config_recipes import (
|
||||||
from graphiti_core.search.search_filters import SearchFilters
|
from graphiti_core.search.search_filters import SearchFilters
|
||||||
from graphiti_core.search.search_utils import (
|
from graphiti_core.search.search_utils import (
|
||||||
RELEVANT_SCHEMA_LIMIT,
|
RELEVANT_SCHEMA_LIMIT,
|
||||||
get_communities_by_nodes,
|
|
||||||
get_mentioned_nodes,
|
get_mentioned_nodes,
|
||||||
get_relevant_edges,
|
get_relevant_edges,
|
||||||
get_relevant_nodes,
|
get_relevant_nodes,
|
||||||
|
|
@ -708,7 +707,7 @@ class Graphiti:
|
||||||
bfs_origin_node_uuids,
|
bfs_origin_node_uuids,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_episode_mentions(self, episode_uuids: list[str]) -> SearchResults:
|
async def nodes_and_edges_by_episode(self, episode_uuids: list[str]) -> SearchResults:
|
||||||
episodes = await EpisodicNode.get_by_uuids(self.driver, episode_uuids)
|
episodes = await EpisodicNode.get_by_uuids(self.driver, episode_uuids)
|
||||||
|
|
||||||
edges_list = await semaphore_gather(
|
edges_list = await semaphore_gather(
|
||||||
|
|
@ -719,9 +718,7 @@ class Graphiti:
|
||||||
|
|
||||||
nodes = await get_mentioned_nodes(self.driver, episodes)
|
nodes = await get_mentioned_nodes(self.driver, episodes)
|
||||||
|
|
||||||
communities = await get_communities_by_nodes(self.driver, nodes)
|
return SearchResults(edges=edges, nodes=nodes, communities=[])
|
||||||
|
|
||||||
return SearchResults(edges=edges, nodes=nodes, communities=communities)
|
|
||||||
|
|
||||||
async def add_triplet(self, source_node: EntityNode, edge: EntityEdge, target_node: EntityNode):
|
async def add_triplet(self, source_node: EntityNode, edge: EntityEdge, target_node: EntityNode):
|
||||||
if source_node.name_embedding is None:
|
if source_node.name_embedding is None:
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ load_dotenv()
|
||||||
DEFAULT_DATABASE = os.getenv('DEFAULT_DATABASE', None)
|
DEFAULT_DATABASE = os.getenv('DEFAULT_DATABASE', None)
|
||||||
USE_PARALLEL_RUNTIME = bool(os.getenv('USE_PARALLEL_RUNTIME', False))
|
USE_PARALLEL_RUNTIME = bool(os.getenv('USE_PARALLEL_RUNTIME', False))
|
||||||
SEMAPHORE_LIMIT = int(os.getenv('SEMAPHORE_LIMIT', 20))
|
SEMAPHORE_LIMIT = int(os.getenv('SEMAPHORE_LIMIT', 20))
|
||||||
MAX_REFLEXION_ITERATIONS = 2
|
MAX_REFLEXION_ITERATIONS = int(os.getenv('MAX_REFLEXION_ITERATIONS', 2))
|
||||||
DEFAULT_PAGE_LIMIT = 20
|
DEFAULT_PAGE_LIMIT = 20
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "graphiti-core"
|
name = "graphiti-core"
|
||||||
version = "0.7.9"
|
version = "0.7.10"
|
||||||
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