File tree Expand file tree Collapse file tree 4 files changed +10
-10
lines changed
src/neo4j_graphrag/experimental
tests/unit/experimental/components Expand file tree Collapse file tree 4 files changed +10
-10
lines changed Original file line number Diff line number Diff 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:
Original file line number Diff line number Diff line change 3737 TextChunks ,
3838)
3939from 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
4141from neo4j_graphrag .generation .prompts import ERExtractionTemplate , PromptTemplate
4242from 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 } "
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 3131 TextChunk ,
3232 TextChunks ,
3333)
34- from neo4j_graphrag .experimental .pipeline .exceptions import JSONRepairError
34+ from neo4j_graphrag .experimental .pipeline .exceptions import InvalidJSONError
3535from 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
You can’t perform that action at this time.
0 commit comments