Remove namespace_prefix
Browse files- lightrag/lightrag.py +9 -26
- lightrag/namespace.py +0 -4
lightrag/lightrag.py
CHANGED
@@ -51,7 +51,7 @@ from .base import (
|
|
51 |
StoragesStatus,
|
52 |
DeletionResult,
|
53 |
)
|
54 |
-
from .namespace import NameSpace
|
55 |
from .operate import (
|
56 |
chunking_by_token_size,
|
57 |
extract_entities,
|
@@ -242,9 +242,6 @@ class LightRAG:
|
|
242 |
vector_db_storage_cls_kwargs: dict[str, Any] = field(default_factory=dict)
|
243 |
"""Additional parameters for vector database storage."""
|
244 |
|
245 |
-
# TODO:deprecated, remove in the future, use WORKSPACE instead
|
246 |
-
namespace_prefix: str = field(default="")
|
247 |
-
"""Prefix for namespacing stored data across different environments."""
|
248 |
|
249 |
enable_llm_cache: bool = field(default=True)
|
250 |
"""Enables caching for LLM responses to avoid redundant computations."""
|
@@ -382,9 +379,7 @@ class LightRAG:
|
|
382 |
self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage)
|
383 |
|
384 |
self.llm_response_cache: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore
|
385 |
-
namespace=
|
386 |
-
self.namespace_prefix, NameSpace.KV_STORE_LLM_RESPONSE_CACHE
|
387 |
-
),
|
388 |
global_config=asdict(
|
389 |
self
|
390 |
), # Add global_config to ensure cache works properly
|
@@ -392,51 +387,39 @@ class LightRAG:
|
|
392 |
)
|
393 |
|
394 |
self.full_docs: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore
|
395 |
-
namespace=
|
396 |
-
self.namespace_prefix, NameSpace.KV_STORE_FULL_DOCS
|
397 |
-
),
|
398 |
embedding_func=self.embedding_func,
|
399 |
)
|
400 |
|
401 |
self.text_chunks: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore
|
402 |
-
namespace=
|
403 |
-
self.namespace_prefix, NameSpace.KV_STORE_TEXT_CHUNKS
|
404 |
-
),
|
405 |
embedding_func=self.embedding_func,
|
406 |
)
|
407 |
|
408 |
self.chunk_entity_relation_graph: BaseGraphStorage = self.graph_storage_cls( # type: ignore
|
409 |
-
namespace=
|
410 |
-
self.namespace_prefix, NameSpace.GRAPH_STORE_CHUNK_ENTITY_RELATION
|
411 |
-
),
|
412 |
embedding_func=self.embedding_func,
|
413 |
)
|
414 |
|
415 |
self.entities_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore
|
416 |
-
namespace=
|
417 |
-
self.namespace_prefix, NameSpace.VECTOR_STORE_ENTITIES
|
418 |
-
),
|
419 |
embedding_func=self.embedding_func,
|
420 |
meta_fields={"entity_name", "source_id", "content", "file_path"},
|
421 |
)
|
422 |
self.relationships_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore
|
423 |
-
namespace=
|
424 |
-
self.namespace_prefix, NameSpace.VECTOR_STORE_RELATIONSHIPS
|
425 |
-
),
|
426 |
embedding_func=self.embedding_func,
|
427 |
meta_fields={"src_id", "tgt_id", "source_id", "content", "file_path"},
|
428 |
)
|
429 |
self.chunks_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore
|
430 |
-
namespace=
|
431 |
-
self.namespace_prefix, NameSpace.VECTOR_STORE_CHUNKS
|
432 |
-
),
|
433 |
embedding_func=self.embedding_func,
|
434 |
meta_fields={"full_doc_id", "content", "file_path"},
|
435 |
)
|
436 |
|
437 |
# Initialize document status storage
|
438 |
self.doc_status: DocStatusStorage = self.doc_status_storage_cls(
|
439 |
-
namespace=
|
440 |
global_config=global_config,
|
441 |
embedding_func=None,
|
442 |
)
|
|
|
51 |
StoragesStatus,
|
52 |
DeletionResult,
|
53 |
)
|
54 |
+
from .namespace import NameSpace
|
55 |
from .operate import (
|
56 |
chunking_by_token_size,
|
57 |
extract_entities,
|
|
|
242 |
vector_db_storage_cls_kwargs: dict[str, Any] = field(default_factory=dict)
|
243 |
"""Additional parameters for vector database storage."""
|
244 |
|
|
|
|
|
|
|
245 |
|
246 |
enable_llm_cache: bool = field(default=True)
|
247 |
"""Enables caching for LLM responses to avoid redundant computations."""
|
|
|
379 |
self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage)
|
380 |
|
381 |
self.llm_response_cache: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore
|
382 |
+
namespace=NameSpace.KV_STORE_LLM_RESPONSE_CACHE,
|
|
|
|
|
383 |
global_config=asdict(
|
384 |
self
|
385 |
), # Add global_config to ensure cache works properly
|
|
|
387 |
)
|
388 |
|
389 |
self.full_docs: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore
|
390 |
+
namespace=NameSpace.KV_STORE_FULL_DOCS,
|
|
|
|
|
391 |
embedding_func=self.embedding_func,
|
392 |
)
|
393 |
|
394 |
self.text_chunks: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore
|
395 |
+
namespace=NameSpace.KV_STORE_TEXT_CHUNKS,
|
|
|
|
|
396 |
embedding_func=self.embedding_func,
|
397 |
)
|
398 |
|
399 |
self.chunk_entity_relation_graph: BaseGraphStorage = self.graph_storage_cls( # type: ignore
|
400 |
+
namespace=NameSpace.GRAPH_STORE_CHUNK_ENTITY_RELATION,
|
|
|
|
|
401 |
embedding_func=self.embedding_func,
|
402 |
)
|
403 |
|
404 |
self.entities_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore
|
405 |
+
namespace=NameSpace.VECTOR_STORE_ENTITIES,
|
|
|
|
|
406 |
embedding_func=self.embedding_func,
|
407 |
meta_fields={"entity_name", "source_id", "content", "file_path"},
|
408 |
)
|
409 |
self.relationships_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore
|
410 |
+
namespace=NameSpace.VECTOR_STORE_RELATIONSHIPS,
|
|
|
|
|
411 |
embedding_func=self.embedding_func,
|
412 |
meta_fields={"src_id", "tgt_id", "source_id", "content", "file_path"},
|
413 |
)
|
414 |
self.chunks_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore
|
415 |
+
namespace=NameSpace.VECTOR_STORE_CHUNKS,
|
|
|
|
|
416 |
embedding_func=self.embedding_func,
|
417 |
meta_fields={"full_doc_id", "content", "file_path"},
|
418 |
)
|
419 |
|
420 |
# Initialize document status storage
|
421 |
self.doc_status: DocStatusStorage = self.doc_status_storage_cls(
|
422 |
+
namespace=NameSpace.DOC_STATUS,
|
423 |
global_config=global_config,
|
424 |
embedding_func=None,
|
425 |
)
|
lightrag/namespace.py
CHANGED
@@ -17,10 +17,6 @@ class NameSpace:
|
|
17 |
DOC_STATUS = "doc_status"
|
18 |
|
19 |
|
20 |
-
def make_namespace(prefix: str, base_namespace: str):
|
21 |
-
return prefix + base_namespace
|
22 |
-
|
23 |
-
|
24 |
def is_namespace(namespace: str, base_namespace: str | Iterable[str]):
|
25 |
if isinstance(base_namespace, str):
|
26 |
return namespace.endswith(base_namespace)
|
|
|
17 |
DOC_STATUS = "doc_status"
|
18 |
|
19 |
|
|
|
|
|
|
|
|
|
20 |
def is_namespace(namespace: str, base_namespace: str | Iterable[str]):
|
21 |
if isinstance(base_namespace, str):
|
22 |
return namespace.endswith(base_namespace)
|