yangdx commited on
Commit
d0221a9
·
1 Parent(s): 78289f5

Fix doc_status error

Browse files
Files changed (1) hide show
  1. lightrag/lightrag.py +24 -28
lightrag/lightrag.py CHANGED
@@ -408,17 +408,8 @@ class LightRAG:
408
  self.graph_storage_cls, global_config=global_config
409
  )
410
 
411
- self.json_doc_status_storage = self.key_string_value_json_storage_cls(
412
- namespace=self.namespace_prefix + "json_doc_status_storage",
413
- embedding_func=None,
414
- )
415
-
416
- self.llm_response_cache = self.key_string_value_json_storage_cls(
417
- namespace=make_namespace(
418
- self.namespace_prefix, NameSpace.KV_STORE_LLM_RESPONSE_CACHE
419
- ),
420
- embedding_func=self.embedding_func,
421
- )
422
 
423
  # Check if Oracle storage implementation is used
424
  if (
@@ -528,7 +519,7 @@ class LightRAG:
528
  self.kv_storage == "PGKVStorage"
529
  or self.vector_storage == "PGVectorStorage"
530
  or self.graph_storage == "PGGraphStorage"
531
- or self.json_doc_status_storage == "PGDocStatusStorage"
532
  ):
533
  # Read configuration file
534
  config_parser = configparser.ConfigParser()
@@ -578,12 +569,16 @@ class LightRAG:
578
  self.vector_db_storage_cls.db = postgres_db
579
  if self.graph_storage == "PGGraphStorage":
580
  self.graph_storage_cls.db = postgres_db
581
- if self.json_doc_status_storage == "OracleGraphStorage":
582
- self.json_doc_status_storage = postgres_db
 
 
 
 
 
 
 
583
 
584
- ####
585
- # Add embedding function by walter
586
- ####
587
  self.full_docs: BaseKVStorage = self.key_string_value_json_storage_cls(
588
  namespace=make_namespace(
589
  self.namespace_prefix, NameSpace.KV_STORE_FULL_DOCS
@@ -602,9 +597,6 @@ class LightRAG:
602
  ),
603
  embedding_func=self.embedding_func,
604
  )
605
- ####
606
- # End of adding embedding function by walter
607
- ####
608
 
609
  self.entities_vdb = self.vector_db_storage_cls(
610
  namespace=make_namespace(
@@ -627,6 +619,7 @@ class LightRAG:
627
  embedding_func=self.embedding_func,
628
  )
629
 
 
630
  if self.llm_response_cache and hasattr(
631
  self.llm_response_cache, "global_config"
632
  ):
@@ -639,6 +632,17 @@ class LightRAG:
639
  embedding_func=self.embedding_func,
640
  )
641
 
 
 
 
 
 
 
 
 
 
 
 
642
  self.llm_model_func = limit_async_func_call(self.llm_model_max_async)(
643
  partial(
644
  self.llm_model_func,
@@ -647,14 +651,6 @@ class LightRAG:
647
  )
648
  )
649
 
650
- # Initialize document status storage
651
- self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage)
652
- self.doc_status: DocStatusStorage = self.doc_status_storage_cls(
653
- namespace=make_namespace(self.namespace_prefix, NameSpace.DOC_STATUS),
654
- global_config=global_config,
655
- embedding_func=None,
656
- )
657
-
658
  async def get_graph_labels(self):
659
  text = await self.chunk_entity_relation_graph.get_all_labels()
660
  return text
 
408
  self.graph_storage_cls, global_config=global_config
409
  )
410
 
411
+ # Initialize document status storage
412
+ self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage)
 
 
 
 
 
 
 
 
 
413
 
414
  # Check if Oracle storage implementation is used
415
  if (
 
519
  self.kv_storage == "PGKVStorage"
520
  or self.vector_storage == "PGVectorStorage"
521
  or self.graph_storage == "PGGraphStorage"
522
+ or self.doc_status_storage == "PGDocStatusStorage"
523
  ):
524
  # Read configuration file
525
  config_parser = configparser.ConfigParser()
 
569
  self.vector_db_storage_cls.db = postgres_db
570
  if self.graph_storage == "PGGraphStorage":
571
  self.graph_storage_cls.db = postgres_db
572
+ if self.doc_status_storage == "OracleGraphStorage":
573
+ self.doc_status_storage_cls = postgres_db
574
+
575
+ self.llm_response_cache = self.key_string_value_json_storage_cls(
576
+ namespace=make_namespace(
577
+ self.namespace_prefix, NameSpace.KV_STORE_LLM_RESPONSE_CACHE
578
+ ),
579
+ embedding_func=self.embedding_func,
580
+ )
581
 
 
 
 
582
  self.full_docs: BaseKVStorage = self.key_string_value_json_storage_cls(
583
  namespace=make_namespace(
584
  self.namespace_prefix, NameSpace.KV_STORE_FULL_DOCS
 
597
  ),
598
  embedding_func=self.embedding_func,
599
  )
 
 
 
600
 
601
  self.entities_vdb = self.vector_db_storage_cls(
602
  namespace=make_namespace(
 
619
  embedding_func=self.embedding_func,
620
  )
621
 
622
+ # What's for, Is this nessisary ?
623
  if self.llm_response_cache and hasattr(
624
  self.llm_response_cache, "global_config"
625
  ):
 
632
  embedding_func=self.embedding_func,
633
  )
634
 
635
+ # self.json_doc_status_storage = self.key_string_value_json_storage_cls(
636
+ # namespace=self.namespace_prefix + "json_doc_status_storage",
637
+ # embedding_func=None,
638
+ # )
639
+
640
+ self.doc_status: DocStatusStorage = self.doc_status_storage_cls(
641
+ namespace=make_namespace(self.namespace_prefix, NameSpace.DOC_STATUS),
642
+ global_config=global_config,
643
+ embedding_func=None,
644
+ )
645
+
646
  self.llm_model_func = limit_async_func_call(self.llm_model_max_async)(
647
  partial(
648
  self.llm_model_func,
 
651
  )
652
  )
653
 
 
 
 
 
 
 
 
 
654
  async def get_graph_labels(self):
655
  text = await self.chunk_entity_relation_graph.get_all_labels()
656
  return text