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: async close and multi-group search support #151

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions graphiti_core/graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(
else:
self.llm_client = OpenAIClient()

def close(self):
async def close(self):
"""
Close the connection to the Neo4j database.

Expand Down Expand Up @@ -159,7 +159,7 @@ def close(self):
finally:
graphiti.close()
"""
self.driver.close()
await self.driver.close()

async def build_indices_and_constraints(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion server/graph_service/dto/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class SearchQuery(BaseModel):
group_id: str = Field(..., description='The group id of the memory to get')
group_ids: list[str] = Field(description='The group ids for the memories to search')
query: str
max_facts: int = Field(default=10, description='The maximum number of facts to retrieve')

Expand Down
2 changes: 1 addition & 1 deletion server/graph_service/routers/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@router.post('/search', status_code=status.HTTP_200_OK)
async def search(query: SearchQuery, graphiti: ZepGraphitiDep):
relevant_edges = await graphiti.search(
group_ids=[query.group_id],
group_ids=query.group_ids,
query=query.query,
num_results=query.max_facts,
)
Expand Down
2 changes: 1 addition & 1 deletion server/graph_service/zep_graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def get_graphiti(settings: ZepEnvDep):
try:
yield client
finally:
client.close()
await client.close()


async def initialize_graphiti(settings: ZepEnvDep):
Expand Down
Loading