Skip to content

Commit

Permalink
feat(vector store): improve chunking strategy type names (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot authored and stainless-app[bot] committed Sep 5, 2024
1 parent 0c0b6c9 commit 1d47541
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 287 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-85a85e0c08de456441431c0ae4e9c078cc8f9748c29430b9a9058340db6389ee.yml
7 changes: 7 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ Methods:

Types:

- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">AutoFileChunkingStrategyParam</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">FileChunkingStrategy</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">FileChunkingStrategyParam</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">OtherFileChunkingStrategyObject</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">StaticFileChunkingStrategy</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">StaticFileChunkingStrategyObject</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">StaticFileChunkingStrategyParam</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">VectorStore</a></code>
- <code><a href="./src/resources/beta/vector-stores/vector-stores.ts">VectorStoreDeleted</a></code>

Expand Down
44 changes: 3 additions & 41 deletions src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Shared from '../shared';
import * as ChatAPI from '../chat/chat';
import * as MessagesAPI from './threads/messages';
import * as ThreadsAPI from './threads/threads';
import * as VectorStoresAPI from './vector-stores/vector-stores';
import * as RunsAPI from './threads/runs/runs';
import * as StepsAPI from './threads/runs/steps';
import { CursorPage, type CursorPageParams } from '../../pagination';
Expand Down Expand Up @@ -1218,9 +1219,9 @@ export namespace AssistantCreateParams {
export interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
* strategy. Only applicable if `file_ids` is non-empty.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;

/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
Expand All @@ -1237,45 +1238,6 @@ export namespace AssistantCreateParams {
*/
metadata?: unknown;
}

export namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
export interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}

export interface Static {
static: Static.Static;

/**
* Always `static`.
*/
type: 'static';
}

export namespace Static {
export interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;

/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/resources/beta/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export class Beta extends APIResource {

export namespace Beta {
export import VectorStores = VectorStoresAPI.VectorStores;
export import AutoFileChunkingStrategyParam = VectorStoresAPI.AutoFileChunkingStrategyParam;
export import FileChunkingStrategy = VectorStoresAPI.FileChunkingStrategy;
export import FileChunkingStrategyParam = VectorStoresAPI.FileChunkingStrategyParam;
export import OtherFileChunkingStrategyObject = VectorStoresAPI.OtherFileChunkingStrategyObject;
export import StaticFileChunkingStrategy = VectorStoresAPI.StaticFileChunkingStrategy;
export import StaticFileChunkingStrategyObject = VectorStoresAPI.StaticFileChunkingStrategyObject;
export import StaticFileChunkingStrategyParam = VectorStoresAPI.StaticFileChunkingStrategyParam;
export import VectorStore = VectorStoresAPI.VectorStore;
export import VectorStoreDeleted = VectorStoresAPI.VectorStoreDeleted;
export import VectorStoresPage = VectorStoresAPI.VectorStoresPage;
Expand Down
7 changes: 7 additions & 0 deletions src/resources/beta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export {
export { Beta } from './beta';
export { Chat } from './chat/index';
export {
AutoFileChunkingStrategyParam,
FileChunkingStrategy,
FileChunkingStrategyParam,
OtherFileChunkingStrategyObject,
StaticFileChunkingStrategy,
StaticFileChunkingStrategyObject,
StaticFileChunkingStrategyParam,
VectorStore,
VectorStoreDeleted,
VectorStoreCreateParams,
Expand Down
87 changes: 5 additions & 82 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import * as ChatAPI from '../../chat/chat';
import * as MessagesAPI from './messages';
import * as VectorStoresAPI from '../vector-stores/vector-stores';
import * as RunsAPI from './runs/runs';
import { Stream } from '../../../streaming';

Expand Down Expand Up @@ -379,9 +380,9 @@ export namespace ThreadCreateParams {
export interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
* strategy. Only applicable if `file_ids` is non-empty.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;

/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
Expand All @@ -398,45 +399,6 @@ export namespace ThreadCreateParams {
*/
metadata?: unknown;
}

export namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
export interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}

export interface Static {
static: Static.Static;

/**
* Always `static`.
*/
type: 'static';
}

export namespace Static {
export interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;

/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
Expand Down Expand Up @@ -765,9 +727,9 @@ export namespace ThreadCreateAndRunParams {
export interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
* strategy. Only applicable if `file_ids` is non-empty.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;

/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
Expand All @@ -784,45 +746,6 @@ export namespace ThreadCreateAndRunParams {
*/
metadata?: unknown;
}

export namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
export interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}

export interface Static {
static: Static.Static;

/**
* Always `static`.
*/
type: 'static';
}

export namespace Static {
export interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;

/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
Expand Down
46 changes: 3 additions & 43 deletions src/resources/beta/vector-stores/file-batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as Core from '../../../core';
import * as FileBatchesAPI from './file-batches';
import * as FilesAPI from './files';
import { VectorStoreFilesPage } from './files';
import * as VectorStoresAPI from './vector-stores';
import { type CursorPageParams } from '../../../pagination';

export class FileBatches extends APIResource {
Expand Down Expand Up @@ -267,50 +268,9 @@ export interface FileBatchCreateParams {

/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
* strategy. Only applicable if `file_ids` is non-empty.
*/
chunking_strategy?:
| FileBatchCreateParams.AutoChunkingStrategyRequestParam
| FileBatchCreateParams.StaticChunkingStrategyRequestParam;
}

export namespace FileBatchCreateParams {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
export interface AutoChunkingStrategyRequestParam {
/**
* Always `auto`.
*/
type: 'auto';
}

export interface StaticChunkingStrategyRequestParam {
static: StaticChunkingStrategyRequestParam.Static;

/**
* Always `static`.
*/
type: 'static';
}

export namespace StaticChunkingStrategyRequestParam {
export interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;

/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
}

export interface FileBatchListFilesParams extends CursorPageParams {
Expand Down
Loading

0 comments on commit 1d47541

Please sign in to comment.