Skip to content

Commit 5f9435b

Browse files
feat(vector store): improve chunking strategy type names (#1690)
1 parent 8e07457 commit 5f9435b

20 files changed

+189
-300
lines changed

Diff for: .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

Diff for: api.md

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

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

227237
Methods:

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
from ...._resource import SyncAPIResource, AsyncAPIResource
1818
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
1919
from ....pagination import SyncCursorPage, AsyncCursorPage
20+
from ....types.beta import FileChunkingStrategyParam
2021
from ...._base_client import AsyncPaginator, make_request_options
2122
from ....types.beta.vector_stores import file_batch_create_params, file_batch_list_files_params
23+
from ....types.beta.file_chunking_strategy_param import FileChunkingStrategyParam
2224
from ....types.beta.vector_stores.vector_store_file import VectorStoreFile
2325
from ....types.beta.vector_stores.vector_store_file_batch import VectorStoreFileBatch
2426

@@ -39,7 +41,7 @@ def create(
3941
vector_store_id: str,
4042
*,
4143
file_ids: List[str],
42-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
44+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
4345
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4446
# The extra values given here take precedence over values defined on the client or passed to this method.
4547
extra_headers: Headers | None = None,
@@ -56,7 +58,7 @@ def create(
5658
files.
5759
5860
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
59-
strategy.
61+
strategy. Only applicable if `file_ids` is non-empty.
6062
6163
extra_headers: Send extra headers
6264
@@ -249,7 +251,7 @@ async def create(
249251
vector_store_id: str,
250252
*,
251253
file_ids: List[str],
252-
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
254+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
253255
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
254256
# The extra values given here take precedence over values defined on the client or passed to this method.
255257
extra_headers: Headers | None = None,
@@ -266,7 +268,7 @@ async def create(
266268
files.
267269
268270
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
269-
strategy.
271+
strategy. Only applicable if `file_ids` is non-empty.
270272
271273
extra_headers: Send extra headers
272274

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
from ...._resource import SyncAPIResource, AsyncAPIResource
1717
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
1818
from ....pagination import SyncCursorPage, AsyncCursorPage
19+
from ....types.beta import FileChunkingStrategyParam
1920
from ...._base_client import AsyncPaginator, make_request_options
2021
from ....types.beta.vector_stores import file_list_params, file_create_params
22+
from ....types.beta.file_chunking_strategy_param import FileChunkingStrategyParam
2123
from ....types.beta.vector_stores.vector_store_file import VectorStoreFile
2224
from ....types.beta.vector_stores.vector_store_file_deleted import VectorStoreFileDeleted
2325

@@ -38,7 +40,7 @@ def create(
3840
vector_store_id: str,
3941
*,
4042
file_id: str,
41-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
43+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
4244
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4345
# The extra values given here take precedence over values defined on the client or passed to this method.
4446
extra_headers: Headers | None = None,
@@ -57,7 +59,7 @@ def create(
5759
files.
5860
5961
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
60-
strategy.
62+
strategy. Only applicable if `file_ids` is non-empty.
6163
6264
extra_headers: Send extra headers
6365
@@ -249,7 +251,7 @@ async def create(
249251
vector_store_id: str,
250252
*,
251253
file_id: str,
252-
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
254+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
253255
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
254256
# The extra values given here take precedence over values defined on the client or passed to this method.
255257
extra_headers: Headers | None = None,
@@ -268,7 +270,7 @@ async def create(
268270
files.
269271
270272
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
271-
strategy.
273+
strategy. Only applicable if `file_ids` is non-empty.
272274
273275
extra_headers: Send extra headers
274276

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +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
36+
from ....types.beta import (
37+
FileChunkingStrategyParam,
38+
vector_store_list_params,
39+
vector_store_create_params,
40+
vector_store_update_params,
41+
)
3742
from ...._base_client import AsyncPaginator, make_request_options
3843
from ....types.beta.vector_store import VectorStore
3944
from ....types.beta.vector_store_deleted import VectorStoreDeleted
45+
from ....types.beta.file_chunking_strategy_param import FileChunkingStrategyParam
4046

4147
__all__ = ["VectorStores", "AsyncVectorStores"]
4248

@@ -61,7 +67,7 @@ def with_streaming_response(self) -> VectorStoresWithStreamingResponse:
6167
def create(
6268
self,
6369
*,
64-
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
70+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
6571
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
6672
file_ids: List[str] | NotGiven = NOT_GIVEN,
6773
metadata: Optional[object] | NotGiven = NOT_GIVEN,
@@ -328,7 +334,7 @@ def with_streaming_response(self) -> AsyncVectorStoresWithStreamingResponse:
328334
async def create(
329335
self,
330336
*,
331-
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
337+
chunking_strategy: FileChunkingStrategyParam | NotGiven = NOT_GIVEN,
332338
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
333339
file_ids: List[str] | NotGiven = NOT_GIVEN,
334340
metadata: Optional[object] | NotGiven = NOT_GIVEN,

Diff for: 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
)

Diff for: 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`."""

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

+14
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+
]
+13
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`."""
+22
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+
"""

0 commit comments

Comments
 (0)