chore: ruff formatting
This commit is contained in:
parent
63d071f0d8
commit
affbc557d2
7 changed files with 18 additions and 10 deletions
|
|
@ -8,5 +8,5 @@ from .exceptions import (
|
|||
InvalidDataChunksError,
|
||||
InvalidGraphModelError,
|
||||
InvalidOntologyAdapterError,
|
||||
InvalidChunkGraphInputError
|
||||
InvalidChunkGraphInputError,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue