From 9ec292aac5a9e553407874a2e2f06ec86e828f7f Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Wed, 9 Oct 2024 17:52:29 +0200 Subject: [PATCH] refactor: Add other search types to notebook Added other search types and explanations to jupyter notebook refactor #COG-387 --- notebooks/cognee_demo.ipynb | 70 ++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/notebooks/cognee_demo.ipynb b/notebooks/cognee_demo.ipynb index ac4f159be..302fbb34f 100644 --- a/notebooks/cognee_demo.ipynb +++ b/notebooks/cognee_demo.ipynb @@ -712,7 +712,75 @@ "id": "81fa2b00", "metadata": {}, "source": [ - "#### We normalize search output scores so the lower the score of the search result is the higher the chance that it's what you're looking for." + "#### We normalize search output scores so the lower the score of the search result is the higher the chance that it's what you're looking for. In the example above we have searched for node entities in the knowledge graph related to \"sarah.nguyen@example.com\"" + ] + }, + { + "cell_type": "markdown", + "id": "1b94ff96", + "metadata": {}, + "source": [ + "#### In the example bellow we'll use cognee search to summarize information regarding the node most related to \"sarah.nguyen@example.com\" in the knowledge graph" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "21a3e9a6", + "metadata": {}, + "outputs": [], + "source": [ + "from cognee.api.v1.search import SearchType\n", + "\n", + "node = (await vector_engine.search(\"entities\", \"sarah.nguyen@example.com\"))[0]\n", + "node_name = node.payload[\"name\"]\n", + "\n", + "search_results = await cognee.search(SearchType.SUMMARIES, query = random_node_name)\n", + "print(\"\\n\\Extracted summaries are:\\n\")\n", + "for result in search_results:\n", + " print(f\"{result}\\n\")" + ] + }, + { + "cell_type": "markdown", + "id": "fd6e5fe2", + "metadata": {}, + "source": [ + "#### In this example we'll use cognee search to find chunks in which the node most related to \"sarah.nguyen@example.com\" is a part of" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c7a8abff", + "metadata": {}, + "outputs": [], + "source": [ + "search_results = await cognee.search(SearchType.CHUNKS, query = random_node_name)\n", + "print(\"\\n\\nExtracted chunks are:\\n\")\n", + "for result in search_results:\n", + " print(f\"{result}\\n\")" + ] + }, + { + "cell_type": "markdown", + "id": "47f0112f", + "metadata": {}, + "source": [ + "#### In this example we'll use cognee search to give us insights from the knowledge graph related to the node most related to \"sarah.nguyen@example.com\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "706a3954", + "metadata": {}, + "outputs": [], + "source": [ + "search_results = await cognee.search(SearchType.INSIGHTS, query = random_node_name)\n", + "print(\"\\n\\nExtracted sentences are:\\n\")\n", + "for result in search_results:\n", + " print(f\"{result}\\n\")" ] }, {