From 911460429c8e95effc0c2b2b0c13398fd1f7b1fb Mon Sep 17 00:00:00 2001
From: Igor Ilic <30923996+dexters1@users.noreply.github.com>
Date: Mon, 11 Nov 2024 23:57:46 +0100
Subject: [PATCH] fix: Fix GraphRAG notebook V2 (#16913)

---
 docs/docs/examples/cookbooks/GraphRAG_v2.ipynb | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/docs/docs/examples/cookbooks/GraphRAG_v2.ipynb b/docs/docs/examples/cookbooks/GraphRAG_v2.ipynb
index 8c01fa8ef5..d80b1bd024 100644
--- a/docs/docs/examples/cookbooks/GraphRAG_v2.ipynb
+++ b/docs/docs/examples/cookbooks/GraphRAG_v2.ipynb
@@ -32,7 +32,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "!pip install llama-index llama-index-graph-stores-neo4j graspologic numpy==1.24.4 scipy==1.12.0"
+    "!pip install llama-index llama-index-graph-stores-neo4j graspologic numpy==1.24.4 scipy==1.12.0 future"
    ]
   },
   {
@@ -628,10 +628,14 @@
     "        ).retrieve(query_str)\n",
     "\n",
     "        enitites = set()\n",
-    "        pattern = r\"(\\w+(?:\\s+\\w+)*)\\s*\\({[^}]*}\\)\\s*->\\s*([^(]+?)\\s*\\({[^}]*}\\)\\s*->\\s*(\\w+(?:\\s+\\w+)*)\"\n",
+    "        pattern = (\n",
+    "            r\"^(\\w+(?:\\s+\\w+)*)\\s*->\\s*([a-zA-Z\\s]+?)\\s*->\\s*(\\w+(?:\\s+\\w+)*)$\"\n",
+    "        )\n",
     "\n",
     "        for node in nodes_retrieved:\n",
-    "            matches = re.findall(pattern, node.text, re.DOTALL)\n",
+    "            matches = re.findall(\n",
+    "                pattern, node.text, re.MULTILINE | re.IGNORECASE\n",
+    "            )\n",
     "\n",
     "            for match in matches:\n",
     "                subject = match[0]\n",
-- 
GitLab