From b54ab2f86fd19a5b5861f87941b4a9de57bf6c7a Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:25:10 +0100 Subject: [PATCH] chore(types): include discriminators in unions (#1228) --- src/openai/types/beta/assistant.py | 5 +++-- src/openai/types/beta/threads/message_content_text.py | 7 +++++-- src/openai/types/beta/threads/runs/code_tool_call.py | 7 +++++-- src/openai/types/beta/threads/runs/run_step.py | 5 +++-- .../types/beta/threads/runs/tool_calls_step_details.py | 5 +++-- src/openai/types/beta/threads/thread_message.py | 5 +++-- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/openai/types/beta/assistant.py b/src/openai/types/beta/assistant.py index 7a29984b50..7ba50652aa 100644 --- a/src/openai/types/beta/assistant.py +++ b/src/openai/types/beta/assistant.py @@ -1,9 +1,10 @@ # File generated from our OpenAPI spec by Stainless. from typing import List, Union, Optional -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from ..shared import FunctionDefinition +from ..._utils import PropertyInfo from ..._models import BaseModel __all__ = ["Assistant", "Tool", "ToolCodeInterpreter", "ToolRetrieval", "ToolFunction"] @@ -26,7 +27,7 @@ class ToolFunction(BaseModel): """The type of tool being defined: `function`""" -Tool = Union[ToolCodeInterpreter, ToolRetrieval, ToolFunction] +Tool = Annotated[Union[ToolCodeInterpreter, ToolRetrieval, ToolFunction], PropertyInfo(discriminator="type")] class Assistant(BaseModel): diff --git a/src/openai/types/beta/threads/message_content_text.py b/src/openai/types/beta/threads/message_content_text.py index b529a384c6..dd05ff96ca 100644 --- a/src/openai/types/beta/threads/message_content_text.py +++ b/src/openai/types/beta/threads/message_content_text.py @@ -1,8 +1,9 @@ # File generated from our OpenAPI spec by Stainless. from typing import List, Union -from typing_extensions import Literal +from typing_extensions import Literal, Annotated +from ...._utils import PropertyInfo from ...._models import BaseModel __all__ = [ @@ -57,7 +58,9 @@ class TextAnnotationFilePath(BaseModel): """Always `file_path`.""" -TextAnnotation = Union[TextAnnotationFileCitation, TextAnnotationFilePath] +TextAnnotation = Annotated[ + Union[TextAnnotationFileCitation, TextAnnotationFilePath], PropertyInfo(discriminator="type") +] class Text(BaseModel): diff --git a/src/openai/types/beta/threads/runs/code_tool_call.py b/src/openai/types/beta/threads/runs/code_tool_call.py index f808005ecb..0de47b379b 100644 --- a/src/openai/types/beta/threads/runs/code_tool_call.py +++ b/src/openai/types/beta/threads/runs/code_tool_call.py @@ -1,8 +1,9 @@ # File generated from our OpenAPI spec by Stainless. from typing import List, Union -from typing_extensions import Literal +from typing_extensions import Literal, Annotated +from ....._utils import PropertyInfo from ....._models import BaseModel __all__ = [ @@ -38,7 +39,9 @@ class CodeInterpreterOutputImage(BaseModel): """Always `image`.""" -CodeInterpreterOutput = Union[CodeInterpreterOutputLogs, CodeInterpreterOutputImage] +CodeInterpreterOutput = Annotated[ + Union[CodeInterpreterOutputLogs, CodeInterpreterOutputImage], PropertyInfo(discriminator="type") +] class CodeInterpreter(BaseModel): diff --git a/src/openai/types/beta/threads/runs/run_step.py b/src/openai/types/beta/threads/runs/run_step.py index 01aab8e9a6..899883ac2d 100644 --- a/src/openai/types/beta/threads/runs/run_step.py +++ b/src/openai/types/beta/threads/runs/run_step.py @@ -1,8 +1,9 @@ # File generated from our OpenAPI spec by Stainless. from typing import Union, Optional -from typing_extensions import Literal +from typing_extensions import Literal, Annotated +from ....._utils import PropertyInfo from ....._models import BaseModel from .tool_calls_step_details import ToolCallsStepDetails from .message_creation_step_details import MessageCreationStepDetails @@ -18,7 +19,7 @@ class LastError(BaseModel): """A human-readable description of the error.""" -StepDetails = Union[MessageCreationStepDetails, ToolCallsStepDetails] +StepDetails = Annotated[Union[MessageCreationStepDetails, ToolCallsStepDetails], PropertyInfo(discriminator="type")] class Usage(BaseModel): diff --git a/src/openai/types/beta/threads/runs/tool_calls_step_details.py b/src/openai/types/beta/threads/runs/tool_calls_step_details.py index 80eb90bf66..b1b5a72bee 100644 --- a/src/openai/types/beta/threads/runs/tool_calls_step_details.py +++ b/src/openai/types/beta/threads/runs/tool_calls_step_details.py @@ -1,8 +1,9 @@ # File generated from our OpenAPI spec by Stainless. from typing import List, Union -from typing_extensions import Literal +from typing_extensions import Literal, Annotated +from ....._utils import PropertyInfo from ....._models import BaseModel from .code_tool_call import CodeToolCall from .function_tool_call import FunctionToolCall @@ -10,7 +11,7 @@ __all__ = ["ToolCallsStepDetails", "ToolCall"] -ToolCall = Union[CodeToolCall, RetrievalToolCall, FunctionToolCall] +ToolCall = Annotated[Union[CodeToolCall, RetrievalToolCall, FunctionToolCall], PropertyInfo(discriminator="type")] class ToolCallsStepDetails(BaseModel): diff --git a/src/openai/types/beta/threads/thread_message.py b/src/openai/types/beta/threads/thread_message.py index 25b3a199f7..6ed5da1401 100644 --- a/src/openai/types/beta/threads/thread_message.py +++ b/src/openai/types/beta/threads/thread_message.py @@ -1,15 +1,16 @@ # File generated from our OpenAPI spec by Stainless. from typing import List, Union, Optional -from typing_extensions import Literal +from typing_extensions import Literal, Annotated +from ...._utils import PropertyInfo from ...._models import BaseModel from .message_content_text import MessageContentText from .message_content_image_file import MessageContentImageFile __all__ = ["ThreadMessage", "Content"] -Content = Union[MessageContentImageFile, MessageContentText] +Content = Annotated[Union[MessageContentImageFile, MessageContentText], PropertyInfo(discriminator="type")] class ThreadMessage(BaseModel):