Get Most Relevant Facts for an Arbitrary Query

In this recipe, we demonstrate how to retrieve the most relevant facts from the knowledge graph using an arbitrary search query.

First, we perform a search on the knowledge graph using a sample query:

1zep_client = AsyncZep(api_key=API_KEY)
2results = await client.graph.search(user_id="some user_id", query="Some search query", scope="edges")

Then, we get the edges from the search results and construct our fact list with list comprehension:

1relevant_edges = results.edges
2facts_list = [edge.fact for edge in relevant_edges]
3for fact in facts_list:
4 print(fact)

We demonstrated how to retrieve the most relevant facts for an arbitrary query using the Zep client. Adjust the query and parameters as needed to tailor the search for your specific use case.

Built with