Skip to content

Commit

Permalink
feat(api): adding file purposes (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed May 8, 2024
1 parent 89478ce commit c4a1dbc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 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: 64
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-edb5af3ade0cd27cf366b0654b90c7a81c43c433e11fc3f6e621e2c779de10d4.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-2e14236d4015bf3b956290ea8b656224a0c7b206a356c6af2a7ae43fdbceb04c.yml
22 changes: 10 additions & 12 deletions src/openai/resources/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create(
self,
*,
file: FileTypes,
purpose: Literal["fine-tune", "assistants"],
purpose: Literal["assistants", "batch", "fine-tune"],
# 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 All @@ -79,12 +79,11 @@ def create(
purpose: The intended purpose of the uploaded file.
Use "fine-tune" for
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
"assistants" for
Use "assistants" for
[Assistants](https://platform.openai.com/docs/api-reference/assistants) and
[Messages](https://platform.openai.com/docs/api-reference/messages). This allows
us to validate the format of the uploaded file is correct for fine-tuning.
[Messages](https://platform.openai.com/docs/api-reference/messages), "batch" for
[Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning).
extra_headers: Send extra headers
Expand Down Expand Up @@ -325,7 +324,7 @@ async def create(
self,
*,
file: FileTypes,
purpose: Literal["fine-tune", "assistants"],
purpose: Literal["assistants", "batch", "fine-tune"],
# 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 All @@ -352,12 +351,11 @@ async def create(
purpose: The intended purpose of the uploaded file.
Use "fine-tune" for
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
"assistants" for
Use "assistants" for
[Assistants](https://platform.openai.com/docs/api-reference/assistants) and
[Messages](https://platform.openai.com/docs/api-reference/messages). This allows
us to validate the format of the uploaded file is correct for fine-tuning.
[Messages](https://platform.openai.com/docs/api-reference/messages), "batch" for
[Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning).
extra_headers: Send extra headers
Expand Down
11 changes: 5 additions & 6 deletions src/openai/types/file_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ class FileCreateParams(TypedDict, total=False):
file: Required[FileTypes]
"""The File object (not file name) to be uploaded."""

purpose: Required[Literal["fine-tune", "assistants"]]
purpose: Required[Literal["assistants", "batch", "fine-tune"]]
"""The intended purpose of the uploaded file.
Use "fine-tune" for
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
"assistants" for
Use "assistants" for
[Assistants](https://platform.openai.com/docs/api-reference/assistants) and
[Messages](https://platform.openai.com/docs/api-reference/messages). This allows
us to validate the format of the uploaded file is correct for fine-tuning.
[Messages](https://platform.openai.com/docs/api-reference/messages), "batch" for
[Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning).
"""
6 changes: 3 additions & 3 deletions src/openai/types/file_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class FileObject(BaseModel):
object: Literal["file"]
"""The object type, which is always `file`."""

purpose: Literal["fine-tune", "fine-tune-results", "assistants", "assistants_output"]
purpose: Literal["assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results"]
"""The intended purpose of the file.
Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and
`assistants_output`.
Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`,
`fine-tune`, and `fine-tune-results`.
"""

status: Literal["uploaded", "processed", "error"]
Expand Down
12 changes: 6 additions & 6 deletions tests/api_resources/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class TestFiles:
def test_method_create(self, client: OpenAI) -> None:
file = client.files.create(
file=b"raw file contents",
purpose="fine-tune",
purpose="assistants",
)
assert_matches_type(FileObject, file, path=["response"])

@parametrize
def test_raw_response_create(self, client: OpenAI) -> None:
response = client.files.with_raw_response.create(
file=b"raw file contents",
purpose="fine-tune",
purpose="assistants",
)

assert response.is_closed is True
Expand All @@ -47,7 +47,7 @@ def test_raw_response_create(self, client: OpenAI) -> None:
def test_streaming_response_create(self, client: OpenAI) -> None:
with client.files.with_streaming_response.create(
file=b"raw file contents",
purpose="fine-tune",
purpose="assistants",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down Expand Up @@ -263,15 +263,15 @@ class TestAsyncFiles:
async def test_method_create(self, async_client: AsyncOpenAI) -> None:
file = await async_client.files.create(
file=b"raw file contents",
purpose="fine-tune",
purpose="assistants",
)
assert_matches_type(FileObject, file, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
response = await async_client.files.with_raw_response.create(
file=b"raw file contents",
purpose="fine-tune",
purpose="assistants",
)

assert response.is_closed is True
Expand All @@ -283,7 +283,7 @@ async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
async with async_client.files.with_streaming_response.create(
file=b"raw file contents",
purpose="fine-tune",
purpose="assistants",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down

0 comments on commit c4a1dbc

Please sign in to comment.