Skip to content

Commit

Permalink
chore(types): define FilePurpose enum (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Aug 15, 2024
1 parent 3bf03f2 commit 05f0132
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-285bce7dcdae7eea5fe84a8d6e5af2c1473d65ea193109370fb2257851eef7eb.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8ff62fa1091460d68fbd36d72c17d91b709917bebf2983c9c4de5784bc384a2e.yml
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Methods:
Types:

```python
from openai.types import FileContent, FileDeleted, FileObject
from openai.types import FileContent, FileDeleted, FileObject, FilePurpose
```

Methods:
Expand Down
8 changes: 4 additions & 4 deletions src/openai/resources/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import time
import typing_extensions
from typing import Mapping, cast
from typing_extensions import Literal

import httpx

from .. import _legacy_response
from ..types import file_list_params, file_create_params
from ..types import FilePurpose, file_list_params, file_create_params
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from .._utils import (
extract_files,
Expand All @@ -35,6 +34,7 @@
)
from ..types.file_object import FileObject
from ..types.file_deleted import FileDeleted
from ..types.file_purpose import FilePurpose

__all__ = ["Files", "AsyncFiles"]

Expand All @@ -52,7 +52,7 @@ def create(
self,
*,
file: FileTypes,
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
purpose: FilePurpose,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -334,7 +334,7 @@ async def create(
self,
*,
file: FileTypes,
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
purpose: FilePurpose,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
8 changes: 4 additions & 4 deletions src/openai/resources/uploads/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

from typing import List
from typing_extensions import Literal

import httpx

Expand All @@ -16,7 +15,7 @@
PartsWithStreamingResponse,
AsyncPartsWithStreamingResponse,
)
from ...types import upload_create_params, upload_complete_params
from ...types import FilePurpose, upload_create_params, upload_complete_params
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
maybe_transform,
Expand All @@ -27,6 +26,7 @@
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ..._base_client import make_request_options
from ...types.upload import Upload
from ...types.file_purpose import FilePurpose

__all__ = ["Uploads", "AsyncUploads"]

Expand All @@ -50,7 +50,7 @@ def create(
bytes: int,
filename: str,
mime_type: str,
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
purpose: FilePurpose,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -233,7 +233,7 @@ async def create(
bytes: int,
filename: str,
mime_type: str,
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
purpose: FilePurpose,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
1 change: 1 addition & 0 deletions src/openai/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .image_model import ImageModel as ImageModel
from .file_content import FileContent as FileContent
from .file_deleted import FileDeleted as FileDeleted
from .file_purpose import FilePurpose as FilePurpose
from .model_deleted import ModelDeleted as ModelDeleted
from .images_response import ImagesResponse as ImagesResponse
from .completion_usage import CompletionUsage as CompletionUsage
Expand Down
5 changes: 3 additions & 2 deletions src/openai/types/file_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from __future__ import annotations

from typing_extensions import Literal, Required, TypedDict
from typing_extensions import Required, TypedDict

from .._types import FileTypes
from .file_purpose import FilePurpose

__all__ = ["FileCreateParams"]

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

purpose: Required[Literal["assistants", "batch", "fine-tune", "vision"]]
purpose: Required[FilePurpose]
"""The intended purpose of the uploaded file.
Use "assistants" for
Expand Down
7 changes: 7 additions & 0 deletions src/openai/types/file_purpose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import Literal, TypeAlias

__all__ = ["FilePurpose"]

FilePurpose: TypeAlias = Literal["assistants", "batch", "fine-tune", "vision"]
6 changes: 4 additions & 2 deletions src/openai/types/upload_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from __future__ import annotations

from typing_extensions import Literal, Required, TypedDict
from typing_extensions import Required, TypedDict

from .file_purpose import FilePurpose

__all__ = ["UploadCreateParams"]

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

purpose: Required[Literal["assistants", "batch", "fine-tune", "vision"]]
purpose: Required[FilePurpose]
"""The intended purpose of the uploaded file.
See the
Expand Down

0 comments on commit 05f0132

Please sign in to comment.