Add annotations to the delta

This commit is contained in:
Ishaan Jaff 2025-03-22 11:38:30 -07:00
parent 5c59a6a58f
commit 44f4c623e2

View file

@ -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: