fix linting

This commit is contained in:
zrguo
2025-03-11 15:44:01 +08:00
parent 62b304600b
commit 418aea3895
3 changed files with 15 additions and 11 deletions

View File

@@ -1294,14 +1294,14 @@ class LightRAG:
): ):
""" """
Query with separate keyword extraction step. Query with separate keyword extraction step.
This method extracts keywords from the query first, then uses them for the query. This method extracts keywords from the query first, then uses them for the query.
Args: Args:
query: User query query: User query
prompt: Additional prompt for the query prompt: Additional prompt for the query
param: Query parameters param: Query parameters
Returns: Returns:
Query response Query response
""" """
@@ -1315,12 +1315,12 @@ class LightRAG:
) -> str | AsyncIterator[str]: ) -> str | AsyncIterator[str]:
""" """
Async version of query_with_separate_keyword_extraction. Async version of query_with_separate_keyword_extraction.
Args: Args:
query: User query query: User query
prompt: Additional prompt for the query prompt: Additional prompt for the query
param: Query parameters param: Query parameters
Returns: Returns:
Query response or async iterator Query response or async iterator
""" """
@@ -1336,7 +1336,7 @@ class LightRAG:
global_config=asdict(self), global_config=asdict(self),
hashing_kv=self.llm_response_cache, hashing_kv=self.llm_response_cache,
) )
await self._query_done() await self._query_done()
return response return response

View File

@@ -1917,6 +1917,7 @@ async def kg_query_with_keywords(
return response return response
async def query_with_keywords( async def query_with_keywords(
query: str, query: str,
prompt: str, prompt: str,
@@ -1931,11 +1932,11 @@ async def query_with_keywords(
) -> str | AsyncIterator[str]: ) -> str | AsyncIterator[str]:
""" """
Extract keywords from the query and then use them for retrieving information. Extract keywords from the query and then use them for retrieving information.
1. Extracts high-level and low-level keywords from the query 1. Extracts high-level and low-level keywords from the query
2. Formats the query with the extracted keywords and prompt 2. Formats the query with the extracted keywords and prompt
3. Uses the appropriate query method based on param.mode 3. Uses the appropriate query method based on param.mode
Args: Args:
query: The user's query query: The user's query
prompt: Additional prompt to prepend to the query prompt: Additional prompt to prepend to the query
@@ -1947,7 +1948,7 @@ async def query_with_keywords(
text_chunks_db: Text chunks storage text_chunks_db: Text chunks storage
global_config: Global configuration global_config: Global configuration
hashing_kv: Cache storage hashing_kv: Cache storage
Returns: Returns:
Query response or async iterator Query response or async iterator
""" """

View File

@@ -891,6 +891,7 @@ def lazy_external_import(module_name: str, class_name: str) -> Callable[..., Any
return import_class return import_class
def get_content_summary(content: str, max_length: int = 100) -> str: def get_content_summary(content: str, max_length: int = 100) -> str:
"""Get summary of document content """Get summary of document content
@@ -906,6 +907,7 @@ def get_content_summary(content: str, max_length: int = 100) -> str:
return content return content
return content[:max_length] + "..." return content[:max_length] + "..."
def clean_text(text: str) -> str: def clean_text(text: str) -> str:
"""Clean text by removing null bytes (0x00) and whitespace """Clean text by removing null bytes (0x00) and whitespace
@@ -917,6 +919,7 @@ def clean_text(text: str) -> str:
""" """
return text.strip().replace("\x00", "") return text.strip().replace("\x00", "")
def check_storage_env_vars(storage_name: str) -> None: def check_storage_env_vars(storage_name: str) -> None:
"""Check if all required environment variables for storage implementation exist """Check if all required environment variables for storage implementation exist
@@ -927,7 +930,7 @@ def check_storage_env_vars(storage_name: str) -> None:
ValueError: If required environment variables are missing ValueError: If required environment variables are missing
""" """
from lightrag.kg import STORAGE_ENV_REQUIREMENTS from lightrag.kg import STORAGE_ENV_REQUIREMENTS
required_vars = STORAGE_ENV_REQUIREMENTS.get(storage_name, []) required_vars = STORAGE_ENV_REQUIREMENTS.get(storage_name, [])
missing_vars = [var for var in required_vars if var not in os.environ] missing_vars = [var for var in required_vars if var not in os.environ]
@@ -935,4 +938,4 @@ def check_storage_env_vars(storage_name: str) -> None:
raise ValueError( raise ValueError(
f"Storage implementation '{storage_name}' requires the following " f"Storage implementation '{storage_name}' requires the following "
f"environment variables: {', '.join(missing_vars)}" f"environment variables: {', '.join(missing_vars)}"
) )