Skip to content

Commit 84ac45a

Browse files
committed
Renamed JSONRepairError to InvalidJSONError
1 parent 87524f4 commit 84ac45a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

docs/source/api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ PipelineStatusUpdateError
511511
:show-inheritance:
512512

513513

514-
JSONRepairError
515-
===============
514+
InvalidJSONError
515+
================
516516

517-
.. autoclass:: neo4j_graphrag.experimental.pipeline.exceptions.JSONRepairError
517+
.. autoclass:: neo4j_graphrag.experimental.pipeline.exceptions.InvalidJSONError
518518
:show-inheritance:

src/neo4j_graphrag/experimental/components/entity_relation_extractor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
TextChunks,
3838
)
3939
from neo4j_graphrag.experimental.pipeline.component import Component
40-
from neo4j_graphrag.experimental.pipeline.exceptions import JSONRepairError
40+
from neo4j_graphrag.experimental.pipeline.exceptions import InvalidJSONError
4141
from neo4j_graphrag.generation.prompts import ERExtractionTemplate, PromptTemplate
4242
from neo4j_graphrag.llm import LLMInterface
4343

@@ -111,9 +111,9 @@ def fix_invalid_json(raw_json: str) -> str:
111111
repaired_json = ""
112112

113113
if repaired_json == '""':
114-
raise JSONRepairError("JSON repair resulted in an empty or invalid JSON.")
114+
raise InvalidJSONError("JSON repair resulted in an empty or invalid JSON.")
115115
if not repaired_json:
116-
raise JSONRepairError("JSON repair resulted in an empty string.")
116+
raise InvalidJSONError("JSON repair resulted in an empty string.")
117117
return repaired_json
118118

119119

@@ -218,7 +218,7 @@ async def extract_for_chunk(
218218
try:
219219
llm_generated_json = fix_invalid_json(llm_result.content)
220220
result = json.loads(llm_generated_json)
221-
except (json.JSONDecodeError, JSONRepairError) as e:
221+
except (json.JSONDecodeError, InvalidJSONError) as e:
222222
if self.on_error == OnError.RAISE:
223223
raise LLMGenerationError(
224224
f"LLM response is not valid JSON {llm_result.content}: {e}"

src/neo4j_graphrag/experimental/pipeline/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class PipelineStatusUpdateError(Neo4jGraphRagError):
3333
pass
3434

3535

36-
class JSONRepairError(Neo4jGraphRagError):
36+
class InvalidJSONError(Neo4jGraphRagError):
3737
"""Raised when JSON repair fails to produce valid JSON."""
3838

3939
pass

tests/unit/experimental/components/test_entity_relation_extractor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
TextChunk,
3232
TextChunks,
3333
)
34-
from neo4j_graphrag.experimental.pipeline.exceptions import JSONRepairError
34+
from neo4j_graphrag.experimental.pipeline.exceptions import InvalidJSONError
3535
from neo4j_graphrag.llm import LLMInterface, LLMResponse
3636

3737

@@ -215,7 +215,7 @@ def test_fix_invalid_json_empty_result() -> None:
215215
json_string = "invalid json"
216216

217217
with patch("json_repair.repair_json", return_value=""):
218-
with pytest.raises(JSONRepairError):
218+
with pytest.raises(InvalidJSONError):
219219
fix_invalid_json(json_string)
220220

221221

0 commit comments

Comments
 (0)