Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e82cd85

Browse files
author
Stainless Bot
committedSep 6, 2024
feat(vector store): improve chunking strategy type names (#1690)
1 parent b2f58cb commit e82cd85

20 files changed

+201
-321
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-85a85e0c08de456441431c0ae4e9c078cc8f9748c29430b9a9058340db6389ee.yml

‎api.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,17 @@ Methods:
222222
Types:
223223

224224
```python
225-
from openai.types.beta import VectorStore, VectorStoreDeleted
225+
from openai.types.beta import (
226+
AutoFileChunkingStrategyParam,
227+
FileChunkingStrategy,
228+
FileChunkingStrategyParam,
229+
OtherFileChunkingStrategyObject,
230+
StaticFileChunkingStrategy,
231+
StaticFileChunkingStrategyObject,
232+
StaticFileChunkingStrategyParam,
233+
VectorStore,
234+
VectorStoreDeleted,
235+
)
226236
```
227237

228238
Methods:

‎src/openai/resources/beta/vector_stores/file_batches.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
from ...._resource import SyncAPIResource, AsyncAPIResource
2323
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2424
from ....pagination import SyncCursorPage, AsyncCursorPage
25-
from ...._base_client import (
26-
AsyncPaginator,
27-
make_request_options,
28-
)
25+
from ....types.beta import FileChunkingStrategyParam
26+
from ...._base_client import AsyncPaginator, make_request_options
2927
from ....types.beta.vector_stores import file_batch_create_params, file_batch_list_files_params
28+
from ....types.beta.file_chunking_strategy_param import FileChunkingStrategyParam
3029
from ....types.beta.vector_stores.vector_store_file import VectorStoreFile
3130
from ....types.beta.vector_stores.vector_store_file_batch import VectorStoreFileBatch
3231

@@ -47,7 +46,7 @@ def create(
4746
vector_store_id: str,
4847
*,
4948
file_ids: List[str],
50-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
49+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
5150
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5251
# The extra values given here take precedence over values defined on the client or passed to this method.
5352
extra_headers: Headers | None = None,
@@ -64,7 +63,7 @@ def create(
6463
files.
6564
6665
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
67-
strategy.
66+
strategy. Only applicable if `file_ids` is non-empty.
6867
6968
extra_headers: Send extra headers
7069
@@ -174,7 +173,7 @@ def create_and_poll(
174173
*,
175174
file_ids: List[str],
176175
poll_interval_ms: int | NotGiven = NOT_GIVEN,
177-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
176+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
178177
) -> VectorStoreFileBatch:
179178
"""Create a vector store batch and poll until all files have been processed."""
180179
batch = self.create(
@@ -308,7 +307,7 @@ def upload_and_poll(
308307
max_concurrency: int = 5,
309308
file_ids: List[str] = [],
310309
poll_interval_ms: int | NotGiven = NOT_GIVEN,
311-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
310+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
312311
) -> VectorStoreFileBatch:
313312
"""Uploads the given files concurrently and then creates a vector store file batch.
314313
@@ -365,7 +364,7 @@ async def create(
365364
vector_store_id: str,
366365
*,
367366
file_ids: List[str],
368-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
367+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
369368
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
370369
# The extra values given here take precedence over values defined on the client or passed to this method.
371370
extra_headers: Headers | None = None,
@@ -382,7 +381,7 @@ async def create(
382381
files.
383382
384383
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
385-
strategy.
384+
strategy. Only applicable if `file_ids` is non-empty.
386385
387386
extra_headers: Send extra headers
388387
@@ -492,7 +491,7 @@ async def create_and_poll(
492491
*,
493492
file_ids: List[str],
494493
poll_interval_ms: int | NotGiven = NOT_GIVEN,
495-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
494+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
496495
) -> VectorStoreFileBatch:
497496
"""Create a vector store batch and poll until all files have been processed."""
498497
batch = await self.create(
@@ -626,7 +625,7 @@ async def upload_and_poll(
626625
max_concurrency: int = 5,
627626
file_ids: List[str] = [],
628627
poll_interval_ms: int | NotGiven = NOT_GIVEN,
629-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
628+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
630629
) -> VectorStoreFileBatch:
631630
"""Uploads the given files concurrently and then creates a vector store file batch.
632631

‎src/openai/resources/beta/vector_stores/files.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
from ...._resource import SyncAPIResource, AsyncAPIResource
1919
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2020
from ....pagination import SyncCursorPage, AsyncCursorPage
21-
from ...._base_client import (
22-
AsyncPaginator,
23-
make_request_options,
24-
)
21+
from ....types.beta import FileChunkingStrategyParam
22+
from ...._base_client import AsyncPaginator, make_request_options
2523
from ....types.beta.vector_stores import file_list_params, file_create_params
24+
from ....types.beta.file_chunking_strategy_param import FileChunkingStrategyParam
2625
from ....types.beta.vector_stores.vector_store_file import VectorStoreFile
2726
from ....types.beta.vector_stores.vector_store_file_deleted import VectorStoreFileDeleted
2827

@@ -43,7 +42,7 @@ def create(
4342
vector_store_id: str,
4443
*,
4544
file_id: str,
46-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
45+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
4746
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4847
# The extra values given here take precedence over values defined on the client or passed to this method.
4948
extra_headers: Headers | None = None,
@@ -62,7 +61,7 @@ def create(
6261
files.
6362
6463
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
65-
strategy.
64+
strategy. Only applicable if `file_ids` is non-empty.
6665
6766
extra_headers: Send extra headers
6867
@@ -245,7 +244,7 @@ def create_and_poll(
245244
*,
246245
vector_store_id: str,
247246
poll_interval_ms: int | NotGiven = NOT_GIVEN,
248-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
247+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
249248
) -> VectorStoreFile:
250249
"""Attach a file to the given vector store and wait for it to be processed."""
251250
self.create(vector_store_id=vector_store_id, file_id=file_id, chunking_strategy=chunking_strategy)
@@ -302,7 +301,7 @@ def upload(
302301
*,
303302
vector_store_id: str,
304303
file: FileTypes,
305-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
304+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
306305
) -> VectorStoreFile:
307306
"""Upload a file to the `files` API and then attach it to the given vector store.
308307
@@ -318,7 +317,7 @@ def upload_and_poll(
318317
vector_store_id: str,
319318
file: FileTypes,
320319
poll_interval_ms: int | NotGiven = NOT_GIVEN,
321-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
320+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
322321
) -> VectorStoreFile:
323322
"""Add a file to a vector store and poll until processing is complete."""
324323
file_obj = self._client.files.create(file=file, purpose="assistants")
@@ -344,7 +343,7 @@ async def create(
344343
vector_store_id: str,
345344
*,
346345
file_id: str,
347-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
346+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
348347
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
349348
# The extra values given here take precedence over values defined on the client or passed to this method.
350349
extra_headers: Headers | None = None,
@@ -363,7 +362,7 @@ async def create(
363362
files.
364363
365364
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
366-
strategy.
365+
strategy. Only applicable if `file_ids` is non-empty.
367366
368367
extra_headers: Send extra headers
369368
@@ -546,7 +545,7 @@ async def create_and_poll(
546545
*,
547546
vector_store_id: str,
548547
poll_interval_ms: int | NotGiven = NOT_GIVEN,
549-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
548+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
550549
) -> VectorStoreFile:
551550
"""Attach a file to the given vector store and wait for it to be processed."""
552551
await self.create(vector_store_id=vector_store_id, file_id=file_id, chunking_strategy=chunking_strategy)
@@ -603,7 +602,7 @@ async def upload(
603602
*,
604603
vector_store_id: str,
605604
file: FileTypes,
606-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
605+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
607606
) -> VectorStoreFile:
608607
"""Upload a file to the `files` API and then attach it to the given vector store.
609608
@@ -621,7 +620,7 @@ async def upload_and_poll(
621620
vector_store_id: str,
622621
file: FileTypes,
623622
poll_interval_ms: int | NotGiven = NOT_GIVEN,
624-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
623+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
625624
) -> VectorStoreFile:
626625
"""Add a file to a vector store and poll until processing is complete."""
627626
file_obj = await self._client.files.create(file=file, purpose="assistants")

‎src/openai/resources/beta/vector_stores/vector_stores.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
AsyncFileBatchesWithStreamingResponse,
3434
)
3535
from ....pagination import SyncCursorPage, AsyncCursorPage
36-
from ....types.beta import vector_store_list_params, vector_store_create_params, vector_store_update_params
37-
from ...._base_client import (
38-
AsyncPaginator,
39-
make_request_options,
36+
from ....types.beta import (
37+
FileChunkingStrategyParam,
38+
vector_store_list_params,
39+
vector_store_create_params,
40+
vector_store_update_params,
4041
)
42+
from ...._base_client import AsyncPaginator, make_request_options
4143
from ....types.beta.vector_store import VectorStore
4244
from ....types.beta.vector_store_deleted import VectorStoreDeleted
45+
from ....types.beta.file_chunking_strategy_param import FileChunkingStrategyParam
4346

4447
__all__ = ["VectorStores", "AsyncVectorStores"]
4548

@@ -64,7 +67,7 @@ def with_streaming_response(self) -> VectorStoresWithStreamingResponse:
6467
def create(
6568
self,
6669
*,
67-
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
70+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
6871
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
6972
file_ids: List[str] | NotGiven = NOT_GIVEN,
7073
metadata: Optional[object] | NotGiven = NOT_GIVEN,
@@ -331,7 +334,7 @@ def with_streaming_response(self) -> AsyncVectorStoresWithStreamingResponse:
331334
async def create(
332335
self,
333336
*,
334-
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
337+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
335338
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
336339
file_ids: List[str] | NotGiven = NOT_GIVEN,
337340
metadata: Optional[object] | NotGiven = NOT_GIVEN,

‎src/openai/types/beta/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .assistant_tool_choice import AssistantToolChoice as AssistantToolChoice
2020
from .code_interpreter_tool import CodeInterpreterTool as CodeInterpreterTool
2121
from .assistant_stream_event import AssistantStreamEvent as AssistantStreamEvent
22+
from .file_chunking_strategy import FileChunkingStrategy as FileChunkingStrategy
2223
from .file_search_tool_param import FileSearchToolParam as FileSearchToolParam
2324
from .assistant_create_params import AssistantCreateParams as AssistantCreateParams
2425
from .assistant_update_params import AssistantUpdateParams as AssistantUpdateParams
@@ -28,11 +29,17 @@
2829
from .assistant_tool_choice_param import AssistantToolChoiceParam as AssistantToolChoiceParam
2930
from .code_interpreter_tool_param import CodeInterpreterToolParam as CodeInterpreterToolParam
3031
from .assistant_tool_choice_option import AssistantToolChoiceOption as AssistantToolChoiceOption
32+
from .file_chunking_strategy_param import FileChunkingStrategyParam as FileChunkingStrategyParam
3133
from .thread_create_and_run_params import ThreadCreateAndRunParams as ThreadCreateAndRunParams
34+
from .static_file_chunking_strategy import StaticFileChunkingStrategy as StaticFileChunkingStrategy
3235
from .assistant_tool_choice_function import AssistantToolChoiceFunction as AssistantToolChoiceFunction
3336
from .assistant_response_format_option import AssistantResponseFormatOption as AssistantResponseFormatOption
37+
from .auto_file_chunking_strategy_param import AutoFileChunkingStrategyParam as AutoFileChunkingStrategyParam
3438
from .assistant_tool_choice_option_param import AssistantToolChoiceOptionParam as AssistantToolChoiceOptionParam
39+
from .other_file_chunking_strategy_object import OtherFileChunkingStrategyObject as OtherFileChunkingStrategyObject
40+
from .static_file_chunking_strategy_param import StaticFileChunkingStrategyParam as StaticFileChunkingStrategyParam
3541
from .assistant_tool_choice_function_param import AssistantToolChoiceFunctionParam as AssistantToolChoiceFunctionParam
42+
from .static_file_chunking_strategy_object import StaticFileChunkingStrategyObject as StaticFileChunkingStrategyObject
3643
from .assistant_response_format_option_param import (
3744
AssistantResponseFormatOptionParam as AssistantResponseFormatOptionParam,
3845
)

‎src/openai/types/beta/assistant_create_params.py

+5-39
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from __future__ import annotations
44

55
from typing import List, Union, Iterable, Optional
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict
6+
from typing_extensions import Required, TypedDict
77

88
from ..chat_model import ChatModel
99
from .assistant_tool_param import AssistantToolParam
10+
from .file_chunking_strategy_param import FileChunkingStrategyParam
1011
from .assistant_response_format_option_param import AssistantResponseFormatOptionParam
1112

1213
__all__ = [
@@ -15,10 +16,6 @@
1516
"ToolResourcesCodeInterpreter",
1617
"ToolResourcesFileSearch",
1718
"ToolResourcesFileSearchVectorStore",
18-
"ToolResourcesFileSearchVectorStoreChunkingStrategy",
19-
"ToolResourcesFileSearchVectorStoreChunkingStrategyAuto",
20-
"ToolResourcesFileSearchVectorStoreChunkingStrategyStatic",
21-
"ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic",
2219
]
2320

2421

@@ -118,43 +115,12 @@ class ToolResourcesCodeInterpreter(TypedDict, total=False):
118115
"""
119116

120117

121-
class ToolResourcesFileSearchVectorStoreChunkingStrategyAuto(TypedDict, total=False):
122-
type: Required[Literal["auto"]]
123-
"""Always `auto`."""
124-
125-
126-
class ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic(TypedDict, total=False):
127-
chunk_overlap_tokens: Required[int]
128-
"""The number of tokens that overlap between chunks. The default value is `400`.
129-
130-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
131-
"""
132-
133-
max_chunk_size_tokens: Required[int]
134-
"""The maximum number of tokens in each chunk.
135-
136-
The default value is `800`. The minimum value is `100` and the maximum value is
137-
`4096`.
138-
"""
139-
140-
141-
class ToolResourcesFileSearchVectorStoreChunkingStrategyStatic(TypedDict, total=False):
142-
static: Required[ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic]
143-
144-
type: Required[Literal["static"]]
145-
"""Always `static`."""
146-
147-
148-
ToolResourcesFileSearchVectorStoreChunkingStrategy: TypeAlias = Union[
149-
ToolResourcesFileSearchVectorStoreChunkingStrategyAuto, ToolResourcesFileSearchVectorStoreChunkingStrategyStatic
150-
]
151-
152-
153118
class ToolResourcesFileSearchVectorStore(TypedDict, total=False):
154-
chunking_strategy: ToolResourcesFileSearchVectorStoreChunkingStrategy
119+
chunking_strategy: FileChunkingStrategyParam
155120
"""The chunking strategy used to chunk the file(s).
156121
157-
If not set, will use the `auto` strategy.
122+
If not set, will use the `auto` strategy. Only applicable if `file_ids` is
123+
non-empty.
158124
"""
159125

160126
file_ids: List[str]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Literal, Required, TypedDict
6+
7+
__all__ = ["AutoFileChunkingStrategyParam"]
8+
9+
10+
class AutoFileChunkingStrategyParam(TypedDict, total=False):
11+
type: Required[Literal["auto"]]
12+
"""Always `auto`."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Union
4+
from typing_extensions import Annotated, TypeAlias
5+
6+
from ..._utils import PropertyInfo
7+
from .other_file_chunking_strategy_object import OtherFileChunkingStrategyObject
8+
from .static_file_chunking_strategy_object import StaticFileChunkingStrategyObject
9+
10+
__all__ = ["FileChunkingStrategy"]
11+
12+
FileChunkingStrategy: TypeAlias = Annotated[
13+
Union[StaticFileChunkingStrategyObject, OtherFileChunkingStrategyObject], PropertyInfo(discriminator="type")
14+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Union
6+
from typing_extensions import TypeAlias
7+
8+
from .auto_file_chunking_strategy_param import AutoFileChunkingStrategyParam
9+
from .static_file_chunking_strategy_param import StaticFileChunkingStrategyParam
10+
11+
__all__ = ["FileChunkingStrategyParam"]
12+
13+
FileChunkingStrategyParam: TypeAlias = Union[AutoFileChunkingStrategyParam, StaticFileChunkingStrategyParam]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal
4+
5+
from ..._models import BaseModel
6+
7+
__all__ = ["OtherFileChunkingStrategyObject"]
8+
9+
10+
class OtherFileChunkingStrategyObject(BaseModel):
11+
type: Literal["other"]
12+
"""Always `other`."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
4+
5+
from ..._models import BaseModel
6+
7+
__all__ = ["StaticFileChunkingStrategy"]
8+
9+
10+
class StaticFileChunkingStrategy(BaseModel):
11+
chunk_overlap_tokens: int
12+
"""The number of tokens that overlap between chunks. The default value is `400`.
13+
14+
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
15+
"""
16+
17+
max_chunk_size_tokens: int
18+
"""The maximum number of tokens in each chunk.
19+
20+
The default value is `800`. The minimum value is `100` and the maximum value is
21+
`4096`.
22+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal
4+
5+
from ..._models import BaseModel
6+
from .static_file_chunking_strategy import StaticFileChunkingStrategy
7+
8+
__all__ = ["StaticFileChunkingStrategyObject"]
9+
10+
11+
class StaticFileChunkingStrategyObject(BaseModel):
12+
static: StaticFileChunkingStrategy
13+
14+
type: Literal["static"]
15+
"""Always `static`."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
__all__ = ["StaticFileChunkingStrategyParam"]
8+
9+
10+
class StaticFileChunkingStrategyParam(TypedDict, total=False):
11+
chunk_overlap_tokens: Required[int]
12+
"""The number of tokens that overlap between chunks. The default value is `400`.
13+
14+
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
15+
"""
16+
17+
max_chunk_size_tokens: Required[int]
18+
"""The maximum number of tokens in each chunk.
19+
20+
The default value is `800`. The minimum value is `100` and the maximum value is
21+
`4096`.
22+
"""

‎src/openai/types/beta/thread_create_and_run_params.py

+4-39
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .function_tool_param import FunctionToolParam
1010
from .file_search_tool_param import FileSearchToolParam
1111
from .code_interpreter_tool_param import CodeInterpreterToolParam
12+
from .file_chunking_strategy_param import FileChunkingStrategyParam
1213
from .assistant_tool_choice_option_param import AssistantToolChoiceOptionParam
1314
from .threads.message_content_part_param import MessageContentPartParam
1415
from .assistant_response_format_option_param import AssistantResponseFormatOptionParam
@@ -24,10 +25,6 @@
2425
"ThreadToolResourcesCodeInterpreter",
2526
"ThreadToolResourcesFileSearch",
2627
"ThreadToolResourcesFileSearchVectorStore",
27-
"ThreadToolResourcesFileSearchVectorStoreChunkingStrategy",
28-
"ThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto",
29-
"ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic",
30-
"ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic",
3128
"ToolResources",
3229
"ToolResourcesCodeInterpreter",
3330
"ToolResourcesFileSearch",
@@ -218,44 +215,12 @@ class ThreadToolResourcesCodeInterpreter(TypedDict, total=False):
218215
"""
219216

220217

221-
class ThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto(TypedDict, total=False):
222-
type: Required[Literal["auto"]]
223-
"""Always `auto`."""
224-
225-
226-
class ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic(TypedDict, total=False):
227-
chunk_overlap_tokens: Required[int]
228-
"""The number of tokens that overlap between chunks. The default value is `400`.
229-
230-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
231-
"""
232-
233-
max_chunk_size_tokens: Required[int]
234-
"""The maximum number of tokens in each chunk.
235-
236-
The default value is `800`. The minimum value is `100` and the maximum value is
237-
`4096`.
238-
"""
239-
240-
241-
class ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic(TypedDict, total=False):
242-
static: Required[ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic]
243-
244-
type: Required[Literal["static"]]
245-
"""Always `static`."""
246-
247-
248-
ThreadToolResourcesFileSearchVectorStoreChunkingStrategy: TypeAlias = Union[
249-
ThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto,
250-
ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic,
251-
]
252-
253-
254218
class ThreadToolResourcesFileSearchVectorStore(TypedDict, total=False):
255-
chunking_strategy: ThreadToolResourcesFileSearchVectorStoreChunkingStrategy
219+
chunking_strategy: FileChunkingStrategyParam
256220
"""The chunking strategy used to chunk the file(s).
257221
258-
If not set, will use the `auto` strategy.
222+
If not set, will use the `auto` strategy. Only applicable if `file_ids` is
223+
non-empty.
259224
"""
260225

261226
file_ids: List[str]

‎src/openai/types/beta/thread_create_params.py

+4-38
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

88
from .code_interpreter_tool_param import CodeInterpreterToolParam
9+
from .file_chunking_strategy_param import FileChunkingStrategyParam
910
from .threads.message_content_part_param import MessageContentPartParam
1011

1112
__all__ = [
@@ -18,10 +19,6 @@
1819
"ToolResourcesCodeInterpreter",
1920
"ToolResourcesFileSearch",
2021
"ToolResourcesFileSearchVectorStore",
21-
"ToolResourcesFileSearchVectorStoreChunkingStrategy",
22-
"ToolResourcesFileSearchVectorStoreChunkingStrategyAuto",
23-
"ToolResourcesFileSearchVectorStoreChunkingStrategyStatic",
24-
"ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic",
2522
]
2623

2724

@@ -99,43 +96,12 @@ class ToolResourcesCodeInterpreter(TypedDict, total=False):
9996
"""
10097

10198

102-
class ToolResourcesFileSearchVectorStoreChunkingStrategyAuto(TypedDict, total=False):
103-
type: Required[Literal["auto"]]
104-
"""Always `auto`."""
105-
106-
107-
class ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic(TypedDict, total=False):
108-
chunk_overlap_tokens: Required[int]
109-
"""The number of tokens that overlap between chunks. The default value is `400`.
110-
111-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
112-
"""
113-
114-
max_chunk_size_tokens: Required[int]
115-
"""The maximum number of tokens in each chunk.
116-
117-
The default value is `800`. The minimum value is `100` and the maximum value is
118-
`4096`.
119-
"""
120-
121-
122-
class ToolResourcesFileSearchVectorStoreChunkingStrategyStatic(TypedDict, total=False):
123-
static: Required[ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic]
124-
125-
type: Required[Literal["static"]]
126-
"""Always `static`."""
127-
128-
129-
ToolResourcesFileSearchVectorStoreChunkingStrategy: TypeAlias = Union[
130-
ToolResourcesFileSearchVectorStoreChunkingStrategyAuto, ToolResourcesFileSearchVectorStoreChunkingStrategyStatic
131-
]
132-
133-
13499
class ToolResourcesFileSearchVectorStore(TypedDict, total=False):
135-
chunking_strategy: ToolResourcesFileSearchVectorStoreChunkingStrategy
100+
chunking_strategy: FileChunkingStrategyParam
136101
"""The chunking strategy used to chunk the file(s).
137102
138-
If not set, will use the `auto` strategy.
103+
If not set, will use the `auto` strategy. Only applicable if `file_ids` is
104+
non-empty.
139105
"""
140106

141107
file_ids: List[str]

‎src/openai/types/beta/vector_store_create_params.py

+6-41
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Optional
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict
5+
from typing import List, Optional
6+
from typing_extensions import Literal, Required, TypedDict
77

8-
__all__ = [
9-
"VectorStoreCreateParams",
10-
"ChunkingStrategy",
11-
"ChunkingStrategyAuto",
12-
"ChunkingStrategyStatic",
13-
"ChunkingStrategyStaticStatic",
14-
"ExpiresAfter",
15-
]
8+
from .file_chunking_strategy_param import FileChunkingStrategyParam
9+
10+
__all__ = ["VectorStoreCreateParams", "ExpiresAfter"]
1611

1712

1813
class VectorStoreCreateParams(TypedDict, total=False):
19-
chunking_strategy: ChunkingStrategy
14+
chunking_strategy: FileChunkingStrategyParam
2015
"""The chunking strategy used to chunk the file(s).
2116
2217
If not set, will use the `auto` strategy. Only applicable if `file_ids` is
@@ -45,36 +40,6 @@ class VectorStoreCreateParams(TypedDict, total=False):
4540
"""The name of the vector store."""
4641

4742

48-
class ChunkingStrategyAuto(TypedDict, total=False):
49-
type: Required[Literal["auto"]]
50-
"""Always `auto`."""
51-
52-
53-
class ChunkingStrategyStaticStatic(TypedDict, total=False):
54-
chunk_overlap_tokens: Required[int]
55-
"""The number of tokens that overlap between chunks. The default value is `400`.
56-
57-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
58-
"""
59-
60-
max_chunk_size_tokens: Required[int]
61-
"""The maximum number of tokens in each chunk.
62-
63-
The default value is `800`. The minimum value is `100` and the maximum value is
64-
`4096`.
65-
"""
66-
67-
68-
class ChunkingStrategyStatic(TypedDict, total=False):
69-
static: Required[ChunkingStrategyStaticStatic]
70-
71-
type: Required[Literal["static"]]
72-
"""Always `static`."""
73-
74-
75-
ChunkingStrategy: TypeAlias = Union[ChunkingStrategyAuto, ChunkingStrategyStatic]
76-
77-
7843
class ExpiresAfter(TypedDict, total=False):
7944
anchor: Required[Literal["last_active_at"]]
8045
"""Anchor timestamp after which the expiration policy applies.

‎src/openai/types/beta/vector_stores/file_batch_create_params.py

+8-43
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict
5+
from typing import List
6+
from typing_extensions import Required, TypedDict
77

8-
__all__ = [
9-
"FileBatchCreateParams",
10-
"ChunkingStrategy",
11-
"ChunkingStrategyAutoChunkingStrategyRequestParam",
12-
"ChunkingStrategyStaticChunkingStrategyRequestParam",
13-
"ChunkingStrategyStaticChunkingStrategyRequestParamStatic",
14-
]
8+
from ..file_chunking_strategy_param import FileChunkingStrategyParam
9+
10+
__all__ = ["FileBatchCreateParams"]
1511

1612

1713
class FileBatchCreateParams(TypedDict, total=False):
@@ -22,40 +18,9 @@ class FileBatchCreateParams(TypedDict, total=False):
2218
files.
2319
"""
2420

25-
chunking_strategy: ChunkingStrategy
21+
chunking_strategy: FileChunkingStrategyParam
2622
"""The chunking strategy used to chunk the file(s).
2723
28-
If not set, will use the `auto` strategy.
29-
"""
30-
31-
32-
class ChunkingStrategyAutoChunkingStrategyRequestParam(TypedDict, total=False):
33-
type: Required[Literal["auto"]]
34-
"""Always `auto`."""
35-
36-
37-
class ChunkingStrategyStaticChunkingStrategyRequestParamStatic(TypedDict, total=False):
38-
chunk_overlap_tokens: Required[int]
39-
"""The number of tokens that overlap between chunks. The default value is `400`.
40-
41-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
24+
If not set, will use the `auto` strategy. Only applicable if `file_ids` is
25+
non-empty.
4226
"""
43-
44-
max_chunk_size_tokens: Required[int]
45-
"""The maximum number of tokens in each chunk.
46-
47-
The default value is `800`. The minimum value is `100` and the maximum value is
48-
`4096`.
49-
"""
50-
51-
52-
class ChunkingStrategyStaticChunkingStrategyRequestParam(TypedDict, total=False):
53-
static: Required[ChunkingStrategyStaticChunkingStrategyRequestParamStatic]
54-
55-
type: Required[Literal["static"]]
56-
"""Always `static`."""
57-
58-
59-
ChunkingStrategy: TypeAlias = Union[
60-
ChunkingStrategyAutoChunkingStrategyRequestParam, ChunkingStrategyStaticChunkingStrategyRequestParam
61-
]

‎src/openai/types/beta/vector_stores/file_create_params.py

+7-43
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
from __future__ import annotations
44

5-
from typing import Union
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict
5+
from typing_extensions import Required, TypedDict
76

8-
__all__ = [
9-
"FileCreateParams",
10-
"ChunkingStrategy",
11-
"ChunkingStrategyAutoChunkingStrategyRequestParam",
12-
"ChunkingStrategyStaticChunkingStrategyRequestParam",
13-
"ChunkingStrategyStaticChunkingStrategyRequestParamStatic",
14-
]
7+
from ..file_chunking_strategy_param import FileChunkingStrategyParam
8+
9+
__all__ = ["FileCreateParams"]
1510

1611

1712
class FileCreateParams(TypedDict, total=False):
@@ -22,40 +17,9 @@ class FileCreateParams(TypedDict, total=False):
2217
files.
2318
"""
2419

25-
chunking_strategy: ChunkingStrategy
20+
chunking_strategy: FileChunkingStrategyParam
2621
"""The chunking strategy used to chunk the file(s).
2722
28-
If not set, will use the `auto` strategy.
29-
"""
30-
31-
32-
class ChunkingStrategyAutoChunkingStrategyRequestParam(TypedDict, total=False):
33-
type: Required[Literal["auto"]]
34-
"""Always `auto`."""
35-
36-
37-
class ChunkingStrategyStaticChunkingStrategyRequestParamStatic(TypedDict, total=False):
38-
chunk_overlap_tokens: Required[int]
39-
"""The number of tokens that overlap between chunks. The default value is `400`.
40-
41-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
23+
If not set, will use the `auto` strategy. Only applicable if `file_ids` is
24+
non-empty.
4225
"""
43-
44-
max_chunk_size_tokens: Required[int]
45-
"""The maximum number of tokens in each chunk.
46-
47-
The default value is `800`. The minimum value is `100` and the maximum value is
48-
`4096`.
49-
"""
50-
51-
52-
class ChunkingStrategyStaticChunkingStrategyRequestParam(TypedDict, total=False):
53-
static: Required[ChunkingStrategyStaticChunkingStrategyRequestParamStatic]
54-
55-
type: Required[Literal["static"]]
56-
"""Always `static`."""
57-
58-
59-
ChunkingStrategy: TypeAlias = Union[
60-
ChunkingStrategyAutoChunkingStrategyRequestParam, ChunkingStrategyStaticChunkingStrategyRequestParam
61-
]
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Union, Optional
4-
from typing_extensions import Literal, Annotated, TypeAlias
3+
from typing import Optional
4+
from typing_extensions import Literal
55

6-
from ...._utils import PropertyInfo
76
from ...._models import BaseModel
7+
from ..file_chunking_strategy import FileChunkingStrategy
88

9-
__all__ = [
10-
"VectorStoreFile",
11-
"LastError",
12-
"ChunkingStrategy",
13-
"ChunkingStrategyStatic",
14-
"ChunkingStrategyStaticStatic",
15-
"ChunkingStrategyOther",
16-
]
9+
__all__ = ["VectorStoreFile", "LastError"]
1710

1811

1912
class LastError(BaseModel):
@@ -24,38 +17,6 @@ class LastError(BaseModel):
2417
"""A human-readable description of the error."""
2518

2619

27-
class ChunkingStrategyStaticStatic(BaseModel):
28-
chunk_overlap_tokens: int
29-
"""The number of tokens that overlap between chunks. The default value is `400`.
30-
31-
Note that the overlap must not exceed half of `max_chunk_size_tokens`.
32-
"""
33-
34-
max_chunk_size_tokens: int
35-
"""The maximum number of tokens in each chunk.
36-
37-
The default value is `800`. The minimum value is `100` and the maximum value is
38-
`4096`.
39-
"""
40-
41-
42-
class ChunkingStrategyStatic(BaseModel):
43-
static: ChunkingStrategyStaticStatic
44-
45-
type: Literal["static"]
46-
"""Always `static`."""
47-
48-
49-
class ChunkingStrategyOther(BaseModel):
50-
type: Literal["other"]
51-
"""Always `other`."""
52-
53-
54-
ChunkingStrategy: TypeAlias = Annotated[
55-
Union[ChunkingStrategyStatic, ChunkingStrategyOther], PropertyInfo(discriminator="type")
56-
]
57-
58-
5920
class VectorStoreFile(BaseModel):
6021
id: str
6122
"""The identifier, which can be referenced in API endpoints."""
@@ -93,5 +54,5 @@ class VectorStoreFile(BaseModel):
9354
attached to.
9455
"""
9556

96-
chunking_strategy: Optional[ChunkingStrategy] = None
57+
chunking_strategy: Optional[FileChunkingStrategy] = None
9758
"""The strategy used to chunk the file."""

0 commit comments

Comments
 (0)
Please sign in to comment.