From 44f4c623e2a94024c63f2d212c3683ead14727d4 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 22 Mar 2025 11:38:30 -0700 Subject: [PATCH] Add annotations to the delta --- litellm/types/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 58c78dfa292..8821d2c80bd 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -630,6 +630,7 @@ class Delta(OpenAIObject): audio: Optional[ChatCompletionAudioResponse] = None, reasoning_content: Optional[str] = None, thinking_blocks: Optional[List[ChatCompletionThinkingBlock]] = None, + annotations: Optional[List[ChatCompletionAnnotation]] = None, **params, ): super(Delta, self).__init__(**params) @@ -640,6 +641,7 @@ class Delta(OpenAIObject): self.function_call: Optional[Union[FunctionCall, Any]] = None self.tool_calls: Optional[List[Union[ChatCompletionDeltaToolCall, Any]]] = None self.audio: Optional[ChatCompletionAudioResponse] = None + self.annotations: Optional[List[ChatCompletionAnnotation]] = None if reasoning_content is not None: self.reasoning_content = reasoning_content @@ -653,6 +655,12 @@ class Delta(OpenAIObject): # ensure default response matches OpenAI spec del self.thinking_blocks + # Add annotations to the delta, ensure they are only on Delta if they exist (Match OpenAI spec) + if annotations is not None: + self.annotations = annotations + else: + del self.annotations + if function_call is not None and isinstance(function_call, dict): self.function_call = FunctionCall(**function_call) else: