diff --git a/lightrag/base.py b/lightrag/base.py index b89e114d..9f891a7c 100644 --- a/lightrag/base.py +++ b/lightrag/base.py @@ -229,16 +229,21 @@ class BaseVectorStorage(StorageNameSpace, ABC): # Try to get model identifier from the embedding function # If it's a wrapped function (doesn't have get_model_identifier), # fallback to the original embedding_func from global_config - if hasattr(self.embedding_func, 'get_model_identifier'): + if hasattr(self.embedding_func, "get_model_identifier"): return self.embedding_func.get_model_identifier() - elif 'embedding_func' in self.global_config: - original_embedding_func = self.global_config['embedding_func'] - if original_embedding_func is not None and hasattr(original_embedding_func, 'get_model_identifier'): + elif "embedding_func" in self.global_config: + original_embedding_func = self.global_config["embedding_func"] + if original_embedding_func is not None and hasattr( + original_embedding_func, "get_model_identifier" + ): return original_embedding_func.get_model_identifier() else: # Debug: log why we couldn't get model identifier from lightrag.utils import logger - logger.debug(f"Could not get model_identifier: embedding_func is {type(original_embedding_func)}, has method={hasattr(original_embedding_func, 'get_model_identifier') if original_embedding_func else False}") + + logger.debug( + f"Could not get model_identifier: embedding_func is {type(original_embedding_func)}, has method={hasattr(original_embedding_func, 'get_model_identifier') if original_embedding_func else False}" + ) # Fallback: no model identifier available return "" diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index dd7afcc7..c18a3b4b 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -2316,10 +2316,10 @@ class PGVectorStorage(BaseVectorStorage): while True: # Fetch a batch of rows - select_query = ( - f"SELECT * FROM {legacy_table_name} OFFSET $1 LIMIT $2" + select_query = f"SELECT * FROM {legacy_table_name} OFFSET $1 LIMIT $2" + rows = await db.query( + select_query, [offset, batch_size], multirows=True ) - rows = await db.query(select_query, [offset, batch_size], multirows=True) if not rows: break @@ -2561,7 +2561,9 @@ class PGVectorStorage(BaseVectorStorage): if not ids: return - delete_sql = f"DELETE FROM {self.table_name} WHERE workspace=$1 AND id = ANY($2)" + delete_sql = ( + f"DELETE FROM {self.table_name} WHERE workspace=$1 AND id = ANY($2)" + ) try: await self.db.execute(delete_sql, {"workspace": self.workspace, "ids": ids}) @@ -3359,6 +3361,7 @@ class PGDocStatusStorage(DocStatusStorage): class PostgreSQLMigrationError(Exception): """Exception for PostgreSQL table migration errors.""" + pass diff --git a/lightrag/kg/qdrant_impl.py b/lightrag/kg/qdrant_impl.py index e4d08b71..6b0db51f 100644 --- a/lightrag/kg/qdrant_impl.py +++ b/lightrag/kg/qdrant_impl.py @@ -300,7 +300,7 @@ class QdrantVectorDBStorage(BaseVectorStorage): # New naming scheme with model isolation # Example: "lightrag_vdb_chunks_text_embedding_ada_002_1536d" self.final_namespace = f"lightrag_vdb_{self.namespace}_{model_suffix}" - + logger.info( f"Qdrant collection naming: " f"new='{self.final_namespace}', " diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 9fd5a4b3..6618c955 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -533,7 +533,7 @@ class LightRAG: # Fix global_config now global_config = asdict(self) # Restore original EmbeddingFunc object (asdict converts it to dict) - global_config['embedding_func'] = original_embedding_func + global_config["embedding_func"] = original_embedding_func _print_config = ",\n ".join([f"{k} = {v}" for k, v in global_config.items()]) logger.debug(f"LightRAG init with param:\n {_print_config}\n") diff --git a/lightrag/utils.py b/lightrag/utils.py index 66104f1e..3a640d07 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -381,7 +381,7 @@ class EmbeddingFunc: """ model_part = self.model_name if self.model_name else "unknown" # Clean model name: remove special chars, convert to lower, replace - with _ - safe_model_name = re.sub(r'[^a-zA-Z0-9_]', '_', model_part.lower()) + safe_model_name = re.sub(r"[^a-zA-Z0-9_]", "_", model_part.lower()) return f"{safe_model_name}_{self.embedding_dim}d" async def __call__(self, *args, **kwargs) -> np.ndarray: