Skip to content

fix(api): correct types for message attachment tools #1348

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
Apr 19, 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
7 changes: 6 additions & 1 deletion src/openai/types/beta/thread_create_and_run_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Thread",
"ThreadMessage",
"ThreadMessageAttachment",
"ThreadMessageAttachmentTool",
"ThreadToolResources",
"ThreadToolResourcesCodeInterpreter",
"ThreadToolResourcesFileSearch",
Expand Down Expand Up @@ -170,11 +171,15 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
"""


ThreadMessageAttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]


class ThreadMessageAttachment(TypedDict, total=False):
file_id: str
"""The ID of the file to attach to the message."""

tools: List[Literal["file_search", "code_interpreter"]]
tools: Iterable[ThreadMessageAttachmentTool]
"""The tools to add this file to."""


class ThreadMessage(TypedDict, total=False):
Expand Down
12 changes: 10 additions & 2 deletions src/openai/types/beta/thread_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

from __future__ import annotations

from typing import List, Iterable, Optional
from typing import List, Union, Iterable, Optional
from typing_extensions import Literal, Required, TypedDict

from .file_search_tool_param import FileSearchToolParam
from .code_interpreter_tool_param import CodeInterpreterToolParam

__all__ = [
"ThreadCreateParams",
"Message",
"MessageAttachment",
"MessageAttachmentTool",
"ToolResources",
"ToolResourcesCodeInterpreter",
"ToolResourcesFileSearch",
Expand Down Expand Up @@ -40,11 +44,15 @@ class ThreadCreateParams(TypedDict, total=False):
"""


MessageAttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]


class MessageAttachment(TypedDict, total=False):
file_id: str
"""The ID of the file to attach to the message."""

tools: List[Literal["file_search", "code_interpreter"]]
tools: Iterable[MessageAttachmentTool]
"""The tools to add this file to."""


class Message(TypedDict, total=False):
Expand Down
11 changes: 8 additions & 3 deletions src/openai/types/beta/threads/message.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Optional
from typing import List, Union, Optional
from typing_extensions import Literal

from ...._models import BaseModel
from .message_content import MessageContent
from ..file_search_tool import FileSearchTool
from ..code_interpreter_tool import CodeInterpreterTool

__all__ = ["Message", "Attachment", "IncompleteDetails"]
__all__ = ["Message", "Attachment", "AttachmentTool", "IncompleteDetails"]

AttachmentTool = Union[CodeInterpreterTool, FileSearchTool]


class Attachment(BaseModel):
file_id: Optional[str] = None
"""The ID of the file to attach to the message."""

tools: Optional[List[Literal["file_search", "code_interpreter"]]] = None
tools: Optional[List[AttachmentTool]] = None
"""The tools to add this file to."""


class IncompleteDetails(BaseModel):
Expand Down
13 changes: 10 additions & 3 deletions src/openai/types/beta/threads/message_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

from __future__ import annotations

from typing import List, Iterable, Optional
from typing import Union, Iterable, Optional
from typing_extensions import Literal, Required, TypedDict

__all__ = ["MessageCreateParams", "Attachment"]
from ..file_search_tool_param import FileSearchToolParam
from ..code_interpreter_tool_param import CodeInterpreterToolParam

__all__ = ["MessageCreateParams", "Attachment", "AttachmentTool"]


class MessageCreateParams(TypedDict, total=False):
Expand Down Expand Up @@ -33,8 +36,12 @@ class MessageCreateParams(TypedDict, total=False):
"""


AttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]


class Attachment(TypedDict, total=False):
file_id: str
"""The ID of the file to attach to the message."""

tools: List[Literal["file_search", "code_interpreter"]]
tools: Iterable[AttachmentTool]
"""The tools to add this file to."""
11 changes: 9 additions & 2 deletions src/openai/types/beta/threads/run_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

from __future__ import annotations

from typing import List, Union, Iterable, Optional
from typing import Union, Iterable, Optional
from typing_extensions import Literal, Required, TypedDict

from ..assistant_tool_param import AssistantToolParam
from ..file_search_tool_param import FileSearchToolParam
from ..code_interpreter_tool_param import CodeInterpreterToolParam
from ..assistant_tool_choice_option_param import AssistantToolChoiceOptionParam
from ..assistant_response_format_option_param import AssistantResponseFormatOptionParam

__all__ = [
"RunCreateParamsBase",
"AdditionalMessage",
"AdditionalMessageAttachment",
"AdditionalMessageAttachmentTool",
"TruncationStrategy",
"RunCreateParamsNonStreaming",
"RunCreateParamsStreaming",
Expand Down Expand Up @@ -159,11 +162,15 @@ class RunCreateParamsBase(TypedDict, total=False):
"""


AdditionalMessageAttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]


class AdditionalMessageAttachment(TypedDict, total=False):
file_id: str
"""The ID of the file to attach to the message."""

tools: List[Literal["file_search", "code_interpreter"]]
tools: Iterable[AdditionalMessageAttachmentTool]
"""The tools to add this file to."""


class AdditionalMessage(TypedDict, total=False):
Expand Down
Loading