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

Update search method to return EntityEdge objects #48

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions graphiti_core/graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ async def search(self, query: str, center_node_uuid: str | None = None, num_resu
Returns
-------
list
A list of facts (strings) that are relevant to the search query.
A list of EntityEdge objects that are relevant to the search query.
Notes
-----
Expand Down Expand Up @@ -564,9 +564,7 @@ async def search(self, query: str, center_node_uuid: str | None = None, num_resu
)
).edges

facts = [edge.fact for edge in edges]

return facts
return edges

async def _search(
self,
Expand Down
12 changes: 6 additions & 6 deletions tests/test_graphiti_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ async def test_graphiti_init():
logger = setup_logging()
graphiti = Graphiti(NEO4J_URI, NEO4j_USER, NEO4j_PASSWORD, None)

facts = await graphiti.search('Freakenomics guest')
edges = await graphiti.search('Freakenomics guest')

logger.info('\nQUERY: Freakenomics guest\n' + format_context(facts))
logger.info('\nQUERY: Freakenomics guest\n' + format_context([edge.fact for edge in edges]))

facts = await graphiti.search('tania tetlow\n')
edges = await graphiti.search('tania tetlow\n')

logger.info('\nQUERY: Tania Tetlow\n' + format_context(facts))
logger.info('\nQUERY: Tania Tetlow\n' + format_context([edge.fact for edge in edges]))

facts = await graphiti.search('issues with higher ed')
edges = await graphiti.search('issues with higher ed')

logger.info('\nQUERY: issues with higher ed\n' + format_context(facts))
logger.info('\nQUERY: issues with higher ed\n' + format_context([edge.fact for edge in edges]))
graphiti.close()


Expand Down