ArnoChen commited on
Commit
e06bbc8
·
1 Parent(s): b6d6660

add namespace prefix to storage namespaces

Browse files
lightrag/api/lightrag_server.py CHANGED
@@ -40,7 +40,7 @@ from .ollama_api import (
40
  from .ollama_api import ollama_server_infos
41
 
42
  # Load environment variables
43
- load_dotenv()
44
 
45
 
46
  class RAGStorageConfig:
@@ -532,6 +532,16 @@ def parse_args() -> argparse.Namespace:
532
  help="Number of conversation history turns to include (default: from env or 3)",
533
  )
534
 
 
 
 
 
 
 
 
 
 
 
535
  args = parser.parse_args()
536
 
537
  ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
@@ -861,6 +871,8 @@ def create_app(args):
861
  "similarity_threshold": 0.95,
862
  "use_llm_check": False,
863
  },
 
 
864
  )
865
  else:
866
  rag = LightRAG(
@@ -890,6 +902,8 @@ def create_app(args):
890
  "similarity_threshold": 0.95,
891
  "use_llm_check": False,
892
  },
 
 
893
  )
894
 
895
  async def index_file(file_path: Union[str, Path]) -> None:
 
40
  from .ollama_api import ollama_server_infos
41
 
42
  # Load environment variables
43
+ load_dotenv(override=True)
44
 
45
 
46
  class RAGStorageConfig:
 
532
  help="Number of conversation history turns to include (default: from env or 3)",
533
  )
534
 
535
+ # Namespace
536
+ parser.add_argument(
537
+ "--namespace-prefix",
538
+ type=str,
539
+ default=get_env_value(
540
+ "NAMESPACE_PREFIX", ""
541
+ ),
542
+ help="Prefix of the namespace",
543
+ )
544
+
545
  args = parser.parse_args()
546
 
547
  ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
 
871
  "similarity_threshold": 0.95,
872
  "use_llm_check": False,
873
  },
874
+ log_level=args.log_level,
875
+ namespace_prefix=args.namespace_prefix,
876
  )
877
  else:
878
  rag = LightRAG(
 
902
  "similarity_threshold": 0.95,
903
  "use_llm_check": False,
904
  },
905
+ log_level=args.log_level,
906
+ namespace_prefix=args.namespace_prefix,
907
  )
908
 
909
  async def index_file(file_path: Union[str, Path]) -> None:
lightrag/api/ollama_api.py CHANGED
@@ -15,7 +15,7 @@ from dotenv import load_dotenv
15
 
16
 
17
  # Load environment variables
18
- load_dotenv()
19
 
20
 
21
  class OllamaServerInfos:
 
15
 
16
 
17
  # Load environment variables
18
+ load_dotenv(override=True)
19
 
20
 
21
  class OllamaServerInfos:
lightrag/kg/mongo_impl.py CHANGED
@@ -52,7 +52,7 @@ class MongoKVStorage(BaseKVStorage):
52
  return set([s for s in data if s not in existing_ids])
53
 
54
  async def upsert(self, data: dict[str, dict]):
55
- if self.namespace == "llm_response_cache":
56
  for mode, items in data.items():
57
  for k, v in tqdm_async(items.items(), desc="Upserting"):
58
  key = f"{mode}_{k}"
@@ -69,7 +69,7 @@ class MongoKVStorage(BaseKVStorage):
69
  return data
70
 
71
  async def get_by_mode_and_id(self, mode: str, id: str) -> Union[dict, None]:
72
- if "llm_response_cache" == self.namespace:
73
  res = {}
74
  v = self._data.find_one({"_id": mode + "_" + id})
75
  if v:
 
52
  return set([s for s in data if s not in existing_ids])
53
 
54
  async def upsert(self, data: dict[str, dict]):
55
+ if self.namespace.endswith("llm_response_cache"):
56
  for mode, items in data.items():
57
  for k, v in tqdm_async(items.items(), desc="Upserting"):
58
  key = f"{mode}_{k}"
 
69
  return data
70
 
71
  async def get_by_mode_and_id(self, mode: str, id: str) -> Union[dict, None]:
72
+ if self.namespace.endswith("llm_response_cache"):
73
  res = {}
74
  v = self._data.find_one({"_id": mode + "_" + id})
75
  if v:
