Skip to content

Commit f73996b

Browse files
committedApr 19, 2024
fix(api): correct types for message attachment tools (openai#1348)
1 parent 10dde6d commit f73996b

File tree

8 files changed

+499
-107
lines changed

8 files changed

+499
-107
lines changed
 

‎src/openai/types/beta/thread_create_and_run_params.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"Thread",
1717
"ThreadMessage",
1818
"ThreadMessageAttachment",
19+
"ThreadMessageAttachmentTool",
1920
"ThreadToolResources",
2021
"ThreadToolResourcesCodeInterpreter",
2122
"ThreadToolResourcesFileSearch",
@@ -170,11 +171,15 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
170171
"""
171172

172173

174+
ThreadMessageAttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]
175+
176+
173177
class ThreadMessageAttachment(TypedDict, total=False):
174178
file_id: str
175179
"""The ID of the file to attach to the message."""
176180

177-
tools: List[Literal["file_search", "code_interpreter"]]
181+
tools: Iterable[ThreadMessageAttachmentTool]
182+
"""The tools to add this file to."""
178183

179184

180185
class ThreadMessage(TypedDict, total=False):

‎src/openai/types/beta/thread_create_params.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Iterable, Optional
5+
from typing import List, Union, Iterable, Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from .file_search_tool_param import FileSearchToolParam
9+
from .code_interpreter_tool_param import CodeInterpreterToolParam
10+
811
__all__ = [
912
"ThreadCreateParams",
1013
"Message",
1114
"MessageAttachment",
15+
"MessageAttachmentTool",
1216
"ToolResources",
1317
"ToolResourcesCodeInterpreter",
1418
"ToolResourcesFileSearch",
@@ -40,11 +44,15 @@ class ThreadCreateParams(TypedDict, total=False):
4044
"""
4145

4246

47+
MessageAttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]
48+
49+
4350
class MessageAttachment(TypedDict, total=False):
4451
file_id: str
4552
"""The ID of the file to attach to the message."""
4653

47-
tools: List[Literal["file_search", "code_interpreter"]]
54+
tools: Iterable[MessageAttachmentTool]
55+
"""The tools to add this file to."""
4856

4957

5058
class Message(TypedDict, total=False):

‎src/openai/types/beta/threads/message.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List, Optional
3+
from typing import List, Union, Optional
44
from typing_extensions import Literal
55

66
from ...._models import BaseModel
77
from .message_content import MessageContent
8+
from ..file_search_tool import FileSearchTool
9+
from ..code_interpreter_tool import CodeInterpreterTool
810

9-
__all__ = ["Message", "Attachment", "IncompleteDetails"]
11+
__all__ = ["Message", "Attachment", "AttachmentTool", "IncompleteDetails"]
12+
13+
AttachmentTool = Union[CodeInterpreterTool, FileSearchTool]
1014

1115

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

16-
tools: Optional[List[Literal["file_search", "code_interpreter"]]] = None
20+
tools: Optional[List[AttachmentTool]] = None
21+
"""The tools to add this file to."""
1722

1823

1924
class IncompleteDetails(BaseModel):

‎src/openai/types/beta/threads/message_create_params.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Iterable, Optional
5+
from typing import Union, Iterable, Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8-
__all__ = ["MessageCreateParams", "Attachment"]
8+
from ..file_search_tool_param import FileSearchToolParam
9+
from ..code_interpreter_tool_param import CodeInterpreterToolParam
10+
11+
__all__ = ["MessageCreateParams", "Attachment", "AttachmentTool"]
912

1013

1114
class MessageCreateParams(TypedDict, total=False):
@@ -33,8 +36,12 @@ class MessageCreateParams(TypedDict, total=False):
3336
"""
3437

3538

39+
AttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]
40+
41+
3642
class Attachment(TypedDict, total=False):
3743
file_id: str
3844
"""The ID of the file to attach to the message."""
3945

40-
tools: List[Literal["file_search", "code_interpreter"]]
46+
tools: Iterable[AttachmentTool]
47+
"""The tools to add this file to."""

‎src/openai/types/beta/threads/run_create_params.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Iterable, Optional
5+
from typing import Union, Iterable, Optional
66
from typing_extensions import Literal, Required, TypedDict
77

88
from ..assistant_tool_param import AssistantToolParam
9+
from ..file_search_tool_param import FileSearchToolParam
10+
from ..code_interpreter_tool_param import CodeInterpreterToolParam
911
from ..assistant_tool_choice_option_param import AssistantToolChoiceOptionParam
1012
from ..assistant_response_format_option_param import AssistantResponseFormatOptionParam
1113

1214
__all__ = [
1315
"RunCreateParamsBase",
1416
"AdditionalMessage",
1517
"AdditionalMessageAttachment",
18+
"AdditionalMessageAttachmentTool",
1619
"TruncationStrategy",
1720
"RunCreateParamsNonStreaming",
1821
"RunCreateParamsStreaming",
@@ -159,11 +162,15 @@ class RunCreateParamsBase(TypedDict, total=False):
159162
"""
160163

161164

165+
AdditionalMessageAttachmentTool = Union[CodeInterpreterToolParam, FileSearchToolParam]
166+
167+
162168
class AdditionalMessageAttachment(TypedDict, total=False):
163169
file_id: str
164170
"""The ID of the file to attach to the message."""
165171

166-
tools: List[Literal["file_search", "code_interpreter"]]
172+
tools: Iterable[AdditionalMessageAttachmentTool]
173+
"""The tools to add this file to."""
167174

168175

169176
class AdditionalMessage(TypedDict, total=False):

0 commit comments

Comments
 (0)