Skip to content

chore(types): include discriminators in unions #1228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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