The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
revert changes to redaction
Ishaan Jaffer9fff639b93a1
diff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.pyindex 17f3ceb7716..0effed3db70 100644--- a/litellm/litellm_core_utils/redact_messages.py+++ b/litellm/litellm_core_utils/redact_messages.py@@ -42,52 +42,43 @@ def redact_message_input_output_from_custom_logger(def _redact_choice_content(choice):"""Helper to redact content in a choice (message or delta)."""- from litellm.types.utils import LiteLLMCommonStrings- redacted_str = LiteLLMCommonStrings.redacted_by_litellm.value-if isinstance(choice, litellm.Choices):- choice.message.content = redacted_str+ choice.message.content = "redacted-by-litellm"if hasattr(choice.message, "reasoning_content"):- choice.message.reasoning_content = redacted_str+ choice.message.reasoning_content = "redacted-by-litellm"if hasattr(choice.message, "thinking_blocks"):choice.message.thinking_blocks = Noneelif isinstance(choice, litellm.utils.StreamingChoices):- choice.delta.content = redacted_str+ choice.delta.content = "redacted-by-litellm"if hasattr(choice.delta, "reasoning_content"):- choice.delta.reasoning_content = redacted_str+ choice.delta.reasoning_content = "redacted-by-litellm"if hasattr(choice.delta, "thinking_blocks"):choice.delta.thinking_blocks = Nonedef _redact_responses_api_output(output_items):"""Helper to redact ResponsesAPIResponse output items."""- from litellm.types.utils import LiteLLMCommonStrings- redacted_str = LiteLLMCommonStrings.redacted_by_litellm.value-for output_item in output_items:if hasattr(output_item, "content") and isinstance(output_item.content, list):for content_part in output_item.content:if hasattr(content_part, "text"):- content_part.text = redacted_str+ content_part.text = "redacted-by-litellm"# Redact reasoning items in output arrayif hasattr(output_item, "type") and output_item.type == "reasoning":if hasattr(output_item, "summary") and isinstance(output_item.summary, list):for summary_item in output_item.summary:if hasattr(summary_item, "text"):- summary_item.text = redacted_str+ summary_item.text = "redacted-by-litellm"def perform_redaction(model_call_details: dict, result):"""Performs the actual redaction on the logging object and result."""- from litellm.types.utils import LiteLLMCommonStrings- redacted_str = LiteLLMCommonStrings.redacted_by_litellm.value-# Redact model_call_detailsmodel_call_details["messages"] = [- {"role": "user", "content": redacted_str}+ {"role": "user", "content": "redacted-by-litellm"}]model_call_details["prompt"] = ""model_call_details["input"] = ""@@ -115,7 +106,7 @@ def perform_redaction(model_call_details: dict, result):hasattr(result, '__aiter__') or # async generatorhasattr(result, '__anext__')): # async iterator# For async objects, return a simple redacted response without deepcopy- return {"text": redacted_str}+ return {"text": "redacted-by-litellm"}_result = copy.deepcopy(result)if isinstance(_result, litellm.ModelResponse):@@ -132,7 +123,7 @@ def perform_redaction(model_call_details: dict, result):if hasattr(_result, "data") and _result.data is not None:_result.data = []else:- return {"text": redacted_str}+ return {"text": "redacted-by-litellm"}return _result