fixes to CLI
This commit is contained in:
parent
75ea520a1f
commit
c933290886
2 changed files with 93 additions and 4 deletions
|
|
@ -87,12 +87,12 @@ After successful cognify processing, use `cognee search` to query the knowledge
|
||||||
async def run_cognify():
|
async def run_cognify():
|
||||||
try:
|
try:
|
||||||
# Import chunker classes here
|
# Import chunker classes here
|
||||||
from cognee.modules.chunking import TextChunker
|
from cognee.modules.chunking.TextChunker import TextChunker
|
||||||
|
|
||||||
chunker_class = TextChunker # Default
|
chunker_class = TextChunker # Default
|
||||||
if args.chunker == "LangchainChunker":
|
if args.chunker == "LangchainChunker":
|
||||||
try:
|
try:
|
||||||
from cognee.modules.chunking import LangchainChunker
|
from cognee.modules.chunking.LangchainChunker import LangchainChunker
|
||||||
|
|
||||||
chunker_class = LangchainChunker
|
chunker_class = LangchainChunker
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,43 @@ from typing import Protocol
|
||||||
# Configure external library logging
|
# Configure external library logging
|
||||||
def configure_external_library_logging():
|
def configure_external_library_logging():
|
||||||
"""Configure logging for external libraries to reduce verbosity"""
|
"""Configure logging for external libraries to reduce verbosity"""
|
||||||
|
# Set environment variables to suppress LiteLLM logging
|
||||||
|
os.environ.setdefault("LITELLM_LOG", "ERROR")
|
||||||
|
os.environ.setdefault("LITELLM_SET_VERBOSE", "False")
|
||||||
|
|
||||||
# Configure LiteLLM logging to reduce verbosity
|
# Configure LiteLLM logging to reduce verbosity
|
||||||
try:
|
try:
|
||||||
import litellm
|
import litellm
|
||||||
|
|
||||||
|
# Disable verbose logging
|
||||||
litellm.set_verbose = False
|
litellm.set_verbose = False
|
||||||
|
|
||||||
|
# Set additional LiteLLM configuration
|
||||||
|
if hasattr(litellm, 'suppress_debug_info'):
|
||||||
|
litellm.suppress_debug_info = True
|
||||||
|
if hasattr(litellm, 'turn_off_message'):
|
||||||
|
litellm.turn_off_message = True
|
||||||
|
if hasattr(litellm, '_turn_on_debug'):
|
||||||
|
litellm._turn_on_debug = False
|
||||||
|
|
||||||
# Suppress LiteLLM ERROR logging using standard logging
|
# Comprehensive logger suppression
|
||||||
logging.getLogger("litellm").setLevel(logging.CRITICAL)
|
loggers_to_suppress = [
|
||||||
|
"litellm",
|
||||||
|
"litellm.litellm_core_utils.logging_worker",
|
||||||
|
"litellm.litellm_core_utils",
|
||||||
|
"litellm.proxy",
|
||||||
|
"litellm.router",
|
||||||
|
"openai._base_client",
|
||||||
|
"LiteLLM", # Capital case variant
|
||||||
|
"LiteLLM.core",
|
||||||
|
"LiteLLM.logging_worker",
|
||||||
|
"litellm.logging_worker"
|
||||||
|
]
|
||||||
|
|
||||||
|
for logger_name in loggers_to_suppress:
|
||||||
|
logging.getLogger(logger_name).setLevel(logging.CRITICAL)
|
||||||
|
logging.getLogger(logger_name).disabled = True
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# LiteLLM not available, skip configuration
|
# LiteLLM not available, skip configuration
|
||||||
pass
|
pass
|
||||||
|
|
@ -243,6 +272,66 @@ def setup_logging(log_level=None, name=None):
|
||||||
|
|
||||||
# Configure external library logging early to suppress verbose output
|
# Configure external library logging early to suppress verbose output
|
||||||
configure_external_library_logging()
|
configure_external_library_logging()
|
||||||
|
|
||||||
|
# Add custom filter to suppress LiteLLM worker cancellation errors
|
||||||
|
class LiteLLMCancellationFilter(logging.Filter):
|
||||||
|
"""Filter to suppress LiteLLM worker cancellation messages"""
|
||||||
|
|
||||||
|
def filter(self, record):
|
||||||
|
# Check if this is a LiteLLM-related logger
|
||||||
|
if hasattr(record, 'name') and 'litellm' in record.name.lower():
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check message content for cancellation errors
|
||||||
|
if hasattr(record, 'msg') and record.msg:
|
||||||
|
msg_str = str(record.msg).lower()
|
||||||
|
if any(keyword in msg_str for keyword in [
|
||||||
|
'loggingworker cancelled',
|
||||||
|
'logging_worker.py',
|
||||||
|
'cancellederror',
|
||||||
|
'litellm:error'
|
||||||
|
]):
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check formatted message
|
||||||
|
try:
|
||||||
|
if hasattr(record, 'getMessage'):
|
||||||
|
formatted_msg = record.getMessage().lower()
|
||||||
|
if any(keyword in formatted_msg for keyword in [
|
||||||
|
'loggingworker cancelled',
|
||||||
|
'logging_worker.py',
|
||||||
|
'cancellederror',
|
||||||
|
'litellm:error'
|
||||||
|
]):
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Apply the filter to root logger and specific loggers
|
||||||
|
cancellation_filter = LiteLLMCancellationFilter()
|
||||||
|
logging.getLogger().addFilter(cancellation_filter)
|
||||||
|
logging.getLogger('litellm').addFilter(cancellation_filter)
|
||||||
|
|
||||||
|
# Add custom filter to suppress LiteLLM worker cancellation errors
|
||||||
|
class LiteLLMFilter(logging.Filter):
|
||||||
|
def filter(self, record):
|
||||||
|
# Suppress LiteLLM worker cancellation errors
|
||||||
|
if hasattr(record, 'msg') and isinstance(record.msg, str):
|
||||||
|
msg_lower = record.msg.lower()
|
||||||
|
if any(phrase in msg_lower for phrase in [
|
||||||
|
'loggingworker cancelled',
|
||||||
|
'cancellederror',
|
||||||
|
'logging_worker.py',
|
||||||
|
'loggingerror'
|
||||||
|
]):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Apply filter to root logger
|
||||||
|
litellm_filter = LiteLLMFilter()
|
||||||
|
logging.getLogger().addFilter(litellm_filter)
|
||||||
|
|
||||||
def exception_handler(logger, method_name, event_dict):
|
def exception_handler(logger, method_name, event_dict):
|
||||||
"""Custom processor to handle uncaught exceptions."""
|
"""Custom processor to handle uncaught exceptions."""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue