improving ainsert_custom_chunks paralelism
Browse files- lightrag/lightrag.py +7 -21
lightrag/lightrag.py
CHANGED
@@ -437,27 +437,13 @@ class LightRAG:
|
|
437 |
logger.warning("All chunks are already in the storage.")
|
438 |
return
|
439 |
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
knowledge_graph_inst=self.chunk_entity_relation_graph,
|
448 |
-
entity_vdb=self.entities_vdb,
|
449 |
-
relationships_vdb=self.relationships_vdb,
|
450 |
-
global_config=asdict(self),
|
451 |
-
)
|
452 |
-
|
453 |
-
if maybe_new_kg is None:
|
454 |
-
logger.warning("No new entities and relationships found")
|
455 |
-
return
|
456 |
-
else:
|
457 |
-
self.chunk_entity_relation_graph = maybe_new_kg
|
458 |
-
|
459 |
-
await self.full_docs.upsert(new_docs)
|
460 |
-
await self.text_chunks.upsert(inserting_chunks)
|
461 |
|
462 |
finally:
|
463 |
if update_storage:
|
|
|
437 |
logger.warning("All chunks are already in the storage.")
|
438 |
return
|
439 |
|
440 |
+
tasks = [
|
441 |
+
self.chunks_vdb.upsert(inserting_chunks),
|
442 |
+
self._process_entity_relation_graph(inserting_chunks),
|
443 |
+
self.full_docs.upsert(new_docs),
|
444 |
+
self.text_chunks.upsert(inserting_chunks),
|
445 |
+
]
|
446 |
+
await asyncio.gather(*tasks)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
|
448 |
finally:
|
449 |
if update_storage:
|