From f9e87006c19d42f83cdebfa742af185e7a242188 Mon Sep 17 00:00:00 2001 From: Guodong Date: Fri, 18 Oct 2024 18:37:29 +0800 Subject: [PATCH 1/3] fix notification --- .../neo4j/neo4j_property_graph.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py b/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py index 35a71a7d11865..c8e87d8b3d7a1 100644 --- a/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py +++ b/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py @@ -251,7 +251,7 @@ def refresh_schema(self) -> None: "metadata": {"constraint": constraint, "index": index}, } schema_counts = self.structured_query( - "CALL apoc.meta.graphSample() YIELD nodes, relationships " + "CALL apoc.meta.subGraph({}) YIELD nodes, relationships " "RETURN nodes, [rel in relationships | {name:apoc.any.property" "(rel, 'type'), count: apoc.any.property(rel, 'count')}]" " AS relationships" @@ -341,8 +341,7 @@ def upsert_nodes(self, nodes: List[LabelledNode]) -> None: CALL apoc.create.addLabels(e, [row.label]) YIELD node WITH e, row - CALL {{ - WITH e, row + CALL (e, row) {{ WITH e, row WHERE row.embedding IS NOT NULL CALL db.create.setNodeVectorProperty(e, 'embedding', row.embedding) @@ -463,7 +462,7 @@ def get_triplets( return_statement = f""" WITH e - CALL {{ + CALL (e) {{ WITH e MATCH (e)-[r{':`' + '`|`'.join(relation_names) + '`' if relation_names else ''}]->(t:`{BASE_ENTITY_LABEL}`) RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['{BASE_ENTITY_LABEL}', '{BASE_NODE_LABEL}'] | l][0] AS source_type, @@ -739,7 +738,7 @@ def _enhanced_schema_cypher( prop_type = prop["type"] if prop_type == "STRING": with_clauses.append( - f"collect(distinct substring(toString(n.`{prop_name}`), 0, 50)) " + f"collect(distinct substring(toString(coalesce(n.`{prop_name}`, '')), 0, 50)) " # noqa f"AS `{prop_name}_values`" ) return_clauses.append( @@ -765,8 +764,8 @@ def _enhanced_schema_cypher( ) elif prop_type == "LIST": with_clauses.append( - f"min(size(n.`{prop_name}`)) AS `{prop_name}_size_min`, " - f"max(size(n.`{prop_name}`)) AS `{prop_name}_size_max`" + f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, " # noqa + f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`" # noqa ) return_clauses.append( f"min_size: `{prop_name}_size_min`, " @@ -819,7 +818,7 @@ def _enhanced_schema_cypher( ]: if not prop_index: with_clauses.append( - f"collect(distinct toString(n.`{prop_name}`)) " + f"collect(distinct toString(coalesce(n.`{prop_name}`, ''))) " # noqa f"AS `{prop_name}_values`" ) return_clauses.append(f"values: `{prop_name}_values`") @@ -841,8 +840,8 @@ def _enhanced_schema_cypher( elif prop_type == "LIST": with_clauses.append( - f"min(size(n.`{prop_name}`)) AS `{prop_name}_size_min`, " - f"max(size(n.`{prop_name}`)) AS `{prop_name}_size_max`" + f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, " # noqa + f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`" # noqa ) return_clauses.append( f"min_size: `{prop_name}_size_min`, " From ad88cbab6f1801d2fc917a554a6bda27e6724349 Mon Sep 17 00:00:00 2001 From: Guodong Date: Fri, 18 Oct 2024 18:38:17 +0800 Subject: [PATCH 2/3] bump version --- .../graph_stores/llama-index-graph-stores-neo4j/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/pyproject.toml b/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/pyproject.toml index 39c96a53a20d1..8655453c43702 100644 --- a/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/pyproject.toml +++ b/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/pyproject.toml @@ -28,7 +28,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-graph-stores-neo4j" readme = "README.md" -version = "0.3.3" +version = "0.3.4" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" From 900f830c7a90ce3208471fd89aa1a52d59ab1221 Mon Sep 17 00:00:00 2001 From: Guodong Date: Fri, 18 Oct 2024 23:41:43 +0800 Subject: [PATCH 3/3] rm noqa --- .../graph_stores/neo4j/neo4j_property_graph.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py b/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py index c8e87d8b3d7a1..30b00da042bd4 100644 --- a/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py +++ b/llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/llama_index/graph_stores/neo4j/neo4j_property_graph.py @@ -738,7 +738,7 @@ def _enhanced_schema_cypher( prop_type = prop["type"] if prop_type == "STRING": with_clauses.append( - f"collect(distinct substring(toString(coalesce(n.`{prop_name}`, '')), 0, 50)) " # noqa + f"collect(distinct substring(toString(coalesce(n.`{prop_name}`, '')), 0, 50)) " f"AS `{prop_name}_values`" ) return_clauses.append( @@ -764,8 +764,8 @@ def _enhanced_schema_cypher( ) elif prop_type == "LIST": with_clauses.append( - f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, " # noqa - f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`" # noqa + f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, " + f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`" ) return_clauses.append( f"min_size: `{prop_name}_size_min`, " @@ -818,7 +818,7 @@ def _enhanced_schema_cypher( ]: if not prop_index: with_clauses.append( - f"collect(distinct toString(coalesce(n.`{prop_name}`, ''))) " # noqa + f"collect(distinct toString(coalesce(n.`{prop_name}`, ''))) " f"AS `{prop_name}_values`" ) return_clauses.append(f"values: `{prop_name}_values`") @@ -840,8 +840,8 @@ def _enhanced_schema_cypher( elif prop_type == "LIST": with_clauses.append( - f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, " # noqa - f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`" # noqa + f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, " + f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`" ) return_clauses.append( f"min_size: `{prop_name}_size_min`, "