From 91e2b661ca75e4a7f435bb6e1b9f69a85602ad88 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Fri, 21 Jun 2024 20:21:19 -0700 Subject: [PATCH 1/3] Turn on message logging via request header --- litellm/litellm_core_utils/redact_messages.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.py index 8f270d8bec0..91f340cb803 100644 --- a/litellm/litellm_core_utils/redact_messages.py +++ b/litellm/litellm_core_utils/redact_messages.py @@ -32,6 +32,10 @@ def redact_message_input_output_from_logging( if litellm.turn_off_message_logging is not True: return result + request_headers = litellm_logging_obj.model_call_details['litellm_params']['metadata']['headers'] + if request_headers and request_headers.get('litellm-turn-on-message-logging', False): + return result + # remove messages, prompts, input, response from logging litellm_logging_obj.model_call_details["messages"] = [ {"role": "user", "content": "redacted-by-litellm"} From b7452cb38371578b0ee111e0322af70c6e7f91d0 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Fri, 21 Jun 2024 21:52:55 -0700 Subject: [PATCH 2/3] Rename request header --- litellm/litellm_core_utils/redact_messages.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.py index 91f340cb803..cc616afec22 100644 --- a/litellm/litellm_core_utils/redact_messages.py +++ b/litellm/litellm_core_utils/redact_messages.py @@ -28,12 +28,13 @@ def redact_message_input_output_from_logging( Removes messages, prompts, input, response from logging. This modifies the data in-place only redacts when litellm.turn_off_message_logging == True """ + request_headers = litellm_logging_obj.model_call_details['litellm_params']['metadata']['headers'] + # check if user opted out of logging message/response to callbacks - if litellm.turn_off_message_logging is not True: + if litellm.turn_off_message_logging is not True and request_headers.get('litellm-enable-message-redaction', False): return result - request_headers = litellm_logging_obj.model_call_details['litellm_params']['metadata']['headers'] - if request_headers and request_headers.get('litellm-turn-on-message-logging', False): + if request_headers and request_headers.get('litellm-disable-message-redaction', False): return result # remove messages, prompts, input, response from logging From 54bf89fa27cf7b9b1ed137ac93f6fc6d52a0210c Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Fri, 21 Jun 2024 22:10:31 -0700 Subject: [PATCH 3/3] Document feature --- docs/my-website/docs/proxy/logging.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/my-website/docs/proxy/logging.md b/docs/my-website/docs/proxy/logging.md index e9be2b837b5..f9ed5db3ddc 100644 --- a/docs/my-website/docs/proxy/logging.md +++ b/docs/my-website/docs/proxy/logging.md @@ -210,6 +210,24 @@ litellm_settings: turn_off_message_logging: True ``` +If you have this feature turned on, you can override it for specific requests by +setting a request header `LiteLLM-Disable-Message-Redaction: true`. + +```shell +curl --location 'http://0.0.0.0:4000/chat/completions' \ + --header 'Content-Type: application/json' \ + --header 'LiteLLM-Disable-Message-Redaction: true' \ + --data '{ + "model": "gpt-3.5-turbo", + "messages": [ + { + "role": "user", + "content": "what llm are you" + } + ] +}' +``` + ### 🔧 Debugging - Viewing RAW CURL sent from LiteLLM to provider Use this when you want to view the RAW curl request sent from LiteLLM to the LLM API