lightrag/kg/oracle_impl.py CHANGED
@@ -185,7 +185,7 @@ class OracleKVStorage(BaseKVStorage):
185
  SQL = SQL_TEMPLATES["get_by_id_" + self.namespace]
186
  params = {"workspace": self.db.workspace, "id": id}
187
  # print("get_by_id:"+SQL)
188
- if "llm_response_cache" == self.namespace:
189
  array_res = await self.db.query(SQL, params, multirows=True)
190
  res = {}
191
  for row in array_res:
@@ -201,7 +201,7 @@ class OracleKVStorage(BaseKVStorage):
201
  """Specifically for llm_response_cache."""
202
  SQL = SQL_TEMPLATES["get_by_mode_id_" + self.namespace]
203
  params = {"workspace": self.db.workspace, "cache_mode": mode, "id": id}
204
- if "llm_response_cache" == self.namespace:
205
  array_res = await self.db.query(SQL, params, multirows=True)
206
  res = {}
207
  for row in array_res:
@@ -218,7 +218,7 @@ class OracleKVStorage(BaseKVStorage):
218
  params = {"workspace": self.db.workspace}
219
  # print("get_by_ids:"+SQL)
220
  res = await self.db.query(SQL, params, multirows=True)
221
- if "llm_response_cache" == self.namespace:
222
  modes = set()
223
  dict_res: dict[str, dict] = {}
224
  for row in res:
@@ -269,7 +269,7 @@ class OracleKVStorage(BaseKVStorage):
269
 
270
  ################ INSERT METHODS ################
271
  async def upsert(self, data: dict[str, dict]):
272
- if self.namespace == "text_chunks":
273
  list_data = [
274
  {
275
  "id": k,
@@ -302,7 +302,7 @@ class OracleKVStorage(BaseKVStorage):
302
  "status": item["status"],
303
  }
304
  await self.db.execute(merge_sql, _data)
305
- if self.namespace == "full_docs":
306
  for k, v in data.items():
307
  # values.clear()
308
  merge_sql = SQL_TEMPLATES["merge_doc_full"]
@@ -313,7 +313,7 @@ class OracleKVStorage(BaseKVStorage):
313
  }
314
  await self.db.execute(merge_sql, _data)
315
 
316
- if self.namespace == "llm_response_cache":
317
  for mode, items in data.items():
318
  for k, v in items.items():
319
  upsert_sql = SQL_TEMPLATES["upsert_llm_response_cache"]
@@ -334,8 +334,10 @@ class OracleKVStorage(BaseKVStorage):
334
  await self.db.execute(SQL, params)
335
 
336
  async def index_done_callback(self):
337
- if self.namespace in ["full_docs", "text_chunks"]:
338
- logger.info("full doc and chunk data had been saved into oracle db!")
 
 
339
 
340
 
341
  @dataclass
 
185
  SQL = SQL_TEMPLATES["get_by_id_" + self.namespace]
186
  params = {"workspace": self.db.workspace, "id": id}
187
  # print("get_by_id:"+SQL)
188
+ if self.namespace.endswith("llm_response_cache"):
189
  array_res = await self.db.query(SQL, params, multirows=True)
190
  res = {}
191
  for row in array_res:
 
201
  """Specifically for llm_response_cache."""
202
  SQL = SQL_TEMPLATES["get_by_mode_id_" + self.namespace]
203
  params = {"workspace": self.db.workspace, "cache_mode": mode, "id": id}
204
+ if self.namespace.endswith("llm_response_cache"):
205
  array_res = await self.db.query(SQL, params, multirows=True)
206
  res = {}
207
  for row in array_res:
 
218
  params = {"workspace": self.db.workspace}
219
  # print("get_by_ids:"+SQL)
220
  res = await self.db.query(SQL, params, multirows=True)
221
+ if self.namespace.endswith("llm_response_cache"):
222
  modes = set()
223
  dict_res: dict[str, dict] = {}
224
  for row in res:
 
269
 
270
  ################ INSERT METHODS ################
271
  async def upsert(self, data: dict[str, dict]):
272
+ if self.namespace.endswith("text_chunks"):
273
  list_data = [
274
  {
275
  "id": k,
 
302
  "status": item["status"],
303
  }
304
  await self.db.execute(merge_sql, _data)
305
+ if self.namespace.endswith("full_docs"):
306
  for k, v in data.items():
307
  # values.clear()
308
  merge_sql = SQL_TEMPLATES["merge_doc_full"]
 
313
  }
