Skip to content

Commit 3ba0dcc

Browse files
chore(types): include discriminators in unions (#1228)
1 parent 4767259 commit 3ba0dcc

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

src/openai/types/beta/assistant.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import List, Union, Optional
4-
from typing_extensions import Literal
4+
from typing_extensions import Literal, Annotated
55

66
from ..shared import FunctionDefinition
7+
from ..._utils import PropertyInfo
78
from ..._models import BaseModel
89

910
__all__ = ["Assistant", "Tool", "ToolCodeInterpreter", "ToolRetrieval", "ToolFunction"]
@@ -26,7 +27,7 @@ class ToolFunction(BaseModel):
2627
"""The type of tool being defined: `function`"""
2728

2829

29-
Tool = Union[ToolCodeInterpreter, ToolRetrieval, ToolFunction]
30+
Tool = Annotated[Union[ToolCodeInterpreter, ToolRetrieval, ToolFunction], PropertyInfo(discriminator="type")]
3031

3132

3233
class Assistant(BaseModel):

src/openai/types/beta/threads/message_content_text.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import List, Union
4-
from typing_extensions import Literal
4+
from typing_extensions import Literal, Annotated
55

6+
from ...._utils import PropertyInfo
67
from ...._models import BaseModel
78

89
__all__ = [
@@ -57,7 +58,9 @@ class TextAnnotationFilePath(BaseModel):
5758
"""Always `file_path`."""
5859

5960

60-
TextAnnotation = Union[TextAnnotationFileCitation, TextAnnotationFilePath]
61+
TextAnnotation = Annotated[
62+
Union[TextAnnotationFileCitation, TextAnnotationFilePath], PropertyInfo(discriminator="type")
63+
]
6164

6265

6366
class Text(BaseModel):

src/openai/types/beta/threads/runs/code_tool_call.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import List, Union
4-
from typing_extensions import Literal
4+
from typing_extensions import Literal, Annotated
55

6+
from ....._utils import PropertyInfo
67
from ....._models import BaseModel
78

89
__all__ = [
@@ -38,7 +39,9 @@ class CodeInterpreterOutputImage(BaseModel):
3839
"""Always `image`."""
3940

4041

41-
CodeInterpreterOutput = Union[CodeInterpreterOutputLogs, CodeInterpreterOutputImage]
42+
CodeInterpreterOutput = Annotated[
43+
Union[CodeInterpreterOutputLogs, CodeInterpreterOutputImage], PropertyInfo(discriminator="type")
44+
]
4245

4346

4447
class CodeInterpreter(BaseModel):

src/openai/types/beta/threads/runs/run_step.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import Union, Optional
4-
from typing_extensions import Literal
4+
from typing_extensions import Literal, Annotated
55

6+
from ....._utils import PropertyInfo
67
from ....._models import BaseModel
78
from .tool_calls_step_details import ToolCallsStepDetails
89
from .message_creation_step_details import MessageCreationStepDetails
@@ -18,7 +19,7 @@ class LastError(BaseModel):
1819
"""A human-readable description of the error."""
1920

2021

21-
StepDetails = Union[MessageCreationStepDetails, ToolCallsStepDetails]
22+
StepDetails = Annotated[Union[MessageCreationStepDetails, ToolCallsStepDetails], PropertyInfo(discriminator="type")]
2223

2324

2425
class Usage(BaseModel):

src/openai/types/beta/threads/runs/tool_calls_step_details.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import List, Union
4-
from typing_extensions import Literal
4+
from typing_extensions import Literal, Annotated
55

6+
from ....._utils import PropertyInfo
67
from ....._models import BaseModel
78
from .code_tool_call import CodeToolCall
89
from .function_tool_call import FunctionToolCall
910
from .retrieval_tool_call import RetrievalToolCall
1011

1112
__all__ = ["ToolCallsStepDetails", "ToolCall"]
1213

13-
ToolCall = Union[CodeToolCall, RetrievalToolCall, FunctionToolCall]
14+
ToolCall = Annotated[Union[CodeToolCall, RetrievalToolCall, FunctionToolCall], PropertyInfo(discriminator="type")]
1415

1516

1617
class ToolCallsStepDetails(BaseModel):

src/openai/types/beta/threads/thread_message.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import List, Union, Optional
4-
from typing_extensions import Literal
4+
from typing_extensions import Literal, Annotated
55

6+
from ...._utils import PropertyInfo
67
from ...._models import BaseModel
78
from .message_content_text import MessageContentText
89
from .message_content_image_file import MessageContentImageFile
910

1011
__all__ = ["ThreadMessage", "Content"]
1112

12-
Content = Union[MessageContentImageFile, MessageContentText]
13+
Content = Annotated[Union[MessageContentImageFile, MessageContentText], PropertyInfo(discriminator="type")]
1314

1415

1516
class ThreadMessage(BaseModel):

0 commit comments

Comments
 (0)