diff --git a/litellm/tests/test_alangfuse.py b/litellm/tests/test_alangfuse.py index 29718d474..6c3830935 100644 --- a/litellm/tests/test_alangfuse.py +++ b/litellm/tests/test_alangfuse.py @@ -205,6 +205,8 @@ async def test_langfuse_logging_without_request_response(stream): assert _trace_data[0].output == { "role": "assistant", "content": "redacted-by-litellm", + "function_call": None, + "tool_calls": None, } except Exception as e: diff --git a/litellm/utils.py b/litellm/utils.py index 6b8aaaa5d..c4117bdb3 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -378,7 +378,7 @@ class Message(OpenAIObject): super(Message, self).__init__(**params) self.content = content self.role = role - self.tool_calls = [] + self.tool_calls = None self.function_call = None if function_call is not None: @@ -2531,13 +2531,19 @@ class Logging: "complete_streaming_response" ] for choice in _streaming_response.choices: - choice.message.content = "redacted-by-litellm" + if isinstance(choice, litellm.Choices): + choice.message.content = "redacted-by-litellm" + elif isinstance(choice, litellm.utils.StreamingChoices): + choice.delta.content = "redacted-by-litellm" else: if result is not None: if isinstance(result, litellm.ModelResponse): - if hasattr(result, "choices"): + if hasattr(result, "choices") and result.choices is not None: for choice in result.choices: - choice.message.content = "redacted-by-litellm" + if isinstance(choice, litellm.Choices): + choice.message.content = "redacted-by-litellm" + elif isinstance(choice, litellm.utils.StreamingChoices): + choice.delta.content = "redacted-by-litellm" def exception_logging(