Skip to content

Commit 6086210

Browse files
feat(api): updates (#1461)
1 parent 7dcabfc commit 6086210

29 files changed

+515
-41
lines changed

Diff for: .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-363dd904e5d6e65b3a323fc88e6b502fb23a6aa319be219273e3ee47c7530993.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-0577fd0d08da6b867b002a5accd45f7116ef91c4940b41cf45dc479938c77163.yml

Diff for: src/openai/resources/batches.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def create(
6868
for how to upload a file.
6969
7070
Your input file must be formatted as a
71-
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
71+
[JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
7272
and must be uploaded with the purpose `batch`. The file can contain up to 50,000
7373
requests, and can be up to 100 MB in size.
7474
@@ -195,8 +195,11 @@ def cancel(
195195
extra_body: Body | None = None,
196196
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
197197
) -> Batch:
198-
"""
199-
Cancels an in-progress batch.
198+
"""Cancels an in-progress batch.
199+
200+
The batch will be in status `cancelling` for up to
201+
10 minutes, before changing to `cancelled`, where it will have partial results
202+
(if any) available in the output file.
200203
201204
Args:
202205
extra_headers: Send extra headers
@@ -259,7 +262,7 @@ async def create(
259262
for how to upload a file.
260263
261264
Your input file must be formatted as a
262-
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
265+
[JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
263266
and must be uploaded with the purpose `batch`. The file can contain up to 50,000
264267
requests, and can be up to 100 MB in size.
265268
@@ -386,8 +389,11 @@ async def cancel(
386389
extra_body: Body | None = None,
387390
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
388391
) -> Batch:
389-
"""
390-
Cancels an in-progress batch.
392+
"""Cancels an in-progress batch.
393+
394+
The batch will be in status `cancelling` for up to
395+
10 minutes, before changing to `cancelled`, where it will have partial results
396+
(if any) available in the output file.
391397
392398
Args:
393399
extra_headers: Send extra headers

Diff for: src/openai/resources/beta/vector_stores/file_batches.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def create(
4242
vector_store_id: str,
4343
*,
4444
file_ids: List[str],
45+
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
4546
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4647
# The extra values given here take precedence over values defined on the client or passed to this method.
4748
extra_headers: Headers | None = None,
@@ -57,6 +58,9 @@ def create(
5758
the vector store should use. Useful for tools like `file_search` that can access
5859
files.
5960
61+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
62+
strategy.
63+
6064
extra_headers: Send extra headers
6165
6266
extra_query: Add additional query parameters to the request
@@ -70,7 +74,13 @@ def create(
7074
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
7175
return self._post(
7276
f"/vector_stores/{vector_store_id}/file_batches",
73-
body=maybe_transform({"file_ids": file_ids}, file_batch_create_params.FileBatchCreateParams),
77+
body=maybe_transform(
78+
{
79+
"file_ids": file_ids,
80+
"chunking_strategy": chunking_strategy,
81+
},
82+
file_batch_create_params.FileBatchCreateParams,
83+
),
7484
options=make_request_options(
7585
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
7686
),
@@ -242,6 +252,7 @@ async def create(
242252
vector_store_id: str,
243253
*,
244254
file_ids: List[str],
255+
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
245256
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
246257
# The extra values given here take precedence over values defined on the client or passed to this method.
247258
extra_headers: Headers | None = None,
@@ -257,6 +268,9 @@ async def create(
257268
the vector store should use. Useful for tools like `file_search` that can access
258269
files.
259270
271+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
272+
strategy.
273+
260274
extra_headers: Send extra headers
261275
262276
extra_query: Add additional query parameters to the request
@@ -270,7 +284,13 @@ async def create(
270284
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
271285
return await self._post(
272286
f"/vector_stores/{vector_store_id}/file_batches",
273-
body=await async_maybe_transform({"file_ids": file_ids}, file_batch_create_params.FileBatchCreateParams),
287+
body=await async_maybe_transform(
288+
{
289+
"file_ids": file_ids,
290+
"chunking_strategy": chunking_strategy,
291+
},
292+
file_batch_create_params.FileBatchCreateParams,
293+
),
274294
options=make_request_options(
275295
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
276296
),

Diff for: src/openai/resources/beta/vector_stores/files.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def create(
4141
vector_store_id: str,
4242
*,
4343
file_id: str,
44+
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
4445
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4546
# The extra values given here take precedence over values defined on the client or passed to this method.
4647
extra_headers: Headers | None = None,
@@ -58,6 +59,9 @@ def create(
5859
vector store should use. Useful for tools like `file_search` that can access
5960
files.
6061
62+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
63+
strategy.
64+
6165
extra_headers: Send extra headers
6266
6367
extra_query: Add additional query parameters to the request
@@ -71,7 +75,13 @@ def create(
7175
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
7276
return self._post(
7377
f"/vector_stores/{vector_store_id}/files",
74-
body=maybe_transform({"file_id": file_id}, file_create_params.FileCreateParams),
78+
body=maybe_transform(
79+
{
80+
"file_id": file_id,
81+
"chunking_strategy": chunking_strategy,
82+
},
83+
file_create_params.FileCreateParams,
84+
),
7585
options=make_request_options(
7686
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
7787
),
@@ -242,6 +252,7 @@ async def create(
242252
vector_store_id: str,
243253
*,
244254
file_id: str,
255+
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
245256
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
246257
# The extra values given here take precedence over values defined on the client or passed to this method.
247258
extra_headers: Headers | None = None,
@@ -259,6 +270,9 @@ async def create(
259270
vector store should use. Useful for tools like `file_search` that can access
260271
files.
261272
273+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
274+
strategy.
275+
262276
extra_headers: Send extra headers
263277
264278
extra_query: Add additional query parameters to the request
@@ -272,7 +286,13 @@ async def create(
272286
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
273287
return await self._post(
274288
f"/vector_stores/{vector_store_id}/files",
275-
body=await async_maybe_transform({"file_id": file_id}, file_create_params.FileCreateParams),
289+
body=await async_maybe_transform(
290+
{
291+
"file_id": file_id,
292+
"chunking_strategy": chunking_strategy,
293+
},
294+
file_create_params.FileCreateParams,
295+
),
276296
options=make_request_options(
277297
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
278298
),

Diff for: src/openai/resources/beta/vector_stores/vector_stores.py

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def with_streaming_response(self) -> VectorStoresWithStreamingResponse:
6464
def create(
6565
self,
6666
*,
67+
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
6768
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
6869
file_ids: List[str] | NotGiven = NOT_GIVEN,
6970
metadata: Optional[object] | NotGiven = NOT_GIVEN,
@@ -79,6 +80,9 @@ def create(
7980
Create a vector store.
8081
8182
Args:
83+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
84+
strategy. Only applicable if `file_ids` is non-empty.
85+
8286
expires_after: The expiration policy for a vector store.
8387
8488
file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
@@ -105,6 +109,7 @@ def create(
105109
"/vector_stores",
106110
body=maybe_transform(
107111
{
112+
"chunking_strategy": chunking_strategy,
108113
"expires_after": expires_after,
109114
"file_ids": file_ids,
110115
"metadata": metadata,
@@ -326,6 +331,7 @@ def with_streaming_response(self) -> AsyncVectorStoresWithStreamingResponse:
326331
async def create(
327332
self,
328333
*,
334+
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
329335
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
330336
file_ids: List[str] | NotGiven = NOT_GIVEN,
331337
metadata: Optional[object] | NotGiven = NOT_GIVEN,
@@ -341,6 +347,9 @@ async def create(
341347
Create a vector store.
342348
343349
Args:
350+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
351+
strategy. Only applicable if `file_ids` is non-empty.
352+
344353
expires_after: The expiration policy for a vector store.
345354
346355
file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
@@ -367,6 +376,7 @@ async def create(
367376
"/vector_stores",
368377
body=await async_maybe_transform(
369378
{
379+
"chunking_strategy": chunking_strategy,
370380
"expires_after": expires_after,
371381
"file_ids": file_ids,
372382
"metadata": metadata,

Diff for: src/openai/resources/files.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def create(
5151
self,
5252
*,
5353
file: FileTypes,
54-
purpose: Literal["assistants", "batch", "fine-tune"],
54+
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
5555
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5656
# The extra values given here take precedence over values defined on the client or passed to this method.
5757
extra_headers: Headers | None = None,
@@ -70,9 +70,15 @@ def create(
7070
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
7171
details.
7272
73-
The Fine-tuning API only supports `.jsonl` files.
73+
The Fine-tuning API only supports `.jsonl` files. The input also has certain
74+
required formats for fine-tuning
75+
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
76+
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
77+
models.
7478
75-
The Batch API only supports `.jsonl` files up to 100 MB in size.
79+
The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
80+
has a specific required
81+
[format](https://platform.openai.com/docs/api-reference/batch/request-input).
7682
7783
Please [contact us](https://help.openai.com/) if you need to increase these
7884
storage limits.
@@ -305,7 +311,7 @@ async def create(
305311
self,
306312
*,
307313
file: FileTypes,
308-
purpose: Literal["assistants", "batch", "fine-tune"],
314+
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
309315
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
310316
# The extra values given here take precedence over values defined on the client or passed to this method.
311317
extra_headers: Headers | None = None,
@@ -324,9 +330,15 @@ async def create(
324330
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
325331
details.
326332
327-
The Fine-tuning API only supports `.jsonl` files.
333+
The Fine-tuning API only supports `.jsonl` files. The input also has certain
334+
required formats for fine-tuning
335+
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
336+
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
337+
models.
328338
329-
The Batch API only supports `.jsonl` files up to 100 MB in size.
339+
The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
340+
has a specific required
341+
[format](https://platform.openai.com/docs/api-reference/batch/request-input).
330342
331343
Please [contact us](https://help.openai.com/) if you need to increase these
332344
storage limits.

Diff for: src/openai/resources/fine_tuning/jobs/jobs.py

+10
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def create(
8787
Your dataset must be formatted as a JSONL file. Additionally, you must upload
8888
your file with the purpose `fine-tune`.
8989
90+
The contents of the file should differ depending on if the model uses the
91+
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
92+
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
93+
format.
94+
9095
See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
9196
for more details.
9297
@@ -362,6 +367,11 @@ async def create(
362367
Your dataset must be formatted as a JSONL file. Additionally, you must upload
363368
your file with the purpose `fine-tune`.
364369
370+
The contents of the file should differ depending on if the model uses the
371+
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
372+
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
373+
format.
374+
365375
See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
366376
for more details.
367377

Diff for: src/openai/types/batch_create_params.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class BatchCreateParams(TypedDict, total=False):
3030
for how to upload a file.
3131
3232
Your input file must be formatted as a
33-
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
33+
[JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
3434
and must be uploaded with the purpose `batch`. The file can contain up to 50,000
3535
requests, and can be up to 100 MB in size.
3636
"""

Diff for: src/openai/types/beta/assistant_create_params.py

+42
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"ToolResourcesCodeInterpreter",
1515
"ToolResourcesFileSearch",
1616
"ToolResourcesFileSearchVectorStore",
17+
"ToolResourcesFileSearchVectorStoreChunkingStrategy",
18+
"ToolResourcesFileSearchVectorStoreChunkingStrategyAuto",
19+
"ToolResourcesFileSearchVectorStoreChunkingStrategyStatic",
20+
"ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic",
1721
]
1822

1923

@@ -134,7 +138,45 @@ class ToolResourcesCodeInterpreter(TypedDict, total=False):
134138
"""
135139

136140

141+
class ToolResourcesFileSearchVectorStoreChunkingStrategyAuto(TypedDict, total=False):
142+
type: Required[Literal["auto"]]
143+
"""Always `auto`."""
144+
145+
146+
class ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic(TypedDict, total=False):
147+
chunk_overlap_tokens: Required[int]
148+
"""The number of tokens that overlap between chunks. The default value is `400`.
149+
150+
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
151+
"""
152+
153+
max_chunk_size_tokens: Required[int]
154+
"""The maximum number of tokens in each chunk.
155+
156+
The default value is `800`. The minimum value is `100` and the maximum value is
157+
`4096`.
158+
"""
159+
160+
161+
class ToolResourcesFileSearchVectorStoreChunkingStrategyStatic(TypedDict, total=False):
162+
static: Required[ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic]
163+
164+
type: Required[Literal["static"]]
165+
"""Always `static`."""
166+
167+
168+
ToolResourcesFileSearchVectorStoreChunkingStrategy = Union[
169+
ToolResourcesFileSearchVectorStoreChunkingStrategyAuto, ToolResourcesFileSearchVectorStoreChunkingStrategyStatic
170+
]
171+
172+
137173
class ToolResourcesFileSearchVectorStore(TypedDict, total=False):
174+
chunking_strategy: ToolResourcesFileSearchVectorStoreChunkingStrategy
175+
"""The chunking strategy used to chunk the file(s).
176+
177+
If not set, will use the `auto` strategy.
178+
"""
179+
138180
file_ids: List[str]
139181
"""
140182
A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to

0 commit comments

Comments
 (0)