From 1e8429bb20bee4abf41ff2f4a72f40670c652585 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 6 Jun 2024 10:38:15 -0700 Subject: [PATCH] feat - redact messages from slack alerting --- litellm/__init__.py | 1 + litellm/proxy/proxy_config.yaml | 4 +++- litellm/utils.py | 10 +++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 9fb614396..33ae7deab 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -60,6 +60,7 @@ _async_failure_callback: List[Callable] = ( pre_call_rules: List[Callable] = [] post_call_rules: List[Callable] = [] turn_off_message_logging: Optional[bool] = False +redact_messages_in_exceptions: Optional[bool] = False store_audit_logs = False # Enterprise feature, allow users to see audit logs ## end of callbacks ############# diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index 88fc0e913..2bef95acf 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -21,7 +21,9 @@ model_list: general_settings: master_key: sk-1234 + alerting: ["slack"] litellm_settings: callbacks: ["otel"] - store_audit_logs: true \ No newline at end of file + store_audit_logs: true + redact_messages_in_exceptions: True \ No newline at end of file diff --git a/litellm/utils.py b/litellm/utils.py index ba6a37467..91e6d9fab 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -7351,10 +7351,10 @@ def get_provider_fields(custom_llm_provider: str) -> List[ProviderField]: if custom_llm_provider == "databricks": return litellm.DatabricksConfig().get_required_params() - + elif custom_llm_provider == "ollama": return litellm.OllamaConfig().get_required_params() - + else: return [] @@ -8514,7 +8514,11 @@ def exception_type( extra_information = f"\nModel: {model}" if _api_base: extra_information += f"\nAPI Base: `{_api_base}`" - if messages and len(messages) > 0: + if ( + messages + and len(messages) > 0 + and litellm.redact_messages_in_exceptions is False + ): extra_information += f"\nMessages: `{messages}`" if _model_group is not None: