mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(logging): fix turn_off_message_logging redaction for standard logging payload
Two bugs in the redaction path for standard_logging_object["response"]:
1. get_final_response_obj was passing a plain dict (from model_dump()) into
redact_message_input_output_from_logging. perform_redaction only handles
ModelResponse/EmbeddingResponse/ResponsesAPIResponse -- a plain dict hits
the else branch and returns {"text": "redacted-by-litellm"}, destroying
the choices structure. Fix: pass init_response_obj (the original BaseModel)
to redaction so isinstance checks work correctly, then call model_dump()
on the result.
2. _redact_choice_content was not nulling choice.message.audio, so audio
model responses (gpt-4o-audio-preview) kept the full audio blob in the
logged payload even with turn_off_message_logging=True. Fix: set
choice.message.audio = None alongside content redaction.
Fixes:
test_standard_logging_payload[True-ft:gpt-3.5-turbo:my-org:custom_suffix:id]
test_standard_logging_payload_audio[True-False]
test_standard_logging_payload_audio[True-True]
This commit is contained in:
parent
fc81edc4c4
commit
5700c06689
2 changed files with 10 additions and 1 deletions
|
|
@ -4827,9 +4827,16 @@ class StandardLoggingPayloadSetup:
|
|||
else:
|
||||
final_response_obj = {}
|
||||
|
||||
# Pass the original BaseModel object to redaction so isinstance checks inside
|
||||
# perform_redaction work correctly (a plain dict never matches ModelResponse etc.)
|
||||
redaction_input = (
|
||||
init_response_obj
|
||||
if isinstance(init_response_obj, BaseModel)
|
||||
else final_response_obj
|
||||
)
|
||||
modified_final_response_obj = redact_message_input_output_from_logging(
|
||||
model_call_details=kwargs,
|
||||
result=final_response_obj,
|
||||
result=redaction_input,
|
||||
)
|
||||
|
||||
if modified_final_response_obj is not None and isinstance(
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ def _redact_choice_content(choice):
|
|||
choice.message.reasoning_content = "redacted-by-litellm"
|
||||
if hasattr(choice.message, "thinking_blocks"):
|
||||
choice.message.thinking_blocks = None
|
||||
if hasattr(choice.message, "audio"):
|
||||
choice.message.audio = None
|
||||
elif isinstance(choice, litellm.utils.StreamingChoices):
|
||||
choice.delta.content = "redacted-by-litellm"
|
||||
if hasattr(choice.delta, "reasoning_content"):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue