This commit is contained in:
jin
2024-11-25 13:32:33 +08:00
11 changed files with 194 additions and 244 deletions

View File

@@ -172,9 +172,7 @@ class LightRAG:
embedding_func=self.embedding_func,
)
self.chunk_entity_relation_graph = self.graph_storage_cls(
namespace="chunk_entity_relation",
global_config=asdict(self),
embedding_func=self.embedding_func,
namespace="chunk_entity_relation", global_config=asdict(self)
)
####
# add embedding func by walter over
@@ -226,6 +224,7 @@ class LightRAG:
return loop.run_until_complete(self.ainsert(string_or_strings))
async def ainsert(self, string_or_strings):
update_storage = False
try:
if isinstance(string_or_strings, str):
string_or_strings = [string_or_strings]
@@ -239,6 +238,7 @@ class LightRAG:
if not len(new_docs):
logger.warning("All docs are already in the storage")
return
update_storage = True
logger.info(f"[New Docs] inserting {len(new_docs)} docs")
inserting_chunks = {}
@@ -285,7 +285,8 @@ class LightRAG:
await self.full_docs.upsert(new_docs)
await self.text_chunks.upsert(inserting_chunks)
finally:
await self._insert_done()
if update_storage:
await self._insert_done()
async def _insert_done(self):
tasks = []