From 5a5d32dc329d115e56ecf353f4f597455e944333 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 24 Jul 2025 02:13:39 +0800 Subject: [PATCH] Optimize logger message --- lightrag/kg/milvus_impl.py | 2 +- lightrag/operate.py | 4 ++-- lightrag/utils.py | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lightrag/kg/milvus_impl.py b/lightrag/kg/milvus_impl.py index 8a13fd21..ef73a206 100644 --- a/lightrag/kg/milvus_impl.py +++ b/lightrag/kg/milvus_impl.py @@ -536,7 +536,7 @@ class MilvusVectorDBStorage(BaseVectorStorage): # Load the collection if it's not already loaded # In Milvus, collections need to be loaded before they can be searched self._client.load_collection(self.namespace) - logger.debug(f"Collection {self.namespace} loaded successfully") + # logger.debug(f"Collection {self.namespace} loaded successfully") except Exception as e: logger.error(f"Failed to load collection {self.namespace}: {e}") diff --git a/lightrag/operate.py b/lightrag/operate.py index ca8f9caa..b7319bcb 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -2795,7 +2795,7 @@ async def _find_related_text_unit_from_relationships( # Extract chunk IDs from entity_chunks entity_chunk_ids = set() for chunk in entity_chunks: - chunk_id = chunk.get("chunk_id") or chunk.get("id") + chunk_id = chunk.get("chunk_id") if chunk_id: entity_chunk_ids.add(chunk_id) @@ -2808,7 +2808,7 @@ async def _find_related_text_unit_from_relationships( ] logger.debug( - f"Deduplication with entity chunks: {original_count} -> {len(selected_chunk_ids)} chunks " + f"Deduplication relation-chunks with entity-chunks: {original_count} -> {len(selected_chunk_ids)} chunks " ) # Early return if no chunks remain after deduplication diff --git a/lightrag/utils.py b/lightrag/utils.py index dd1a3cf6..875d2b0f 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -85,8 +85,10 @@ def verbose_debug(msg: str, *args, **kwargs): formatted_msg = msg # Then truncate the formatted message truncated_msg = ( - formatted_msg[:100] + "..." if len(formatted_msg) > 100 else formatted_msg + formatted_msg[:150] + "..." if len(formatted_msg) > 150 else formatted_msg ) + # Remove consecutive newlines + truncated_msg = re.sub(r"\n+", "\n", truncated_msg) logger.debug(truncated_msg, **kwargs)