314
  await self.db.execute(merge_sql, _data)
315
 
316
+ if self.namespace.endswith("llm_response_cache"):
317
  for mode, items in data.items():
318
  for k, v in items.items():
319
  upsert_sql = SQL_TEMPLATES["upsert_llm_response_cache"]
 
334
  await self.db.execute(SQL, params)
335
 
336
  async def index_done_callback(self):
337
+ for n in ("full_docs", "text_chunks"):
338
+ if self.namespace.endswith(n):
339
+ logger.info("full doc and chunk data had been saved into oracle db!")
340
+ break
341
 
342
 
343
  @dataclass
lightrag/kg/postgres_impl.py CHANGED
@@ -187,7 +187,7 @@ class PGKVStorage(BaseKVStorage):
187
  """Get doc_full data by id."""
188
  sql = SQL_TEMPLATES["get_by_id_" + self.namespace]
189
  params = {"workspace": self.db.workspace, "id": id}
190
- if "llm_response_cache" == self.namespace:
191
  array_res = await self.db.query(sql, params, multirows=True)
192
  res = {}
193
  for row in array_res:
@@ -203,7 +203,7 @@ class PGKVStorage(BaseKVStorage):
203
  """Specifically for llm_response_cache."""
204
  sql = SQL_TEMPLATES["get_by_mode_id_" + self.namespace]
205
  params = {"workspace": self.db.workspace, mode: mode, "id": id}
206
- if "llm_response_cache" == self.namespace:
207
  array_res = await self.db.query(sql, params, multirows=True)
208
  res = {}
209
  for row in array_res:
@@ -219,7 +219,7 @@ class PGKVStorage(BaseKVStorage):
219
  ids=",".join([f"'{id}'" for id in ids])
220
  )
221
  params = {"workspace": self.db.workspace}
222
- if "llm_response_cache" == self.namespace:
223
  array_res = await self.db.query(sql, params, multirows=True)
224
  modes = set()
225
  dict_res: dict[str, dict] = {}
@@ -239,7 +239,7 @@ class PGKVStorage(BaseKVStorage):
239
  return None
240
 
241
  async def all_keys(self) -> list[dict]:
242
- if "llm_response_cache" == self.namespace:
243
  sql = "select workspace,mode,id from lightrag_llm_cache"
244
  res = await self.db.query(sql, multirows=True)
245
  return res
@@ -270,9 +270,9 @@ class PGKVStorage(BaseKVStorage):
270
 
271
  ################ INSERT METHODS ################
272
  async def upsert(self, data: Dict[str, dict]):
273
- if self.namespace == "text_chunks":
274
  pass
275
- elif self.namespace == "full_docs":
276
  for k, v in data.items():
277
  upsert_sql = SQL_TEMPLATES["upsert_doc_full"]
278
  _data = {
@@ -281,7 +281,7 @@ class PGKVStorage(BaseKVStorage):
281
  "workspace": self.db.workspace,
282
  }
283
  await self.db.execute(upsert_sql, _data)
284
- elif self.namespace == "llm_response_cache":
285
  for mode, items in data.items():
286
  for k, v in items.items():
287
  upsert_sql = SQL_TEMPLATES["upsert_llm_response_cache"]
@@ -296,8 +296,10 @@ class PGKVStorage(BaseKVStorage):
296
  await self.db.execute(upsert_sql, _data)
297
 
298
  async def index_done_callback(self):
299
- if self.namespace in ["full_docs", "text_chunks"]:
300
- logger.info("full doc and chunk data had been saved into postgresql db!")
 
 
301
 
302
 
303
  @dataclass
@@ -389,11 +391,11 @@ class PGVectorStorage(BaseVectorStorage):
389
  for i, d in enumerate(list_data):
390
  d["__vector__"] = embeddings[i]
391
  for item in list_data:
392
- if self.namespace == "chunks":
393
  upsert_sql, data = self._upsert_chunks(item)
394
- elif self.namespace == "entities":
395
  upsert_sql, data = self._upsert_entities(item)
396
- elif self.namespace == "relationships":
397
  upsert_sql, data = self._upsert_relationships(item)
