From 59a493847c846f978cdf2b66360daf9a640847b4 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:19:47 +0100 Subject: [PATCH 1/2] Fix search --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b72609b5b..35f230db6 100644 --- a/README.md +++ b/README.md @@ -110,12 +110,33 @@ poetry add cognee ## 💻 Usage +- Add a new piece of information to storage +``` +import cognee +cognee.add(data_path, file_name) +``` -```cognee.add()``` - Add a new piece of information to storage +- Use LLMs and cognee to create graphs + +``` +cognee.cognify(file_name) + ``` -```cognee.cognify() ``` - Use LLMs to create graphs +- Render the graph after adding your Graphistry credentials to .env -```cognee.search()``` - Query the graph for a piece of information +``` +graph_url = await render_graph(graph, graph_type = "networkx") +print(graph_url) +``` + +- Query the graph for a piece of information + +``` +query_params = { + SearchType.SIMILARITY: {'query': 'your search query here'} +} +cognee.search(graph, query_params) +``` ## Demo From 13551dacf1c9fa1d2be2e7aa92978c36341cdbb3 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:41:43 +0100 Subject: [PATCH 2/2] Add docs --- cognee/api/v1/search/search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cognee/api/v1/search/search.py b/cognee/api/v1/search/search.py index 5b0719714..7591f10f7 100644 --- a/cognee/api/v1/search/search.py +++ b/cognee/api/v1/search/search.py @@ -17,7 +17,7 @@ class SearchType(Enum): NEIGHBOR = auto() -async def complex_search(graph, query_params: Dict[SearchType, Dict[str, Any]]) -> List: +async def search(graph, query_params: Dict[SearchType, Dict[str, Any]]) -> List: search_functions: Dict[SearchType, Callable] = { SearchType.ADJACENT: search_adjacent, SearchType.SIMILARITY: search_similarity, @@ -61,7 +61,7 @@ if __name__ == "__main__": await graph_client.load_graph_from_file() graph = graph_client.graph - results = await complex_search(graph, query_params) + results = await search(graph, query_params) print(results) asyncio.run(main())