From 791330400788e360fd3e985fad5fac59e7fec21c Mon Sep 17 00:00:00 2001 From: Lukas Selch Date: Mon, 17 Feb 2025 15:12:35 +0100 Subject: [PATCH] Fixed broken ainsert_custom_kg() --- lightrag/lightrag.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index bf1c02d2..7b3e8605 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -36,6 +36,7 @@ from .utils import ( limit_async_func_call, logger, set_logger, + encode_string_by_tiktoken, ) from .types import KnowledgeGraph @@ -863,7 +864,14 @@ class LightRAG: source_id = chunk_data["source_id"] chunk_id = compute_mdhash_id(chunk_content.strip(), prefix="chunk-") - chunk_entry = {"content": chunk_content.strip(), "source_id": source_id} + chunk_entry = { + "content": chunk_content.strip(), + "source_id": source_id, + "tokens": len(encode_string_by_tiktoken(chunk_entry["content"])), + "chunk_order_id": 0, + "full_doc_id": source_id, + "status": DocStatus.PROCESSED + } all_chunks_data[chunk_id] = chunk_entry chunk_to_source_map[source_id] = chunk_id update_storage = True