style: fix lint issues (trailing whitespace and formatting)

This commit is contained in:
BukeLy 2025-11-20 01:28:39 +08:00
parent e9f6cedff8
commit 088b986ac6
5 changed files with 20 additions and 12 deletions

View file

@ -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 ""

View file

@ -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

View file

@ -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}', "

View file

@ -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")

View file

@ -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: