From 1b2d295a4f9511c8be13786b2eb9ed1af016bca3 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sun, 6 Jul 2025 00:16:47 +0800 Subject: [PATCH] Remove namespace_prefix --- lightrag/lightrag.py | 35 +++++++++-------------------------- lightrag/namespace.py | 4 ---- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 47e484f0..17681f89 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -51,7 +51,7 @@ from .base import ( StoragesStatus, DeletionResult, ) -from .namespace import NameSpace, make_namespace +from .namespace import NameSpace from .operate import ( chunking_by_token_size, extract_entities, @@ -242,9 +242,6 @@ class LightRAG: vector_db_storage_cls_kwargs: dict[str, Any] = field(default_factory=dict) """Additional parameters for vector database storage.""" - # TODO:deprecated, remove in the future, use WORKSPACE instead - namespace_prefix: str = field(default="") - """Prefix for namespacing stored data across different environments.""" enable_llm_cache: bool = field(default=True) """Enables caching for LLM responses to avoid redundant computations.""" @@ -382,9 +379,7 @@ class LightRAG: self.doc_status_storage_cls = self._get_storage_class(self.doc_status_storage) self.llm_response_cache: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.KV_STORE_LLM_RESPONSE_CACHE - ), + namespace=NameSpace.KV_STORE_LLM_RESPONSE_CACHE, global_config=asdict( self ), # Add global_config to ensure cache works properly @@ -392,51 +387,39 @@ class LightRAG: ) self.full_docs: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.KV_STORE_FULL_DOCS - ), + namespace=NameSpace.KV_STORE_FULL_DOCS, embedding_func=self.embedding_func, ) self.text_chunks: BaseKVStorage = self.key_string_value_json_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.KV_STORE_TEXT_CHUNKS - ), + namespace=NameSpace.KV_STORE_TEXT_CHUNKS, embedding_func=self.embedding_func, ) self.chunk_entity_relation_graph: BaseGraphStorage = self.graph_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.GRAPH_STORE_CHUNK_ENTITY_RELATION - ), + namespace=NameSpace.GRAPH_STORE_CHUNK_ENTITY_RELATION, embedding_func=self.embedding_func, ) self.entities_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.VECTOR_STORE_ENTITIES - ), + namespace=NameSpace.VECTOR_STORE_ENTITIES, embedding_func=self.embedding_func, meta_fields={"entity_name", "source_id", "content", "file_path"}, ) self.relationships_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.VECTOR_STORE_RELATIONSHIPS - ), + namespace=NameSpace.VECTOR_STORE_RELATIONSHIPS, embedding_func=self.embedding_func, meta_fields={"src_id", "tgt_id", "source_id", "content", "file_path"}, ) self.chunks_vdb: BaseVectorStorage = self.vector_db_storage_cls( # type: ignore - namespace=make_namespace( - self.namespace_prefix, NameSpace.VECTOR_STORE_CHUNKS - ), + namespace=NameSpace.VECTOR_STORE_CHUNKS, embedding_func=self.embedding_func, meta_fields={"full_doc_id", "content", "file_path"}, ) # Initialize document status storage self.doc_status: DocStatusStorage = self.doc_status_storage_cls( - namespace=make_namespace(self.namespace_prefix, NameSpace.DOC_STATUS), + namespace=NameSpace.DOC_STATUS, global_config=global_config, embedding_func=None, ) diff --git a/lightrag/namespace.py b/lightrag/namespace.py index 77e04c9e..657d65ac 100644 --- a/lightrag/namespace.py +++ b/lightrag/namespace.py @@ -17,10 +17,6 @@ class NameSpace: DOC_STATUS = "doc_status" -def make_namespace(prefix: str, base_namespace: str): - return prefix + base_namespace - - def is_namespace(namespace: str, base_namespace: str | Iterable[str]): if isinstance(base_namespace, str): return namespace.endswith(base_namespace)