Commit b54ab2f8

Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
2024-03-13 01:25:10
chore(types): include discriminators in unions (#1228)
1 parent 0f0aec5
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):
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):
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 @@ from .retrieval_tool_call import RetrievalToolCall
 
 __all__ = ["ToolCallsStepDetails", "ToolCall"]
 
-ToolCall = Union[CodeToolCall, RetrievalToolCall, FunctionToolCall]
+ToolCall = Annotated[Union[CodeToolCall, RetrievalToolCall, FunctionToolCall], PropertyInfo(discriminator="type")]
 
 
 class ToolCallsStepDetails(BaseModel):
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):
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):
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):