Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add delete group endpoint #132

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "graphiti-core"
version = "0.3.3"
version = "0.3.4"
description = "A temporal graph building library"
authors = [
"Paul Paliychuk <paul@getzep.com>",
Expand Down
6 changes: 6 additions & 0 deletions server/graph_service/routers/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ async def delete_entity_edge(uuid: str, graphiti: ZepGraphitiDep):
return Result(message='Entity Edge deleted', success=True)


@router.delete('/group/{group_id}', status_code=status.HTTP_200_OK)
async def delete_group(group_id: str, graphiti: ZepGraphitiDep):
await graphiti.delete_group(group_id)
return Result(message='Group deleted', success=True)


@router.delete('/episode/{uuid}', status_code=status.HTTP_200_OK)
async def delete_episode(uuid: str, graphiti: ZepGraphitiDep):
await graphiti.delete_episodic_node(uuid)
Expand Down
14 changes: 14 additions & 0 deletions server/graph_service/zep_graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ async def get_entity_edge(self, uuid: str):
except EdgeNotFoundError as e:
raise HTTPException(status_code=404, detail=e.message) from e

async def delete_group(self, group_id: str):
try:
edges = await EntityEdge.get_by_group_ids(self.driver, [group_id])
nodes = await EntityNode.get_by_group_ids(self.driver, [group_id])
episodes = await EpisodicNode.get_by_group_ids(self.driver, [group_id])
for edge in edges:
await edge.delete(self.driver)
for node in nodes:
await node.delete(self.driver)
for episode in episodes:
await episode.delete(self.driver)
except EdgeNotFoundError as e:
raise HTTPException(status_code=404, detail=e.message) from e

async def delete_entity_edge(self, uuid: str):
try:
edge = await EntityEdge.get_by_uuid(self.driver, uuid)
Expand Down