Skip to content

Commit

Permalink
chore(types): include discriminators in unions (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Mar 12, 2024
1 parent 4767259 commit 3ba0dcc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/openai/types/beta/assistant.py
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions src/openai/types/beta/threads/message_content_text.py
Original file line number Diff line number Diff line change
@@ -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__ = [
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions src/openai/types/beta/threads/runs/code_tool_call.py
Original file line number Diff line number Diff line change
@@ -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__ = [
Expand Down Expand Up @@ -38,7 +39,9 @@ class CodeInterpreterOutputImage(BaseModel):
"""Always `image`."""


CodeInterpreterOutput = Union[CodeInterpreterOutputLogs, CodeInterpreterOutputImage]
CodeInterpreterOutput = Annotated[
Union[CodeInterpreterOutputLogs, CodeInterpreterOutputImage], PropertyInfo(discriminator="type")
]


class CodeInterpreter(BaseModel):
Expand Down
5 changes: 3 additions & 2 deletions src/openai/types/beta/threads/runs/run_step.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions src/openai/types/beta/threads/runs/tool_calls_step_details.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# 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
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):
Expand Down
5 changes: 3 additions & 2 deletions src/openai/types/beta/threads/thread_message.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 3ba0dcc

Please sign in to comment.