Commit c4a1dbc2

Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
2024-05-09 04:11:15
feat(api): adding file purposes (#1401)
1 parent 89478ce
Changed files (5)
src
tests
api_resources
src/openai/resources/files.py
@@ -52,7 +52,7 @@ class Files(SyncAPIResource):
         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,
@@ -79,12 +79,11 @@ class Files(SyncAPIResource):
 
           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
 
@@ -325,7 +324,7 @@ class AsyncFiles(AsyncAPIResource):
         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,
@@ -352,12 +351,11 @@ class AsyncFiles(AsyncAPIResource):
 
           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
 
src/openai/types/file_create_params.py
@@ -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).
     """
src/openai/types/file_object.py
@@ -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"]
tests/api_resources/test_files.py
@@ -27,7 +27,7 @@ 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"])
 
@@ -35,7 +35,7 @@ class TestFiles:
     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
@@ -47,7 +47,7 @@ class TestFiles:
     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"
@@ -263,7 +263,7 @@ 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"])
 
@@ -271,7 +271,7 @@ class TestAsyncFiles:
     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
@@ -283,7 +283,7 @@ class TestAsyncFiles:
     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"
.stats.yml
@@ -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