398
  else:
399
  raise ValueError(f"{self.namespace} is not supported")
 
187
  """Get doc_full data by id."""
188
  sql = SQL_TEMPLATES["get_by_id_" + self.namespace]
189
  params = {"workspace": self.db.workspace, "id": id}
190
+ if self.namespace.endswith("llm_response_cache"):
191
  array_res = await self.db.query(sql, params, multirows=True)
192
  res = {}
193
  for row in array_res:
 
203
  """Specifically for llm_response_cache."""
204
  sql = SQL_TEMPLATES["get_by_mode_id_" + self.namespace]
205
  params = {"workspace": self.db.workspace, mode: mode, "id": id}
206
+ if self.namespace.endswith("llm_response_cache"):
207
  array_res = await self.db.query(sql, params, multirows=True)
208
  res = {}
209
  for row in array_res:
 
219
  ids=",".join([f"'{id}'" for id in ids])
220
  )
221
  params = {"workspace": self.db.workspace}
222
+ if self.namespace.endswith("llm_response_cache"):
223
  array_res = await self.db.query(sql, params, multirows=True)
224
  modes = set()
225
  dict_res: dict[str, dict] = {}
 
239
  return None
240
 
241
  async def all_keys(self) -> list[dict]:
242
+ if self.namespace.endswith("llm_response_cache"):
243
  sql = "select workspace,mode,id from lightrag_llm_cache"
244
  res = await self.db.query(sql, multirows=True)
245
  return res
 
270
 
271
  ################ INSERT METHODS ################
272
  async def upsert(self, data: Dict[str, dict]):
273
+ if self.namespace.endswith("text_chunks"):
274
  pass
275
+ elif self.namespace.endswith("full_docs"):
276
  for k, v in data.items():
277
  upsert_sql = SQL_TEMPLATES["upsert_doc_full"]
278
  _data = {
 
281
  "workspace": self.db.workspace,
282
  }
283
  await self.db.execute(upsert_sql, _data)
284
+ elif self.namespace.endswith("llm_response_cache"):
285
  for mode, items in data.items():
286
  for k, v in items.items():
287
  upsert_sql = SQL_TEMPLATES["upsert_llm_response_cache"]
 
296
  await self.db.execute(upsert_sql, _data)
297
 
298
  async def index_done_callback(self):
299
+ for n in ("full_docs", "text_chunks"):
300
+ if self.namespace.endswith(n):
301
+ logger.info("full doc and chunk data had been saved into postgresql db!")
302
+ break
303
 
304
 
305
  @dataclass
 
391
  for i, d in enumerate(list_data):
392
  d["__vector__"] = embeddings[i]
393
  for item in list_data:
394
+ if self.namespace.endswith("chunks"):
395
  upsert_sql, data = self._upsert_chunks(item)
396
+ elif self.namespace.endswith("entities"):
397
  upsert_sql, data = self._upsert_entities(item)
398
+ elif self.namespace.endswith("relationships"):
399
  upsert_sql, data = self._upsert_relationships(item)
400
  else:
401
  raise ValueError(f"{self.namespace} is not supported")
lightrag/kg/tidb_impl.py CHANGED
@@ -160,7 +160,7 @@ class TiDBKVStorage(BaseKVStorage):
160
  async def upsert(self, data: dict[str, dict]):
161
  left_data = {k: v for k, v in data.items() if k not in self._data}
162
  self._data.update(left_data)
