diff --git a/graphiti_core/graphiti.py b/graphiti_core/graphiti.py index 74d5edec..0f428f51 100644 --- a/graphiti_core/graphiti.py +++ b/graphiti_core/graphiti.py @@ -318,17 +318,21 @@ async def add_episode_endpoint(episode_data: EpisodeData): previous_episodes = await self.retrieve_episodes( reference_time, last_n=RELEVANT_SCHEMA_LIMIT, group_ids=[group_id] ) - episode = EpisodicNode( - name=name, - group_id=group_id, - labels=[], - source=source, - content=episode_body, - source_description=source_description, - created_at=now, - valid_at=reference_time, + + episode = ( + await EpisodicNode.get_by_uuid(self.driver, uuid) + if uuid is not None + else EpisodicNode( + name=name, + group_id=group_id, + labels=[], + source=source, + content=episode_body, + source_description=source_description, + created_at=now, + valid_at=reference_time, + ) ) - episode.uuid = uuid if uuid is not None else episode.uuid # Extract entities as nodes