Skip to content

Commit 0ee81a2

Browse files
feat(vector store): improve chunking strategy type names (#1041)
1 parent 6b8975b commit 0ee81a2

File tree

10 files changed

+120
-288
lines changed

10 files changed

+120
-288
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ Methods:
198198

199199
Types:
200200

201+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">AutoFileChunkingStrategyParam</a></code>
202+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">FileChunkingStrategy</a></code>
203+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">FileChunkingStrategyParam</a></code>
204+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">OtherFileChunkingStrategyObject</a></code>
205+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">StaticFileChunkingStrategy</a></code>
206+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">StaticFileChunkingStrategyObject</a></code>
207+
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">StaticFileChunkingStrategyParam</a></code>
201208
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">VectorStore</a></code>
202209
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">VectorStoreDeleted</a></code>
203210

src/resources/beta/assistants.ts

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as Shared from '../shared';
88
import * as ChatAPI from '../chat/chat';
99
import * as MessagesAPI from './threads/messages';
1010
import * as ThreadsAPI from './threads/threads';
11+
import * as VectorStoresAPI from './vector-stores/vector-stores';
1112
import * as RunsAPI from './threads/runs/runs';
1213
import * as StepsAPI from './threads/runs/steps';
1314
import { CursorPage, type CursorPageParams } from '../../pagination';
@@ -1218,9 +1219,9 @@ export namespace AssistantCreateParams {
12181219
export interface VectorStore {
12191220
/**
12201221
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
1221-
* strategy.
1222+
* strategy. Only applicable if `file_ids` is non-empty.
12221223
*/
1223-
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
1224+
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
12241225

12251226
/**
12261227
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
@@ -1237,45 +1238,6 @@ export namespace AssistantCreateParams {
12371238
*/
12381239
metadata?: unknown;
12391240
}
1240-
1241-
export namespace VectorStore {
1242-
/**
1243-
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
1244-
* `800` and `chunk_overlap_tokens` of `400`.
1245-
*/
1246-
export interface Auto {
1247-
/**
1248-
* Always `auto`.
1249-
*/
1250-
type: 'auto';
1251-
}
1252-
1253-
export interface Static {
1254-
static: Static.Static;
1255-
1256-
/**
1257-
* Always `static`.
1258-
*/
1259-
type: 'static';
1260-
}
1261-
1262-
export namespace Static {
1263-
export interface Static {
1264-
/**
1265-
* The number of tokens that overlap between chunks. The default value is `400`.
1266-
*
1267-
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1268-
*/
1269-
chunk_overlap_tokens: number;
1270-
1271-
/**
1272-
* The maximum number of tokens in each chunk. The default value is `800`. The
1273-
* minimum value is `100` and the maximum value is `4096`.
1274-
*/
1275-
max_chunk_size_tokens: number;
1276-
}
1277-
}
1278-
}
12791241
}
12801242
}
12811243
}

