diff --git a/cognee/tasks/graph/exceptions/__init__.py b/cognee/tasks/graph/exceptions/__init__.py index 3516ba151..d91bbbd36 100644 --- a/cognee/tasks/graph/exceptions/__init__.py +++ b/cognee/tasks/graph/exceptions/__init__.py @@ -8,5 +8,5 @@ from .exceptions import ( InvalidDataChunksError, InvalidGraphModelError, InvalidOntologyAdapterError, - InvalidChunkGraphInputError + InvalidChunkGraphInputError, ) diff --git a/cognee/tasks/graph/exceptions/exceptions.py b/cognee/tasks/graph/exceptions/exceptions.py index 0708bab31..c09ee1c08 100644 --- a/cognee/tasks/graph/exceptions/exceptions.py +++ b/cognee/tasks/graph/exceptions/exceptions.py @@ -13,6 +13,7 @@ class InvalidDataChunksError(CogneeValidationError): status_code=status.HTTP_400_BAD_REQUEST, ) + class InvalidGraphModelError(CogneeValidationError): def __init__(self, got): super().__init__( @@ -21,12 +22,14 @@ class InvalidGraphModelError(CogneeValidationError): status_code=status.HTTP_400_BAD_REQUEST, ) + class InvalidOntologyAdapterError(CogneeConfigurationError): def __init__(self, got): super().__init__( message=f"ontology_adapter lacks required interface (got {got}).", name="InvalidOntologyAdapterError", - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + ) class InvalidChunkGraphInputError(CogneeValidationError): @@ -34,4 +37,5 @@ class InvalidChunkGraphInputError(CogneeValidationError): super().__init__( message=f"Invalid chunk inputs or LLM Chunkgraphs: {detail}", name="InvalidChunkGraphInputError", - status_code=status.HTTP_400_BAD_REQUEST) \ No newline at end of file + status_code=status.HTTP_400_BAD_REQUEST, + ) diff --git a/cognee/tasks/graph/extract_graph_from_data.py b/cognee/tasks/graph/extract_graph_from_data.py index 2ddd85075..019e9e4a1 100644 --- a/cognee/tasks/graph/extract_graph_from_data.py +++ b/cognee/tasks/graph/extract_graph_from_data.py @@ -19,6 +19,7 @@ from cognee.tasks.graph.exceptions import ( InvalidOntologyAdapterError, ) + async def integrate_chunk_graphs( data_chunks: list[DocumentChunk], chunk_graphs: list, @@ -30,11 +31,15 @@ async def integrate_chunk_graphs( if not isinstance(data_chunks, list) or not isinstance(chunk_graphs, list): raise InvalidChunkGraphInputError("data_chunks and chunk_graphs must be lists.") if len(data_chunks) != len(chunk_graphs): - raise InvalidChunkGraphInputError(f"length mismatch: {len(data_chunks)} chunks vs {len(chunk_graphs)} graphs.") + raise InvalidChunkGraphInputError( + f"length mismatch: {len(data_chunks)} chunks vs {len(chunk_graphs)} graphs." + ) if not isinstance(graph_model, type) or not issubclass(graph_model, BaseModel): raise InvalidGraphModelError(graph_model) if ontology_adapter is None or not hasattr(ontology_adapter, "get_subgraph"): - raise InvalidOntologyAdapterError(type(ontology_adapter).__name__ if ontology_adapter else "None") + raise InvalidOntologyAdapterError( + type(ontology_adapter).__name__ if ontology_adapter else "None" + ) graph_engine = await get_graph_engine() diff --git a/cognee/tasks/storage/add_data_points.py b/cognee/tasks/storage/add_data_points.py index 41bda954f..6cdc90ac9 100644 --- a/cognee/tasks/storage/add_data_points.py +++ b/cognee/tasks/storage/add_data_points.py @@ -11,7 +11,6 @@ from cognee.tasks.storage.exceptions import ( async def add_data_points(data_points: List[DataPoint]) -> List[DataPoint]: - if not isinstance(data_points, list): raise InvalidDataPointsInAddDataPointsError("data_points must be a list.") if not all(isinstance(dp, DataPoint) for dp in data_points): diff --git a/cognee/tasks/storage/exceptions/exceptions.py b/cognee/tasks/storage/exceptions/exceptions.py index 2da6a84aa..9b2de9efd 100644 --- a/cognee/tasks/storage/exceptions/exceptions.py +++ b/cognee/tasks/storage/exceptions/exceptions.py @@ -9,5 +9,5 @@ class InvalidDataPointsInAddDataPointsError(CogneeValidationError): super().__init__( message=f"Invalid data_points: {detail}", name="InvalidDataPointsInAddDataPointsError", - status_code=status.HTTP_400_BAD_REQUEST) - + status_code=status.HTTP_400_BAD_REQUEST, + ) diff --git a/cognee/tasks/summarization/exceptions/exceptions.py b/cognee/tasks/summarization/exceptions/exceptions.py index d0c9cfec6..9e8e7197e 100644 --- a/cognee/tasks/summarization/exceptions/exceptions.py +++ b/cognee/tasks/summarization/exceptions/exceptions.py @@ -10,4 +10,5 @@ class InvalidSummaryInputsError(CogneeValidationError): super().__init__( message=f"Invalid summarize_text inputs: {detail}", name="InvalidSummaryInputsError", - status_code=status.HTTP_400_BAD_REQUEST) \ No newline at end of file + status_code=status.HTTP_400_BAD_REQUEST, + ) diff --git a/cognee/tasks/summarization/summarize_text.py b/cognee/tasks/summarization/summarize_text.py index b482b5b4a..f6dcc54a2 100644 --- a/cognee/tasks/summarization/summarize_text.py +++ b/cognee/tasks/summarization/summarize_text.py @@ -42,7 +42,6 @@ async def summarize_text( if not all(hasattr(c, "text") for c in data_chunks): raise InvalidSummaryInputsError("each DocumentChunk must have a 'text' attribute.") - if len(data_chunks) == 0: return data_chunks