Skip to content

Commit 4b32e45

Browse files
Add warning when schema enforcement is on but schema not provided
1 parent 9dc67d9 commit 4b32e45

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/neo4j_graphrag/experimental/components/entity_relation_extractor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,15 @@ def validate_chunk(
354354
Perform validation after entity and relation extraction:
355355
- Enforce schema if schema enforcement mode is on and schema is provided
356356
"""
357-
# if enforcing_schema is on and schema is provided, clean the graph
358-
return (
359-
self._clean_graph(chunk_graph, schema)
360-
if self.enforce_schema != SchemaEnforcementMode.NONE and schema.entities
361-
else chunk_graph
362-
)
357+
if self.enforce_schema != SchemaEnforcementMode.NONE:
358+
if not schema or not schema.entities: # schema is not provided
359+
logger.warning(
360+
"Schema enforcement is ON but the guiding schema is not provided."
361+
)
362+
else:
363+
# if enforcing_schema is on and schema is provided, clean the graph
364+
return self._clean_graph(chunk_graph, schema)
365+
return chunk_graph
363366

364367
def _clean_graph(
365368
self,

0 commit comments

Comments
 (0)