Skip to content

Commit

Permalink
add optional uuid field
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen15 committed Sep 6, 2024
1 parent cd36604 commit 81b69ad
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions graphiti_core/graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ async def build_indices_and_constraints(self):
await build_indices_and_constraints(self.driver)

async def retrieve_episodes(
self,
reference_time: datetime,
last_n: int = EPISODE_WINDOW_LEN,
group_ids: list[str | None] | None = None,
self,
reference_time: datetime,
last_n: int = EPISODE_WINDOW_LEN,
group_ids: list[str | None] | None = None,
) -> list[EpisodicNode]:
"""
Retrieve the last n episodic nodes from the graph.
Expand Down Expand Up @@ -207,13 +207,14 @@ async def retrieve_episodes(
return await retrieve_episodes(self.driver, reference_time, last_n, group_ids)

async def add_episode(
self,
name: str,
episode_body: str,
source_description: str,
reference_time: datetime,
source: EpisodeType = EpisodeType.message,
group_id: str | None = None,
self,
name: str,
episode_body: str,
source_description: str,
reference_time: datetime,
source: EpisodeType = EpisodeType.message,
group_id: str | None = None,
uuid: str = None

Check failure on line 217 in graphiti_core/graphiti.py

View workflow job for this annotation

GitHub Actions / mypy

assignment

Incompatible default for argument "uuid" (default has type "None", argument has type "str")

Check notice on line 217 in graphiti_core/graphiti.py

View workflow job for this annotation

GitHub Actions / mypy

Note

PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True

Check notice on line 217 in graphiti_core/graphiti.py

View workflow job for this annotation

GitHub Actions / mypy

Note

Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
):
"""
Process an episode and update the graph.
Expand Down Expand Up @@ -278,6 +279,7 @@ async def add_episode_endpoint(episode_data: EpisodeData):
created_at=now,
valid_at=reference_time,
)
episode.uuid = episode.uuid if uuid is None else uuid

# Extract entities as nodes

Expand Down Expand Up @@ -523,11 +525,11 @@ async def add_episode_bulk(self, bulk_episodes: list[RawEpisode], group_id: str
raise e

async def search(
self,
query: str,
center_node_uuid: str | None = None,
group_ids: list[str | None] | None = None,
num_results=10,
self,
query: str,
center_node_uuid: str | None = None,
group_ids: list[str | None] | None = None,
num_results=10,
):
"""
Perform a hybrid search on the knowledge graph.
Expand Down Expand Up @@ -583,21 +585,21 @@ async def search(
return edges

async def _search(
self,
query: str,
timestamp: datetime,
config: SearchConfig,
center_node_uuid: str | None = None,
self,
query: str,
timestamp: datetime,
config: SearchConfig,
center_node_uuid: str | None = None,
):
return await hybrid_search(
self.driver, self.llm_client.get_embedder(), query, timestamp, config, center_node_uuid
)

async def get_nodes_by_query(
self,
query: str,
group_ids: list[str | None] | None = None,
limit: int = RELEVANT_SCHEMA_LIMIT,
self,
query: str,
group_ids: list[str | None] | None = None,
limit: int = RELEVANT_SCHEMA_LIMIT,
) -> list[EntityNode]:
"""
Retrieve nodes from the graph database based on a text query.
Expand Down

0 comments on commit 81b69ad

Please sign in to comment.