Abyl Ikhsanov commited on
Commit
c573936
·
1 Parent(s): 1a71601

adding full_doc_id to insert

Browse files
Files changed (1) hide show
  1. lightrag/lightrag.py +4 -4
lightrag/lightrag.py CHANGED
@@ -835,11 +835,11 @@ class LightRAG:
835
  await asyncio.gather(*tasks)
836
  logger.info("All Insert done")
837
 
838
- def insert_custom_kg(self, custom_kg: dict[str, Any]) -> None:
839
  loop = always_get_an_event_loop()
840
- loop.run_until_complete(self.ainsert_custom_kg(custom_kg))
841
 
842
- async def ainsert_custom_kg(self, custom_kg: dict[str, Any]) -> None:
843
  update_storage = False
844
  try:
845
  # Insert chunks into vector storage
@@ -865,7 +865,7 @@ class LightRAG:
865
  "source_id": source_id,
866
  "tokens": tokens,
867
  "chunk_order_index": chunk_order_index,
868
- "full_doc_id": source_id,
869
  "status": DocStatus.PROCESSED,
870
  }
871
  all_chunks_data[chunk_id] = chunk_entry
 
835
  await asyncio.gather(*tasks)
836
  logger.info("All Insert done")
837
 
838
+ def insert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str = None) -> None:
839
  loop = always_get_an_event_loop()
840
+ loop.run_until_complete(self.ainsert_custom_kg(custom_kg, full_doc_id))
841
 
842
+ async def ainsert_custom_kg(self, custom_kg: dict[str, Any], full_doc_id: str | None) -> None:
843
  update_storage = False
844
  try:
845
  # Insert chunks into vector storage
 
865
  "source_id": source_id,
866
  "tokens": tokens,
867
  "chunk_order_index": chunk_order_index,
868
+ "full_doc_id": full_doc_id if full_doc_id is not None else source_id,
869
  "status": DocStatus.PROCESSED,
870
  }
871
  all_chunks_data[chunk_id] = chunk_entry