From 3d5cb7644a21d8e032dddd7dfb628fb2bccba573 Mon Sep 17 00:00:00 2001 From: Leon Luithlen Date: Wed, 27 Nov 2024 12:50:39 +0100 Subject: [PATCH] Pass DocumentChunk metadata_id to _metadata field --- cognee/modules/chunking/TextChunker.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cognee/modules/chunking/TextChunker.py b/cognee/modules/chunking/TextChunker.py index a98d36961..f38058b0e 100644 --- a/cognee/modules/chunking/TextChunker.py +++ b/cognee/modules/chunking/TextChunker.py @@ -34,7 +34,11 @@ class TextChunker(): word_count = chunk_data["word_count"], is_part_of = self.document, chunk_index = self.chunk_index, - cut_type = chunk_data["cut_type"] + cut_type = chunk_data["cut_type"], + _metadata = { + "index_fields": ["text"], + "metadata_id": self.document.metadata_id + } ) paragraph_chunks = [] self.chunk_size = 0 @@ -47,7 +51,11 @@ class TextChunker(): word_count = self.chunk_size, is_part_of = self.document, chunk_index = self.chunk_index, - cut_type = paragraph_chunks[len(paragraph_chunks) - 1]["cut_type"] + cut_type = paragraph_chunks[len(paragraph_chunks) - 1]["cut_type"], + _metadata = { + "index_fields": ["text"], + "metadata_id": self.document.metadata_id + } ) except Exception as e: print(e) @@ -64,7 +72,11 @@ class TextChunker(): word_count = self.chunk_size, is_part_of = self.document, chunk_index = self.chunk_index, - cut_type = paragraph_chunks[len(paragraph_chunks) - 1]["cut_type"] + cut_type = paragraph_chunks[len(paragraph_chunks) - 1]["cut_type"], + _metadata = { + "index_fields": ["text"], + "metadata_id": self.document.metadata_id + } ) except Exception as e: print(e)