Skip to content

Commit c54b66a

Browse files
committed
Cleaning + update example
1 parent 05e7713 commit c54b66a

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

examples/customize/build_graph/components/pruners/graph_pruner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Neo4jNode(
4242
id="Organization/Corp1",
4343
label="Organization",
44-
properties={"name": "CorpA"},
44+
properties={"name": "Corp1"},
4545
),
4646
],
4747
relationships=[
@@ -51,7 +51,7 @@
5151
type="KNOWS",
5252
),
5353
Neo4jRelationship(
54-
start_node_id="Organization/CorpA",
54+
start_node_id="Organization/Corp2",
5555
end_node_id="Person/Jack",
5656
type="WORKS_FOR",
5757
),
@@ -80,12 +80,14 @@
8080
PropertyType(name="name", type="STRING", required=True),
8181
PropertyType(name="address", type="STRING"),
8282
],
83+
additional_properties=True,
8384
),
8485
),
8586
relationship_types=(
8687
RelationshipType(
8788
label="WORKS_FOR",
8889
properties=[PropertyType(name="since", type="LOCAL_DATETIME")],
90+
additional_properties=True,
8991
),
9092
RelationshipType(
9193
label="KNOWS",

src/neo4j_graphrag/experimental/components/schema.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def validate_additional_properties(self) -> Self:
106106
if len(self.properties) == 0 and not self.additional_properties:
107107
raise ValueError(
108108
"Using `additional_properties=False` with no defined "
109-
"properties will cause the model to be pruned during graph cleaning.",
109+
"properties will cause the model to be pruned during graph cleaning. "
110+
f"Define some properties or remove this NodeType: {self}"
110111
)
111112
return self
112113

@@ -135,7 +136,8 @@ def validate_additional_properties(self) -> Self:
135136
if len(self.properties) == 0 and not self.additional_properties:
136137
raise ValueError(
137138
"Using `additional_properties=False` with no defined "
138-
"properties will cause the model to be pruned during graph cleaning.",
139+
"properties will cause the model to be pruned during graph cleaning. "
140+
f"Define some properties or remove this RelationshipType: {self}"
139141
)
140142
return self
141143

@@ -218,20 +220,6 @@ def validate_additional_parameters(self) -> Self:
218220
)
219221
return self
220222

221-
@classmethod
222-
def default_additional_node_types(cls, validated_data: dict[str, Any]) -> bool:
223-
return len(validated_data["node_types"]) == 0
224-
225-
@classmethod
226-
def default_additional_relationship_types(
227-
cls, validated_data: dict[str, Any]
228-
) -> bool:
229-
return len(validated_data["relationship_types"]) == 0
230-
231-
@classmethod
232-
def default_additional_patterns(cls, validated_data: dict[str, Any]) -> bool:
233-
return len(validated_data["patterns"]) == 0
234-
235223
def node_type_from_label(self, label: str) -> Optional[NodeType]:
236224
return self._node_type_index.get(label)
237225

0 commit comments

Comments
 (0)