Skip to content

Commit 2e9d0bd

Browse files
feat(api): adding file purposes (#1401)
1 parent 89478ce commit 2e9d0bd

File tree

5 files changed

+25
-28
lines changed

5 files changed

+25
-28
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 64
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-edb5af3ade0cd27cf366b0654b90c7a81c43c433e11fc3f6e621e2c779de10d4.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-2e14236d4015bf3b956290ea8b656224a0c7b206a356c6af2a7ae43fdbceb04c.yml

src/openai/resources/files.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create(
5252
self,
5353
*,
5454
file: FileTypes,
55-
purpose: Literal["fine-tune", "assistants"],
55+
purpose: Literal["assistants", "batch", "fine-tune"],
5656
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5757
# The extra values given here take precedence over values defined on the client or passed to this method.
5858
extra_headers: Headers | None = None,
@@ -79,12 +79,11 @@ def create(
7979
8080
purpose: The intended purpose of the uploaded file.
8181
82-
Use "fine-tune" for
83-
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
84-
"assistants" for
82+
Use "assistants" for
8583
[Assistants](https://platform.openai.com/docs/api-reference/assistants) and
86-
[Messages](https://platform.openai.com/docs/api-reference/messages). This allows
87-
us to validate the format of the uploaded file is correct for fine-tuning.
84+
[Messages](https://platform.openai.com/docs/api-reference/messages), "batch" for
85+
[Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
86+
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning).
8887
8988
extra_headers: Send extra headers
9089
@@ -325,7 +324,7 @@ async def create(
325324
self,
326325
*,
327326
file: FileTypes,
328-
purpose: Literal["fine-tune", "assistants"],
327+
purpose: Literal["assistants", "batch", "fine-tune"],
329328
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
330329
# The extra values given here take precedence over values defined on the client or passed to this method.
331330
extra_headers: Headers | None = None,
@@ -352,12 +351,11 @@ async def create(
352351
353352
purpose: The intended purpose of the uploaded file.
354353
355-
Use "fine-tune" for
356-
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
357-
"assistants" for
354+
Use "assistants" for
358355
[Assistants](https://platform.openai.com/docs/api-reference/assistants) and
359-
[Messages](https://platform.openai.com/docs/api-reference/messages). This allows
360-
us to validate the format of the uploaded file is correct for fine-tuning.
356+
[Messages](https://platform.openai.com/docs/api-reference/messages), "batch" for
357+
[Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
358+
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning).
361359
362360
extra_headers: Send extra headers
363361

src/openai/types/file_create_params.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ class FileCreateParams(TypedDict, total=False):
1313
file: Required[FileTypes]
1414
"""The File object (not file name) to be uploaded."""
1515

16-
purpose: Required[Literal["fine-tune", "assistants"]]
16+
purpose: Required[Literal["assistants", "batch", "fine-tune"]]
1717
"""The intended purpose of the uploaded file.
1818
19-
Use "fine-tune" for
20-
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
21-
"assistants" for
19+
Use "assistants" for
2220
[Assistants](https://platform.openai.com/docs/api-reference/assistants) and
23-
[Messages](https://platform.openai.com/docs/api-reference/messages). This allows
24-
us to validate the format of the uploaded file is correct for fine-tuning.
21+
[Messages](https://platform.openai.com/docs/api-reference/messages), "batch" for
22+
[Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
23+
[Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning).
2524
"""

src/openai/types/file_object.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ class FileObject(BaseModel):
2424
object: Literal["file"]
2525
"""The object type, which is always `file`."""
2626

27-
purpose: Literal["fine-tune", "fine-tune-results", "assistants", "assistants_output"]
27+
purpose: Literal["assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results"]
2828
"""The intended purpose of the file.
2929
30-
Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and
31-
`assistants_output`.
30+
Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`,
31+
`fine-tune`, and `fine-tune-results`.
3232
"""
3333

3434
status: Literal["uploaded", "processed", "error"]

tests/api_resources/test_files.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class TestFiles:
2727
def test_method_create(self, client: OpenAI) -> None:
2828
file = client.files.create(
2929
file=b"raw file contents",
30-
purpose="fine-tune",
30+
purpose="assistants",
3131
)
3232
assert_matches_type(FileObject, file, path=["response"])
3333

3434
@parametrize
3535
def test_raw_response_create(self, client: OpenAI) -> None:
3636
response = client.files.with_raw_response.create(
3737
file=b"raw file contents",
38-
purpose="fine-tune",
38+
purpose="assistants",
3939
)
4040

4141
assert response.is_closed is True
@@ -47,7 +47,7 @@ def test_raw_response_create(self, client: OpenAI) -> None:
4747
def test_streaming_response_create(self, client: OpenAI) -> None:
4848
with client.files.with_streaming_response.create(
4949
file=b"raw file contents",
50-
purpose="fine-tune",
50+
purpose="assistants",
5151
) as response:
5252
assert not response.is_closed
5353
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -263,15 +263,15 @@ class TestAsyncFiles:
263263
async def test_method_create(self, async_client: AsyncOpenAI) -> None:
264264
file = await async_client.files.create(
265265
file=b"raw file contents",
266-
purpose="fine-tune",
266+
purpose="assistants",
267267
)
268268
assert_matches_type(FileObject, file, path=["response"])
269269

270270
@parametrize
271271
async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
272272
response = await async_client.files.with_raw_response.create(
273273
file=b"raw file contents",
274-
purpose="fine-tune",
274+
purpose="assistants",
275275
)
276276

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

0 commit comments

Comments
 (0)