Skip to content

Commit b0d110a

Browse files
stainless-botmegamanics
authored andcommitted
feat(api): updates (openai#1461)
1 parent b8656c1 commit b0d110a

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
@@ -47,6 +47,7 @@ def create(
4747
vector_store_id: str,
4848
*,
4949
file_ids: List[str],
50+
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
5051
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5152
# The extra values given here take precedence over values defined on the client or passed to this method.
5253
extra_headers: Headers | None = None,
@@ -62,6 +63,9 @@ def create(
6263
the vector store should use. Useful for tools like `file_search` that can access
6364
files.
6465
66+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
67+
strategy.
68+
6569
extra_headers: Send extra headers
6670
6771
extra_query: Add additional query parameters to the request
@@ -75,7 +79,13 @@ def create(
7579
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
7680
return self._post(
7781
f"/vector_stores/{vector_store_id}/file_batches",
78-
body=maybe_transform({"file_ids": file_ids}, file_batch_create_params.FileBatchCreateParams),
82+
body=maybe_transform(
83+
{
84+
"file_ids": file_ids,
85+
"chunking_strategy": chunking_strategy,
86+
},
87+
file_batch_create_params.FileBatchCreateParams,
88+
),
7989
options=make_request_options(
8090
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
8191
),
@@ -351,6 +361,7 @@ async def create(
351361
vector_store_id: str,
352362
*,
353363
file_ids: List[str],
364+
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
354365
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
355366
# The extra values given here take precedence over values defined on the client or passed to this method.
356367
extra_headers: Headers | None = None,
@@ -366,6 +377,9 @@ async def create(
366377
the vector store should use. Useful for tools like `file_search` that can access
367378
files.
368379
380+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
381+
strategy.
382+
369383
extra_headers: Send extra headers
370384
371385
extra_query: Add additional query parameters to the request
@@ -379,7 +393,13 @@ async def create(
379393
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
380394
return await self._post(
381395
f"/vector_stores/{vector_store_id}/file_batches",
382-
body=await async_maybe_transform({"file_ids": file_ids}, file_batch_create_params.FileBatchCreateParams),
396+
body=await async_maybe_transform(
397+
{
398+
"file_ids": file_ids,
399+
"chunking_strategy": chunking_strategy,
400+
},
401+
file_batch_create_params.FileBatchCreateParams,
402+
),
383403
options=make_request_options(
384404
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
385405
),

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

+22-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def create(
4343
vector_store_id: str,
4444
*,
4545
file_id: str,
46+
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
4647
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4748
# The extra values given here take precedence over values defined on the client or passed to this method.
4849
extra_headers: Headers | None = None,
@@ -60,6 +61,9 @@ def create(
6061
vector store should use. Useful for tools like `file_search` that can access
6162
files.
6263
64+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
65+
strategy.
66+
6367
extra_headers: Send extra headers
6468
6569
extra_query: Add additional query parameters to the request
@@ -73,7 +77,13 @@ def create(
7377
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
7478
return self._post(
7579
f"/vector_stores/{vector_store_id}/files",
76-
body=maybe_transform({"file_id": file_id}, file_create_params.FileCreateParams),
80+
body=maybe_transform(
81+
{
82+
"file_id": file_id,
83+
"chunking_strategy": chunking_strategy,
84+
},
85+
file_create_params.FileCreateParams,
86+
),
7787
options=make_request_options(
7888
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
7989
),
@@ -330,6 +340,7 @@ async def create(
330340
vector_store_id: str,
331341
*,
332342
file_id: str,
343+
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
333344
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
334345
# The extra values given here take precedence over values defined on the client or passed to this method.
335346
extra_headers: Headers | None = None,
@@ -347,6 +358,9 @@ async def create(
347358
vector store should use. Useful for tools like `file_search` that can access
348359
files.
349360
361+
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
362+
strategy.
363+
350364
extra_headers: Send extra headers
351365
352366
extra_query: Add additional query parameters to the request
@@ -360,7 +374,13 @@ async def create(
360374
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
361375
return await self._post(
362376
f"/vector_stores/{vector_store_id}/files",
363-
body=await async_maybe_transform({"file_id": file_id}, file_create_params.FileCreateParams),
377+
body=await async_maybe_transform(
378+
{
379+
"file_id": file_id,
380+
"chunking_strategy": chunking_strategy,
381+
},
382+
file_create_params.FileCreateParams,
383+
),
364384
options=make_request_options(
365385
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
366386
),

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
@@ -52,7 +52,7 @@ def create(
5252
self,
5353
*,
5454
file: FileTypes,
55-
purpose: Literal["assistants", "batch", "fine-tune"],
55+
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
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,
@@ -71,9 +71,15 @@ def create(
7171
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
7272
details.
7373
74-
The Fine-tuning API only supports `.jsonl` files.
74+
The Fine-tuning API only supports `.jsonl` files. The input also has certain
75+
required formats for fine-tuning
76+
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
77+
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
78+
models.
7579
76-
The Batch API only supports `.jsonl` files up to 100 MB in size.
80+
The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
81+
has a specific required
82+
[format](https://platform.openai.com/docs/api-reference/batch/request-input).
7783
7884
Please [contact us](https://help.openai.com/) if you need to increase these
7985
storage limits.
@@ -329,7 +335,7 @@ async def create(
329335
self,
330336
*,
331337
file: FileTypes,
332-
purpose: Literal["assistants", "batch", "fine-tune"],
338+
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
333339
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
334340
# The extra values given here take precedence over values defined on the client or passed to this method.
335341
extra_headers: Headers | None = None,
@@ -348,9 +354,15 @@ async def create(
348354
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
349355
details.
350356
351-
The Fine-tuning API only supports `.jsonl` files.
357+
The Fine-tuning API only supports `.jsonl` files. The input also has certain
358+
required formats for fine-tuning
359+
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
360+
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
361+
models.
352362
353-
The Batch API only supports `.jsonl` files up to 100 MB in size.
363+
The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
364+
has a specific required
365+
[format](https://platform.openai.com/docs/api-reference/batch/request-input).
354366
355367
Please [contact us](https://help.openai.com/) if you need to increase these
356368
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)