src/resources/beta/beta.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export class Beta extends APIResource {
1313

1414
export namespace Beta {
1515
export import VectorStores = VectorStoresAPI.VectorStores;
16+
export import AutoFileChunkingStrategyParam = VectorStoresAPI.AutoFileChunkingStrategyParam;
17+
export import FileChunkingStrategy = VectorStoresAPI.FileChunkingStrategy;
18+
export import FileChunkingStrategyParam = VectorStoresAPI.FileChunkingStrategyParam;
19+
export import OtherFileChunkingStrategyObject = VectorStoresAPI.OtherFileChunkingStrategyObject;
20+
export import StaticFileChunkingStrategy = VectorStoresAPI.StaticFileChunkingStrategy;
21+
export import StaticFileChunkingStrategyObject = VectorStoresAPI.StaticFileChunkingStrategyObject;
22+
export import StaticFileChunkingStrategyParam = VectorStoresAPI.StaticFileChunkingStrategyParam;
1623
export import VectorStore = VectorStoresAPI.VectorStore;
1724
export import VectorStoreDeleted = VectorStoresAPI.VectorStoreDeleted;
1825
export import VectorStoresPage = VectorStoresAPI.VectorStoresPage;

src/resources/beta/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ export {
3232
ThreadCreateAndRunParamsStreaming,
3333
Threads,
3434
} from './threads/index';
35-
export { Beta } from './beta';
3635
export {
36+
AutoFileChunkingStrategyParam,
37+
FileChunkingStrategy,
38+
FileChunkingStrategyParam,
39+
OtherFileChunkingStrategyObject,
40+
StaticFileChunkingStrategy,
41+
StaticFileChunkingStrategyObject,
42+
StaticFileChunkingStrategyParam,
3743
VectorStore,
3844
VectorStoreDeleted,
3945
VectorStoreCreateParams,
@@ -42,3 +48,4 @@ export {
4248
VectorStoresPage,
4349
VectorStores,
4450
} from './vector-stores/index';
51+
export { Beta } from './beta';

src/resources/beta/threads/threads.ts

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as Shared from '../../shared';
99
import * as AssistantsAPI from '../assistants';
1010
import * as ChatAPI from '../../chat/chat';
1111
import * as MessagesAPI from './messages';
12+
import * as VectorStoresAPI from '../vector-stores/vector-stores';
1213
import * as RunsAPI from './runs/runs';
1314
import { Stream } from '../../../streaming';
1415

@@ -355,9 +356,9 @@ export namespace ThreadCreateParams {
355356
export interface VectorStore {
356357
/**
357358
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
358-
* strategy.
359+
* strategy. Only applicable if `file_ids` is non-empty.
359360
*/
360-
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
361+
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
361362

362363
/**
363364
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
@@ -374,45 +375,6 @@ export namespace ThreadCreateParams {
374375
*/
375376
metadata?: unknown;
376377
}
377-
378-
export namespace VectorStore {
379-
/**
380-
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
381-
* `800` and `chunk_overlap_tokens` of `400`.
382-
*/
383-
export interface Auto {
384-
/**
385-
* Always `auto`.
386-
*/
387-
type: 'auto';
388-
}
389-
390-
export interface Static {
391-
static: Static.Static;
392-
393-
/**
394-
* Always `static`.
395-
*/
396-
type: 'static';
397-
}
398-
399-
export namespace Static {
400-
export interface Static {
401-
/**
402-
* The number of tokens that overlap between chunks. The default value is `400`.
403-
*
404-
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
405-
*/
406-
chunk_overlap_tokens: number;
407-
408-
/**
409-
* The maximum number of tokens in each chunk. The default value is `800`. The
410-
* minimum value is `100` and the maximum value is `4096`.
411-
*/
412-
max_chunk_size_tokens: number;
413-
}
414-
}
415-
}
416378
}
417379
}
418380
}
@@ -741,9 +703,9 @@ export namespace ThreadCreateAndRunParams {
741703
export interface VectorStore {
742704
/**
743705
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
744-
* strategy.
706+
* strategy. Only applicable if `file_ids` is non-empty.
745707
*/
746-
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
708+
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
747709

748710
/**
749711
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
@@ -760,45 +722,6 @@ export namespace ThreadCreateAndRunParams {
760722
*/
761723
metadata?: unknown;
762724
}
763-
764-
export namespace VectorStore {
765-
/**
766-
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
767-
* `800` and `chunk_overlap_tokens` of `400`.
768-
*/
769-
export interface Auto {
770-
/**
771-
* Always `auto`.
772-
*/
773-
type: 'auto';
774-
}
775-
776-
export interface Static {
777-
static: Static.Static;
778-
779-
/**
780-
* Always `static`.
781-
*/
782-
type: 'static';
783-
}
784-
785-
export namespace Static {
786-
export interface Static {
787-
/**
788-
* The number of tokens that overlap between chunks. The default value is `400`.
789-
*
790-
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
791-
*/
792-
chunk_overlap_tokens: number;
793-
794-
/**
795-
* The maximum number of tokens in each chunk. The default value is `800`. The
796-
* minimum value is `100` and the maximum value is `4096`.
797-
*/
798-
max_chunk_size_tokens: number;
799-
}
800-
}
801-
}
802725
}
803726
}
804727
}

src/resources/beta/vector-stores/file-batches.ts

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as Core from '../../../core';
66
import * as FileBatchesAPI from './file-batches';
77
import * as FilesAPI from './files';
88
import { VectorStoreFilesPage } from './files';
9+
import * as VectorStoresAPI from './vector-stores';
910
import { type CursorPageParams } from '../../../pagination';
1011

1112
export class FileBatches extends APIResource {
@@ -160,50 +161,9 @@ export interface FileBatchCreateParams {
160161

161162
/**
162163
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
163-
* strategy.
164+
* strategy. Only applicable if `file_ids` is non-empty.
164165
*/
165-
chunking_strategy?:
166-
| FileBatchCreateParams.AutoChunkingStrategyRequestParam
167-
| FileBatchCreateParams.StaticChunkingStrategyRequestParam;
168-
}
169-
170-
export namespace FileBatchCreateParams {
171-
/**
172-
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
173-
* `800` and `chunk_overlap_tokens` of `400`.
174-
*/
175-
export interface AutoChunkingStrategyRequestParam {
176-
/**
177-
* Always `auto`.
178-
*/
179-
type: 'auto';
180-
}
181-
182-
export interface StaticChunkingStrategyRequestParam {
183-
static: StaticChunkingStrategyRequestParam.Static;
184-
185-
/**
186-
* Always `static`.
187-
*/
188-
type: 'static';
189-
}
190-
191-
export namespace StaticChunkingStrategyRequestParam {
192-
export interface Static {
193-
/**
194-
* The number of tokens that overlap between chunks. The default value is `400`.
195-
*
196-
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
197-
*/
198-
chunk_overlap_tokens: number;
199-
200-
/**
201-
* The maximum number of tokens in each chunk. The default value is `800`. The
202-
* minimum value is `100` and the maximum value is `4096`.
203-
*/
204-
max_chunk_size_tokens: number;
205-
}
206-
}
166+
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
207167
}
208168

209169
export interface FileBatchListFilesParams extends CursorPageParams {

0 commit comments

Comments
 (0)