Skip to content

Commit

Permalink
Change field value from "CONTINUE" to "IGNORE" to match enum field na…
Browse files Browse the repository at this point in the history
…me (neo4j#171)

* Change field value from "IGNORE" to "CONTINUE" to match enum field name

* Update CHANGELOG.md
  • Loading branch information
stellasia authored Oct 8, 2024
1 parent 86f88bf commit d5d1070
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### Fixed
- Fix a bug where `openai` Python client and `numpy` were required to import any embedder or LLM.

### Changed
- The value associated to the enum field `OnError.IGNORE` has been changed from "CONTINUE" to "IGNORE" to stick to the convention and match the field name.

## 1.0.0a1

## 1.0.0a0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@

class OnError(enum.Enum):
RAISE = "RAISE"
IGNORE = "CONTINUE"
IGNORE = "IGNORE"

@classmethod
def possible_values(cls) -> List[str]:
return [e.value for e in cls]


CHUNK_NODE_LABEL = "Chunk"
Expand Down
6 changes: 3 additions & 3 deletions src/neo4j_graphrag/experimental/pipeline/kg_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class SimpleKGPipeline:
text_splitter (Optional[Any]): A text splitter component. Defaults to FixedSizeSplitter().
pdf_loader (Optional[Any]): A PDF loader component. Defaults to PdfLoader().
kg_writer (Optional[Any]): A knowledge graph writer component. Defaults to Neo4jWriter().
on_error (str): Error handling strategy. Defaults to "CONTINUE". Possible values: "RAISE" or "CONTINUE".
on_error (str): Error handling strategy for the Entity and relation extractor. Defaults to "IGNORE", where chunk will be ignored if extraction fails. Possible values: "RAISE" or "IGNORE".
perform_entity_resolution (bool): Merge entities with same label and name. Default: True
prompt_template (str): A custom prompt template to use for extraction.
"""
Expand All @@ -98,7 +98,7 @@ def __init__(
text_splitter: Optional[Any] = None,
pdf_loader: Optional[Any] = None,
kg_writer: Optional[Any] = None,
on_error: str = "CONTINUE",
on_error: str = "IGNORE",
prompt_template: Union[ERExtractionTemplate, str] = ERExtractionTemplate(),
perform_entity_resolution: bool = True,
):
Expand All @@ -110,7 +110,7 @@ def __init__(
on_error_enum = OnError(on_error)
except ValueError:
raise PipelineDefinitionError(
f"Invalid value for on_error: {on_error}. Expected 'RAISE' or 'CONTINUE'."
f"Invalid value for on_error: {on_error}. Expected one of {OnError.possible_values()}."
)

config = SimpleKGPipelineConfig(
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/experimental/pipeline/test_kg_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ def test_simple_kg_pipeline_on_error_invalid_value() -> None:
llm=llm,
driver=driver,
embedder=embedder,
on_error="IGNORE",
on_error="INVALID_VALUE",
)

assert "Expected 'RAISE' or 'CONTINUE'" in str(exc_info.value)
assert "Expected one of ['RAISE', 'IGNORE']" in str(exc_info.value)


def test_simple_kg_pipeline_no_entity_resolution() -> None:
Expand All @@ -274,7 +274,7 @@ def test_simple_kg_pipeline_no_entity_resolution() -> None:
llm=llm,
driver=driver,
embedder=embedder,
on_error="CONTINUE",
on_error="IGNORE",
perform_entity_resolution=False,
)

Expand Down

0 comments on commit d5d1070

Please sign in to comment.