Merge pull request #263 from detaos/detaos-patch-1
Only update storage if there was something to insert
This commit is contained in:
@@ -227,6 +227,7 @@ class LightRAG:
|
|||||||
return loop.run_until_complete(self.ainsert(string_or_strings))
|
return loop.run_until_complete(self.ainsert(string_or_strings))
|
||||||
|
|
||||||
async def ainsert(self, string_or_strings):
|
async def ainsert(self, string_or_strings):
|
||||||
|
update_storage = False
|
||||||
try:
|
try:
|
||||||
if isinstance(string_or_strings, str):
|
if isinstance(string_or_strings, str):
|
||||||
string_or_strings = [string_or_strings]
|
string_or_strings = [string_or_strings]
|
||||||
@@ -240,6 +241,7 @@ class LightRAG:
|
|||||||
if not len(new_docs):
|
if not len(new_docs):
|
||||||
logger.warning("All docs are already in the storage")
|
logger.warning("All docs are already in the storage")
|
||||||
return
|
return
|
||||||
|
update_storage = True
|
||||||
logger.info(f"[New Docs] inserting {len(new_docs)} docs")
|
logger.info(f"[New Docs] inserting {len(new_docs)} docs")
|
||||||
|
|
||||||
inserting_chunks = {}
|
inserting_chunks = {}
|
||||||
@@ -286,6 +288,7 @@ class LightRAG:
|
|||||||
await self.full_docs.upsert(new_docs)
|
await self.full_docs.upsert(new_docs)
|
||||||
await self.text_chunks.upsert(inserting_chunks)
|
await self.text_chunks.upsert(inserting_chunks)
|
||||||
finally:
|
finally:
|
||||||
|
if update_storage:
|
||||||
await self._insert_done()
|
await self._insert_done()
|
||||||
|
|
||||||
async def _insert_done(self):
|
async def _insert_done(self):
|
||||||
|
Reference in New Issue
Block a user