From baa505eeb0bda03c5c13aefd44e81a91e80d3f04 Mon Sep 17 00:00:00 2001 From: Abyl Ikhsanov Date: Sat, 1 Mar 2025 13:26:02 +0100 Subject: [PATCH 1/2] adding full_doc_id to insert --- lightrag/lightrag.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 15338874..b81ca08c 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -835,11 +835,11 @@ async def _insert_done(self) -> None: await asyncio.gather(*tasks) logger.info("All Insert done") - def insert_custom_kg(self, custom_kg: dict[str, Any]) -> None: + def insert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str = None) -> None: loop = always_get_an_event_loop() - loop.run_until_complete(self.ainsert_custom_kg(custom_kg)) + loop.run_until_complete(self.ainsert_custom_kg(custom_kg, full_doc_id)) - async def ainsert_custom_kg(self, custom_kg: dict[str, Any]) -> None: + async def ainsert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str | None) -> None: update_storage = False try: # Insert chunks into vector storage @@ -865,7 +865,7 @@ async def ainsert_custom_kg(self, custom_kg: dict[str, Any]) -> None: "source_id": source_id, "tokens": tokens, "chunk_order_index": chunk_order_index, - "full_doc_id": source_id, + "full_doc_id": full_doc_id if full_doc_id is not None else source_id, "status": DocStatus.PROCESSED, } all_chunks_data[chunk_id] = chunk_entry From bf0ddc645030b8aa22cd09828fc2d7341855f720 Mon Sep 17 00:00:00 2001 From: Abyl Ikhsanov Date: Sat, 1 Mar 2025 13:34:49 +0100 Subject: [PATCH 2/2] making optional for ainsert --- lightrag/lightrag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index b81ca08c..73747a91 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -839,7 +839,7 @@ def insert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str = None) - loop = always_get_an_event_loop() loop.run_until_complete(self.ainsert_custom_kg(custom_kg, full_doc_id)) - async def ainsert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str | None) -> None: + async def ainsert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str = None) -> None: update_storage = False try: # Insert chunks into vector storage