163
- if self.namespace == "text_chunks":
164
  list_data = [
165
  {
166
  "__id__": k,
@@ -196,7 +196,7 @@ class TiDBKVStorage(BaseKVStorage):
196
  )
197
  await self.db.execute(merge_sql, data)
198
 
199
- if self.namespace == "full_docs":
200
  merge_sql = SQL_TEMPLATES["upsert_doc_full"]
201
  data = []
202
  for k, v in self._data.items():
@@ -211,8 +211,10 @@ class TiDBKVStorage(BaseKVStorage):
211
  return left_data
212
 
213
  async def index_done_callback(self):
214
- if self.namespace in ["full_docs", "text_chunks"]:
215
- logger.info("full doc and chunk data had been saved into TiDB db!")
 
 
216
 
217
 
218
  @dataclass
@@ -258,7 +260,7 @@ class TiDBVectorDBStorage(BaseVectorStorage):
258
  if not len(data):
259
  logger.warning("You insert an empty data to vector DB")
260
  return []
261
- if self.namespace == "chunks":
262
  return []
263
  logger.info(f"Inserting {len(data)} vectors to {self.namespace}")
264
 
@@ -288,7 +290,7 @@ class TiDBVectorDBStorage(BaseVectorStorage):
288
  for i, d in enumerate(list_data):
289
  d["content_vector"] = embeddings[i]
290
 
291
- if self.namespace == "entities":
292
  data = []
293
  for item in list_data:
294
  param = {
@@ -309,7 +311,7 @@ class TiDBVectorDBStorage(BaseVectorStorage):
309
  merge_sql = SQL_TEMPLATES["insert_entity"]
310
  await self.db.execute(merge_sql, data)
311
 
312
- elif self.namespace == "relationships":
313
  data = []
314
  for item in list_data:
315
  param = {
 
160
  async def upsert(self, data: dict[str, dict]):
161
  left_data = {k: v for k, v in data.items() if k not in self._data}
162
  self._data.update(left_data)
163
+ if self.namespace.endswith("text_chunks"):
164
  list_data = [
165
  {
166
  "__id__": k,
 
196
  )
197
  await self.db.execute(merge_sql, data)
198
 
199
+ if self.namespace.endswith("full_docs"):
200
  merge_sql = SQL_TEMPLATES["upsert_doc_full"]
201
  data = []
202
  for k, v in self._data.items():
 
211
  return left_data
212
 
213
  async def index_done_callback(self):
214
+ for n in ("full_docs", "text_chunks"):
215
+ if self.namespace.endswith(n):
216
+ logger.info("full doc and chunk data had been saved into TiDB db!")
217
+ break
218
 
219
 
220
  @dataclass
 
260
  if not len(data):
261
  logger.warning("You insert an empty data to vector DB")
262
  return []
263
+ if self.namespace.endswith("chunks"):
264
  return []
265
  logger.info(f"Inserting {len(data)} vectors to {self.namespace}")
266
 
 
290
  for i, d in enumerate(list_data):
291
  d["content_vector"] = embeddings[i]
292
 
293
+ if self.namespace.endswith("entities"):
294
  data = []
295
  for item in list_data:
296
  param = {
 
311
  merge_sql = SQL_TEMPLATES["insert_entity"]
312
  await self.db.execute(merge_sql, data)
313
 
314
+ elif self.namespace.endswith("relationships"):
315
  data = []
316
  for item in list_data:
317
  param = {
lightrag/lightrag.py CHANGED
@@ -167,6 +167,7 @@ class LightRAG:
167
 
168
  # storage
169
  vector_db_storage_cls_kwargs: dict = field(default_factory=dict)
 
170
 
171
  enable_llm_cache: bool = True
172
  # Sometimes there are some reason the LLM failed at Extracting Entities, and we want to continue without LLM cost, we can use this flag
@@ -228,12 +229,12 @@ class LightRAG:
228
  )
229
 
230
  self.json_doc_status_storage = self.key_string_value_json_storage_cls(
231
- namespace="json_doc_status_storage",
232
  embedding_func=None,
233
  )
234
 
235
  self.llm_response_cache = self.key_string_value_json_storage_cls(
236
- namespace="llm_response_cache",
237
  embedding_func=self.embedding_func,
238
  )
239
 
@@ -241,15 +242,15 @@ class LightRAG:
241
  # add embedding func by walter
242
  ####
243
  self.full_docs = self.key_string_value_json_storage_cls(
244
- namespace="full_docs",
245
  embedding_func=self.embedding_func,
246
  )
247
  self.text_chunks = self.key_string_value_json_storage_cls(
248
- namespace="text_chunks",
249
  embedding_func=self.embedding_func,
250
  )
251
  self.chunk_entity_relation_graph = self.graph_storage_cls(
252
- namespace="chunk_entity_relation",
253
  embedding_func=self.embedding_func,
254
  )
255
  ####
@@ -257,17 +258,17 @@ class LightRAG:
257
  ####
258
 
259
  self.entities_vdb = self.vector_db_storage_cls(
260
- namespace="entities",
261
  embedding_func=self.embedding_func,
262
  meta_fields={"entity_name"},
263
  )
264
  self.relationships_vdb = self.vector_db_storage_cls(
265
- namespace="relationships",
266
  embedding_func=self.embedding_func,
267
  meta_fields={"src_id", "tgt_id"},
268
  )
269
  self.chunks_vdb = self.vector_db_storage_cls(
270
- namespace="chunks",
271
  embedding_func=self.embedding_func,
272
  )
273
 
@@ -277,7 +278,7 @@ class LightRAG:
277
  hashing_kv = self.llm_response_cache
278
  else:
279
  hashing_kv = self.key_string_value_json_storage_cls(
280
- namespace="llm_response_cache",
281
  embedding_func=self.embedding_func,
282
  )
283
 
@@ -292,7 +293,7 @@ class LightRAG:
292
  # Initialize document status storage
293
  self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage)
294
  self.doc_status = self.doc_status_storage_cls(
295
- namespace="doc_status",
296
  global_config=global_config,
297
  embedding_func=None,
298
  )
@@ -928,7 +929,7 @@ class LightRAG:
928
  if self.llm_response_cache
929
  and hasattr(self.llm_response_cache, "global_config")
930
  else self.key_string_value_json_storage_cls(
931
- namespace="llm_response_cache",
932
  global_config=asdict(self),
933
  embedding_func=self.embedding_func,
934
  ),
@@ -945,7 +946,7 @@ class LightRAG:
945
  if self.llm_response_cache
946
  and hasattr(self.llm_response_cache, "global_config")
947
  else self.key_string_value_json_storage_cls(
948
- namespace="llm_response_cache",
949
  global_config=asdict(self),
950
  embedding_func=self.embedding_func,
951
  ),
@@ -964,7 +965,7 @@ class LightRAG:
964
  if self.llm_response_cache
965
  and hasattr(self.llm_response_cache, "global_config")
966
  else self.key_string_value_json_storage_cls(
967
- namespace="llm_response_cache",
968
  global_config=asdict(self),
969
  embedding_func=self.embedding_func,
970
  ),
@@ -1005,7 +1006,7 @@ class LightRAG:
1005
  global_config=asdict(self),
1006
  hashing_kv=self.llm_response_cache
1007
  or self.key_string_value_json_storage_cls(
1008
- namespace="llm_response_cache",
1009
  global_config=asdict(self),
1010
  embedding_func=self.embedding_func,
1011
  ),
@@ -1036,7 +1037,7 @@ class LightRAG:
1036
  if self.llm_response_cache
1037
  and hasattr(self.llm_response_cache, "global_config")
1038
  else self.key_string_value_json_storage_cls(
1039
- namespace="llm_response_cache",
1040
  global_config=asdict(self),
1041
  embedding_func=self.embedding_funcne,
1042
  ),
@@ -1052,7 +1053,7 @@ class LightRAG:
1052
  if self.llm_response_cache
1053
  and hasattr(self.llm_response_cache, "global_config")
1054
  else self.key_string_value_json_storage_cls(
1055
- namespace="llm_response_cache",
1056
  global_config=asdict(self),
1057
  embedding_func=self.embedding_func,
1058
  ),
@@ -1071,7 +1072,7 @@ class LightRAG:
1071
  if self.llm_response_cache
1072
  and hasattr(self.llm_response_cache, "global_config")
1073
  else self.key_string_value_json_storage_cls(
1074
- namespace="llm_response_cache",
1075
  global_config=asdict(self),
1076
  embedding_func=self.embedding_func,
1077
  ),
 
167
 
168
  # storage
169
  vector_db_storage_cls_kwargs: dict = field(default_factory=dict)
170
+ namespace_prefix: str = field(default="")
171
 
172
  enable_llm_cache: bool = True
173
  # Sometimes there are some reason the LLM failed at Extracting Entities, and we want to continue without LLM cost, we can use this flag
 
229
  )
230
 
231
  self.json_doc_status_storage = self.key_string_value_json_storage_cls(
232
+ namespace=self.namespace_prefix + "json_doc_status_storage",
233
  embedding_func=None,
234
  )
235
 
236
  self.llm_response_cache = self.key_string_value_json_storage_cls(
237
+ namespace=self.namespace_prefix + "llm_response_cache",
238
  embedding_func=self.embedding_func,
239
  )
240
 
 
242
  # add embedding func by walter
243
  ####
244
  self.full_docs = self.key_string_value_json_storage_cls(
245
+ namespace=self.namespace_prefix + "full_docs",
246
  embedding_func=self.embedding_func,
247
  )
248
  self.text_chunks = self.key_string_value_json_storage_cls(
249
+ namespace=self.namespace_prefix + "text_chunks",
250
  embedding_func=self.embedding_func,
251
  )
252
  self.chunk_entity_relation_graph = self.graph_storage_cls(
253
+ namespace=self.namespace_prefix + "chunk_entity_relation",
254
  embedding_func=self.embedding_func,
255
  )
256
  ####
 
258
  ####
259
 
260
  self.entities_vdb = self.vector_db_storage_cls(
261
+ namespace=self.namespace_prefix + "entities",
262
  embedding_func=self.embedding_func,
263
  meta_fields={"entity_name"},
264
  )
265
  self.relationships_vdb = self.vector_db_storage_cls(
266
+ namespace=self.namespace_prefix + "relationships",
267
  embedding_func=self.embedding_func,
268
  meta_fields={"src_id", "tgt_id"},
269
  )
270
  self.chunks_vdb = self.vector_db_storage_cls(
271
+ namespace=self.namespace_prefix + "chunks",
272
  embedding_func=self.embedding_func,
273
  )
274
 
 
278
  hashing_kv = self.llm_response_cache
279
  else:
280
  hashing_kv = self.key_string_value_json_storage_cls(
281
+ namespace=self.namespace_prefix + "llm_response_cache",
282
  embedding_func=self.embedding_func,
283
  )
284
 
 
293
  # Initialize document status storage
294
  self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage)
295
  self.doc_status = self.doc_status_storage_cls(
296
+ namespace=self.namespace_prefix + "doc_status",
297
  global_config=global_config,
298
  embedding_func=None,
299
  )
 
929
  if self.llm_response_cache
930
  and hasattr(self.llm_response_cache, "global_config")
931
  else self.key_string_value_json_storage_cls(
932
+ namespace=self.namespace_prefix + "llm_response_cache",
933
  global_config=asdict(self),
934
  embedding_func=self.embedding_func,
935
  ),
 
946
  if self.llm_response_cache
947
  and hasattr(self.llm_response_cache, "global_config")
948
  else self.key_string_value_json_storage_cls(
949
+ namespace=self.namespace_prefix + "llm_response_cache",
950
  global_config=asdict(self),
951
  embedding_func=self.embedding_func,
952
  ),
 
965
  if self.llm_response_cache
966
  and hasattr(self.llm_response_cache, "global_config")
967
  else self.key_string_value_json_storage_cls(
968
+ namespace=self.namespace_prefix + "llm_response_cache",
969
  global_config=asdict(self),
970
  embedding_func=self.embedding_func,
971
  ),
 
1006
  global_config=asdict(self),
1007
  hashing_kv=self.llm_response_cache
1008
  or self.key_string_value_json_storage_cls(
1009
+ namespace=self.namespace_prefix + "llm_response_cache",
1010
  global_config=asdict(self),
1011
  embedding_func=self.embedding_func,
1012
  ),
 
1037
  if self.llm_response_cache
1038
  and hasattr(self.llm_response_cache, "global_config")
1039
  else self.key_string_value_json_storage_cls(
1040
+ namespace=self.namespace_prefix + "llm_response_cache",
1041
  global_config=asdict(self),
1042
  embedding_func=self.embedding_funcne,
1043
  ),
 
1053
  if self.llm_response_cache
1054
  and hasattr(self.llm_response_cache, "global_config")
1055
  else self.key_string_value_json_storage_cls(
1056
+ namespace=self.namespace_prefix + "llm_response_cache",
1057
  global_config=asdict(self),
1058
  embedding_func=self.embedding_func,
1059
  ),
 
1072
  if self.llm_response_cache
1073
  and hasattr(self.llm_response_cache, "global_config")
1074
  else self.key_string_value_json_storage_cls(
1075
+ namespace=self.namespace_prefix + "llm_response_cache",
1076
  global_config=asdict(self),
1077
  embedding_func=self.embedding_func,
1078
  ),