From ab8d95cc307a70e119b4f652e9cc8b6c218f1a67 Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Mon, 20 Jan 2025 17:28:14 +0100 Subject: [PATCH] refactor: As neo4j can't support dictionaries, add foreign metadata as string --- cognee/modules/data/processing/document_types/Document.py | 1 + cognee/tasks/documents/classify_documents.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cognee/modules/data/processing/document_types/Document.py b/cognee/modules/data/processing/document_types/Document.py index 7b464acef..e1bbb70ba 100644 --- a/cognee/modules/data/processing/document_types/Document.py +++ b/cognee/modules/data/processing/document_types/Document.py @@ -7,6 +7,7 @@ from cognee.infrastructure.engine import DataPoint class Document(DataPoint): name: str raw_data_location: str + foreign_metadata: Optional[str] mime_type: str _metadata: dict = {"index_fields": ["name"], "type": "Document"} diff --git a/cognee/tasks/documents/classify_documents.py b/cognee/tasks/documents/classify_documents.py index e86bc47e5..b1cc6a71d 100644 --- a/cognee/tasks/documents/classify_documents.py +++ b/cognee/tasks/documents/classify_documents.py @@ -1,4 +1,5 @@ from cognee.modules.data.models import Data +import json from cognee.modules.data.processing.document_types import ( Document, PdfDocument, @@ -57,6 +58,7 @@ async def classify_documents(data_documents: list[Data]) -> list[Document]: raw_data_location=data_item.raw_data_location, name=data_item.name, mime_type=data_item.mime_type, + foreign_metadata=json.dumps(data_item.foreign_metadata, indent=4), ) documents.append(document)