Merge pull request #4352 from msabramo/msabramo/turn-on-message-logging-via-request-header

Disable message redaction in logs via request header
This commit is contained in:
Krish Dholakia 2024-06-22 21:30:41 -07:00 • committed by GitHub
commit 9bffa9a48e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -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

View file

@ -28,8 +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
if request_headers and request_headers.get('litellm-disable-message-redaction', False):
return result
# remove messages, prompts, input, response from logging