mirror of
https://github.com/tiennm99/litellm.git
synced 2026-06-17 22:48:35 +00:00
c7a22921dc
Adds a new config option to exclude specific fields from StandardLoggingPayload before any callback receives it. This provides a general approach to control what data is logged across ALL integrations (S3, GCS, Datadog, etc.). ## Changes 1. **litellm/__init__.py**: Added new global setting `standard_logging_payload_excluded_fields: Optional[List[str]] = None` 2. **litellm/integrations/custom_logger.py**: Modified `redact_standard_logging_payload_from_model_call_details()` to: - Remove specified fields entirely from the StandardLoggingPayload - Works alongside existing `turn_off_message_logging` feature - Excluded fields take precedence (removed rather than redacted) 3. **tests/**: Added comprehensive test suite with 17 tests covering: - Single/multiple field exclusion - Interaction with turn_off_message_logging - Original payload immutability - Config loading via setattr (proxy pattern) - Edge cases (empty list, non-existent fields, None standard_logging_object) ## Usage ```yaml litellm_settings: success_callback: ["s3"] standard_logging_payload_excluded_fields: ["response", "messages"] ``` This removes the `response` and `messages` fields from logs before any callback processes them, reducing log size and improving privacy compliance. ## Available Fields The fields match StandardLoggingPayload TypedDict keys including: - messages, response (large payload fields) - metadata, hidden_params, model_parameters - error_str, error_information - And all other StandardLoggingPayload fields Closes the need for per-integration flags like `s3_log_response`.