YanSte commited on
Commit
399116b
·
1 Parent(s): 90956fc

improving ainsert_custom_chunks paralelism

Browse files
Files changed (1) hide show
  1. 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
- logger.info(f"[New Chunks] inserting {len(inserting_chunks)} chunks")
441
-
442
- await self.chunks_vdb.upsert(inserting_chunks)
443
-
444
- logger.info("[Entity Extraction]...")
445
- maybe_new_kg = await extract_entities(
446
- inserting_chunks,
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: