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
(fixes) datadog logging - handle 1MB max log size on DD (#6996)
Ishaan Jaff5e5d61d9dbf9
diff --git a/tests/logging_callback_tests/test_standard_logging_payload.py b/tests/logging_callback_tests/test_standard_logging_payload.pyindex 76423e1ab48..533c3a70b16 100644--- a/tests/logging_callback_tests/test_standard_logging_payload.py+++ b/tests/logging_callback_tests/test_standard_logging_payload.py@@ -329,6 +329,45 @@ def test_get_final_response_obj():litellm.turn_off_message_logging = False++def test_truncate_standard_logging_payload():+ """+ 1. original messages, response, and error_str should NOT BE MODIFIED, since these are from kwargs+ 2. the `messages`, `response`, and `error_str` in new standard_logging_payload should be truncated+ """+ standard_logging_payload: StandardLoggingPayload = (+ create_standard_logging_payload_with_long_content()+ )+ original_messages = standard_logging_payload["messages"]+ len_original_messages = len(str(original_messages))+ original_response = standard_logging_payload["response"]+ len_original_response = len(str(original_response))+ original_error_str = standard_logging_payload["error_str"]+ len_original_error_str = len(str(original_error_str))++ truncate_standard_logging_payload_content(standard_logging_payload)++ # Original messages, response, and error_str should NOT BE MODIFIED+ assert standard_logging_payload["messages"] != original_messages+ assert standard_logging_payload["response"] != original_response+ assert standard_logging_payload["error_str"] != original_error_str+ assert len_original_messages == len(str(original_messages))+ assert len_original_response == len(str(original_response))+ assert len_original_error_str == len(str(original_error_str))++ print(+ "logged standard_logging_payload",+ json.dumps(standard_logging_payload, indent=2),+ )++ # Logged messages, response, and error_str should be truncated+ # assert len of messages is less than 10_500+ assert len(str(standard_logging_payload["messages"])) < 10_500+ # assert len of response is less than 10_500+ assert len(str(standard_logging_payload["response"])) < 10_500+ # assert len of error_str is less than 10_500+ assert len(str(standard_logging_payload["error_str"])) < 10_500+def test_strip_trailing_slash():common_api_base = "https://api.test.com"assert (@@ -339,3 +378,4 @@ def test_strip_trailing_slash():StandardLoggingPayloadSetup.strip_trailing_slash(common_api_base)== common_api_base)+