Skip to content

Commit 0ce476a

Browse files
test(test_custom_callback.py): add test for message redaction to standard logging object
1 parent 8ce8680 commit 0ce476a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

litellm/tests/test_custom_callback_input.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,13 @@ def test_turn_off_message_logging():
11721172

11731173

11741174
@pytest.mark.parametrize("model", ["gpt-3.5-turbo", "azure/chatgpt-v-2"])
1175-
def test_standard_logging_payload(model):
1175+
@pytest.mark.parametrize(
1176+
"turn_off_message_logging",
1177+
[
1178+
True,
1179+
],
1180+
) # False
1181+
def test_standard_logging_payload(model, turn_off_message_logging):
11761182
"""
11771183
Ensure valid standard_logging_payload is passed for logging calls to s3
11781184
@@ -1184,6 +1190,8 @@ def test_standard_logging_payload(model):
11841190
customHandler = CompletionCustomHandler()
11851191
litellm.callbacks = [customHandler]
11861192

1193+
litellm.turn_off_message_logging = turn_off_message_logging
1194+
11871195
with patch.object(
11881196
customHandler, "log_success_event", new=MagicMock()
11891197
) as mock_client:
@@ -1237,3 +1245,10 @@ def test_standard_logging_payload(model):
12371245
]["model_map_value"]
12381246
is not None
12391247
)
1248+
1249+
## turn off message logging
1250+
slobject: StandardLoggingPayload = mock_client.call_args.kwargs["kwargs"][
1251+
"standard_logging_object"
1252+
]
1253+
if turn_off_message_logging:
1254+
assert "redacted-by-litellm" == slobject["messages"][0]["content"]

0 commit comments

Comments
 (0)