Skip to content

Commit 40e542b

Browse files
chore(types): define FilePurpose enum (#1653)
1 parent c5a74dd commit 40e542b

File tree

8 files changed

+25
-14
lines changed

8 files changed

+25
-14
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-285bce7dcdae7eea5fe84a8d6e5af2c1473d65ea193109370fb2257851eef7eb.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8ff62fa1091460d68fbd36d72c17d91b709917bebf2983c9c4de5784bc384a2e.yml

api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Methods:
8282
Types:
8383

8484
```python
85-
from openai.types import FileContent, FileDeleted, FileObject
85+
from openai.types import FileContent, FileDeleted, FileObject, FilePurpose
8686
```
8787

8888
Methods:

src/openai/resources/files.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
import typing_extensions
66
from typing import Mapping, cast
7-
from typing_extensions import Literal
87

98
import httpx
109

1110
from .. import _legacy_response
12-
from ..types import file_list_params, file_create_params
11+
from ..types import FilePurpose, file_list_params, file_create_params
1312
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
1413
from .._utils import (
1514
extract_files,
@@ -31,6 +30,7 @@
3130
from .._base_client import AsyncPaginator, make_request_options
3231
from ..types.file_object import FileObject
3332
from ..types.file_deleted import FileDeleted
33+
from ..types.file_purpose import FilePurpose
3434

3535
__all__ = ["Files", "AsyncFiles"]
3636

@@ -48,7 +48,7 @@ def create(
4848
self,
4949
*,
5050
file: FileTypes,
51-
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
51+
purpose: FilePurpose,
5252
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5353
# The extra values given here take precedence over values defined on the client or passed to this method.
5454
extra_headers: Headers | None = None,
@@ -307,7 +307,7 @@ async def create(
307307
self,
308308
*,
309309
file: FileTypes,
310-
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
310+
purpose: FilePurpose,
311311
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
312312
# The extra values given here take precedence over values defined on the client or passed to this method.
313313
extra_headers: Headers | None = None,

src/openai/resources/uploads/uploads.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
from typing import List
6-
from typing_extensions import Literal
76

87
import httpx
98

@@ -16,7 +15,7 @@
1615
PartsWithStreamingResponse,
1716
AsyncPartsWithStreamingResponse,
1817
)
19-
from ...types import upload_create_params, upload_complete_params
18+
from ...types import FilePurpose, upload_create_params, upload_complete_params
2019
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
2120
from ..._utils import (
2221
maybe_transform,
@@ -27,6 +26,7 @@
2726
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2827
from ..._base_client import make_request_options
2928
from ...types.upload import Upload
29+
from ...types.file_purpose import FilePurpose
3030

3131
__all__ = ["Uploads", "AsyncUploads"]
3232

@@ -50,7 +50,7 @@ def create(
5050
bytes: int,
5151
filename: str,
5252
mime_type: str,
53-
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
53+
purpose: FilePurpose,
5454
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5555
# The extra values given here take precedence over values defined on the client or passed to this method.
5656
extra_headers: Headers | None = None,
@@ -233,7 +233,7 @@ async def create(
233233
bytes: int,
234234
filename: str,
235235
mime_type: str,
236-
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
236+
purpose: FilePurpose,
237237
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
238238
# The extra values given here take precedence over values defined on the client or passed to this method.
239239
extra_headers: Headers | None = None,

src/openai/types/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .image_model import ImageModel as ImageModel
2525
from .file_content import FileContent as FileContent
2626
from .file_deleted import FileDeleted as FileDeleted
27+
from .file_purpose import FilePurpose as FilePurpose
2728
from .model_deleted import ModelDeleted as ModelDeleted
2829
from .images_response import ImagesResponse as ImagesResponse
2930
from .completion_usage import CompletionUsage as CompletionUsage

src/openai/types/file_create_params.py

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

33
from __future__ import annotations
44

5-
from typing_extensions import Literal, Required, TypedDict
5+
from typing_extensions import Required, TypedDict
66

77
from .._types import FileTypes
8+
from .file_purpose import FilePurpose
89

910
__all__ = ["FileCreateParams"]
1011

@@ -13,7 +14,7 @@ class FileCreateParams(TypedDict, total=False):
1314
file: Required[FileTypes]
1415
"""The File object (not file name) to be uploaded."""
1516

16-
purpose: Required[Literal["assistants", "batch", "fine-tune", "vision"]]
17+
purpose: Required[FilePurpose]
1718
"""The intended purpose of the uploaded file.
1819
1920
Use "assistants" for

src/openai/types/file_purpose.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal, TypeAlias
4+
5+
__all__ = ["FilePurpose"]
6+
7+
FilePurpose: TypeAlias = Literal["assistants", "batch", "fine-tune", "vision"]

src/openai/types/upload_create_params.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Literal, Required, TypedDict
5+
from typing_extensions import Required, TypedDict
6+
7+
from .file_purpose import FilePurpose
68

79
__all__ = ["UploadCreateParams"]
810

@@ -21,7 +23,7 @@ class UploadCreateParams(TypedDict, total=False):
2123
supported MIME types for assistants and vision.
2224
"""
2325

24-
purpose: Required[Literal["assistants", "batch", "fine-tune", "vision"]]
26+
purpose: Required[FilePurpose]
2527
"""The intended purpose of the uploaded file.
2628
2729
See the

0 commit comments

Comments
 (0)