Skip to content

Commit

Permalink
Update search method to return EntityEdge objects
Browse files Browse the repository at this point in the history
---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/getzep/graphiti?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
danielchalef committed Aug 26, 2024
1 parent 598e9fd commit d15b597
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
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

0 comments on commit d15b597

Please sign in to comment.