forked from phoenix/litellm-mirror
fix(redact_messages.py): fix get
This commit is contained in:
parent
4d9a0d45b2
commit
dc43ffb771
1 changed files with 15 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
import litellm
|
import litellm
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
@ -28,13 +29,24 @@ def redact_message_input_output_from_logging(
|
||||||
Removes messages, prompts, input, response from logging. This modifies the data in-place
|
Removes messages, prompts, input, response from logging. This modifies the data in-place
|
||||||
only redacts when litellm.turn_off_message_logging == True
|
only redacts when litellm.turn_off_message_logging == True
|
||||||
"""
|
"""
|
||||||
request_headers = litellm_logging_obj.model_call_details['litellm_params']['metadata']['headers']
|
_request_headers = (
|
||||||
|
litellm_logging_obj.model_call_details.get("litellm_params", {}).get(
|
||||||
|
"metadata", {}
|
||||||
|
)
|
||||||
|
or {}
|
||||||
|
)
|
||||||
|
|
||||||
|
request_headers = _request_headers.get("headers", {})
|
||||||
|
|
||||||
# check if user opted out of logging message/response to callbacks
|
# check if user opted out of logging message/response to callbacks
|
||||||
if litellm.turn_off_message_logging is not True and request_headers.get('litellm-enable-message-redaction', False):
|
if litellm.turn_off_message_logging is not True and request_headers.get(
|
||||||
|
"litellm-enable-message-redaction", False
|
||||||
|
):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if request_headers and request_headers.get('litellm-disable-message-redaction', False):
|
if request_headers and request_headers.get(
|
||||||
|
"litellm-disable-message-redaction", False
|
||||||
|
):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# remove messages, prompts, input, response from logging
|
# remove messages, prompts, input, response from logging
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue