@mixedbread/sdk 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/README.md +12 -24
- package/bin/migration-config.json +2 -2
- package/client.d.mts +4 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +4 -4
- package/client.d.ts.map +1 -1
- package/client.js +2 -2
- package/client.js.map +1 -1
- package/client.mjs +2 -2
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +1 -1
- package/core/pagination.d.mts.map +1 -1
- package/core/pagination.d.ts +1 -1
- package/core/pagination.d.ts.map +1 -1
- package/core/resource.d.mts +1 -1
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +1 -1
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/internal/detect-platform.js +3 -3
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs +3 -3
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +4 -4
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +4 -4
- package/internal/headers.mjs.map +1 -1
- package/internal/shim-types.d.mts +11 -22
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +11 -22
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +2 -2
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +2 -2
- package/internal/shims.d.ts.map +1 -1
- package/internal/uploads.js +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/log.js +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +1 -1
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/values.d.mts +2 -0
- package/internal/utils/values.d.mts.map +1 -1
- package/internal/utils/values.d.ts +2 -0
- package/internal/utils/values.d.ts.map +1 -1
- package/internal/utils/values.js +4 -1
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +2 -0
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +1 -4
- package/resources/data-sources/connectors.d.mts +14 -4
- package/resources/data-sources/connectors.d.mts.map +1 -1
- package/resources/data-sources/connectors.d.ts +14 -4
- package/resources/data-sources/connectors.d.ts.map +1 -1
- package/resources/data-sources/data-sources.d.mts +172 -35
- package/resources/data-sources/data-sources.d.mts.map +1 -1
- package/resources/data-sources/data-sources.d.ts +172 -35
- package/resources/data-sources/data-sources.d.ts.map +1 -1
- package/resources/data-sources/data-sources.js.map +1 -1
- package/resources/data-sources/data-sources.mjs.map +1 -1
- package/resources/data-sources/index.d.mts +1 -1
- package/resources/data-sources/index.d.mts.map +1 -1
- package/resources/data-sources/index.d.ts +1 -1
- package/resources/data-sources/index.d.ts.map +1 -1
- package/resources/data-sources/index.js.map +1 -1
- package/resources/data-sources/index.mjs.map +1 -1
- package/resources/extractions/content.d.mts +4 -0
- package/resources/extractions/content.d.mts.map +1 -1
- package/resources/extractions/content.d.ts +4 -0
- package/resources/extractions/content.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/vector-stores/files.d.mts +59 -26
- package/resources/vector-stores/files.d.mts.map +1 -1
- package/resources/vector-stores/files.d.ts +59 -26
- package/resources/vector-stores/files.d.ts.map +1 -1
- package/resources/vector-stores/files.js +32 -31
- package/resources/vector-stores/files.js.map +1 -1
- package/resources/vector-stores/files.mjs +32 -31
- package/resources/vector-stores/files.mjs.map +1 -1
- package/resources/vector-stores/index.d.mts +1 -1
- package/resources/vector-stores/index.d.mts.map +1 -1
- package/resources/vector-stores/index.d.ts +1 -1
- package/resources/vector-stores/index.d.ts.map +1 -1
- package/resources/vector-stores/index.js.map +1 -1
- package/resources/vector-stores/index.mjs.map +1 -1
- package/resources/vector-stores/vector-stores.d.mts +53 -18
- package/resources/vector-stores/vector-stores.d.mts.map +1 -1
- package/resources/vector-stores/vector-stores.d.ts +53 -18
- package/resources/vector-stores/vector-stores.d.ts.map +1 -1
- package/resources/vector-stores/vector-stores.js +18 -15
- package/resources/vector-stores/vector-stores.js.map +1 -1
- package/resources/vector-stores/vector-stores.mjs +18 -15
- package/resources/vector-stores/vector-stores.mjs.map +1 -1
- package/src/client.ts +10 -4
- package/src/core/pagination.ts +1 -1
- package/src/core/resource.ts +1 -1
- package/src/internal/detect-platform.ts +3 -3
- package/src/internal/headers.ts +5 -5
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +2 -2
- package/src/internal/uploads.ts +2 -2
- package/src/internal/utils/log.ts +1 -1
- package/src/internal/utils/path.ts +1 -1
- package/src/internal/utils/values.ts +3 -0
- package/src/resources/data-sources/connectors.ts +14 -4
- package/src/resources/data-sources/data-sources.ts +207 -37
- package/src/resources/data-sources/index.ts +3 -0
- package/src/resources/extractions/content.ts +5 -0
- package/src/resources/index.ts +3 -0
- package/src/resources/vector-stores/files.ts +81 -39
- package/src/resources/vector-stores/index.ts +2 -0
- package/src/resources/vector-stores/vector-stores.ts +67 -20
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/src/internal/shim-types.d.ts +0 -28
@@ -118,9 +118,9 @@ export interface DataSource {
|
|
118
118
|
metadata: unknown;
|
119
119
|
|
120
120
|
/**
|
121
|
-
* Authentication parameters
|
121
|
+
* Authentication parameters
|
122
122
|
*/
|
123
|
-
auth_params: DataSourceOauth2Params | null;
|
123
|
+
auth_params: DataSourceOauth2Params | DataSource.DataSourceAPIKeyParams | null;
|
124
124
|
|
125
125
|
/**
|
126
126
|
* The type of the object
|
@@ -128,6 +128,20 @@ export interface DataSource {
|
|
128
128
|
object?: 'data_source';
|
129
129
|
}
|
130
130
|
|
131
|
+
export namespace DataSource {
|
132
|
+
/**
|
133
|
+
* Authentication parameters for a API key data source.
|
134
|
+
*/
|
135
|
+
export interface DataSourceAPIKeyParams {
|
136
|
+
type?: 'api_key';
|
137
|
+
|
138
|
+
/**
|
139
|
+
* The API key
|
140
|
+
*/
|
141
|
+
api_key: string;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
131
145
|
/**
|
132
146
|
* Authentication parameters for a OAuth data source.
|
133
147
|
*/
|
@@ -139,25 +153,10 @@ export interface DataSourceOauth2Params {
|
|
139
153
|
*/
|
140
154
|
created_at?: string;
|
141
155
|
|
142
|
-
/**
|
143
|
-
* The OAuth2 client ID
|
144
|
-
*/
|
145
|
-
client_id: string;
|
146
|
-
|
147
|
-
/**
|
148
|
-
* The OAuth2 client secret
|
149
|
-
*/
|
150
|
-
client_secret: string;
|
151
|
-
|
152
|
-
/**
|
153
|
-
* The OAuth2 redirect URI
|
154
|
-
*/
|
155
|
-
redirect_uri: string;
|
156
|
-
|
157
156
|
/**
|
158
157
|
* The OAuth2 scope
|
159
158
|
*/
|
160
|
-
scope
|
159
|
+
scope?: string;
|
161
160
|
|
162
161
|
/**
|
163
162
|
* The OAuth2 access token
|
@@ -178,35 +177,48 @@ export interface DataSourceOauth2Params {
|
|
178
177
|
* The OAuth2 token expiration timestamp
|
179
178
|
*/
|
180
179
|
expires_on?: string | null;
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Additional parameters for the OAuth2 flow
|
183
|
+
*/
|
184
|
+
additional_params?: Record<string, unknown> | null;
|
181
185
|
}
|
182
186
|
|
183
187
|
export type DataSourceType = 'notion' | 'linear';
|
184
188
|
|
185
189
|
/**
|
186
|
-
*
|
190
|
+
* Parameters for creating or updating a Linear data source.
|
187
191
|
*/
|
188
|
-
export interface
|
192
|
+
export interface LinearDataSource {
|
189
193
|
/**
|
190
|
-
* The
|
194
|
+
* The type of data source to create
|
191
195
|
*/
|
192
|
-
|
196
|
+
type?: DataSourceType;
|
193
197
|
|
194
198
|
/**
|
195
|
-
*
|
199
|
+
* The name of the data source
|
196
200
|
*/
|
197
|
-
|
201
|
+
name: string;
|
198
202
|
|
199
203
|
/**
|
200
|
-
* The
|
204
|
+
* The metadata of the data source
|
201
205
|
*/
|
202
|
-
|
206
|
+
metadata?: unknown;
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Base class for OAuth2 create or update parameters.
|
210
|
+
*/
|
211
|
+
auth_params?: Oauth2Params | null;
|
203
212
|
}
|
204
213
|
|
205
|
-
|
214
|
+
/**
|
215
|
+
* Parameters for creating or updating a Notion data source.
|
216
|
+
*/
|
217
|
+
export interface NotionDataSource {
|
206
218
|
/**
|
207
219
|
* The type of data source to create
|
208
220
|
*/
|
209
|
-
type
|
221
|
+
type?: DataSourceType;
|
210
222
|
|
211
223
|
/**
|
212
224
|
* The name of the data source
|
@@ -219,26 +231,181 @@ export interface DataSourceCreateParams {
|
|
219
231
|
metadata?: unknown;
|
220
232
|
|
221
233
|
/**
|
222
|
-
*
|
234
|
+
* The authentication parameters of the data source. Notion supports OAuth2 and API
|
235
|
+
* key.
|
223
236
|
*/
|
224
|
-
auth_params?:
|
237
|
+
auth_params?: Oauth2Params | NotionDataSource.APIKeyCreateOrUpdateParams | null;
|
225
238
|
}
|
226
239
|
|
227
|
-
export
|
240
|
+
export namespace NotionDataSource {
|
228
241
|
/**
|
229
|
-
*
|
242
|
+
* Base class for API key create or update parameters.
|
230
243
|
*/
|
231
|
-
|
244
|
+
export interface APIKeyCreateOrUpdateParams {
|
245
|
+
type?: 'api_key';
|
232
246
|
|
247
|
+
/**
|
248
|
+
* The API key
|
249
|
+
*/
|
250
|
+
api_key: string;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Base class for OAuth2 create or update parameters.
|
256
|
+
*/
|
257
|
+
export interface Oauth2Params {
|
258
|
+
type?: 'oauth2';
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Deleted data source.
|
263
|
+
*/
|
264
|
+
export interface DataSourceDeleteResponse {
|
233
265
|
/**
|
234
|
-
* The
|
266
|
+
* The ID of the data source
|
235
267
|
*/
|
236
|
-
|
268
|
+
id: string;
|
237
269
|
|
238
270
|
/**
|
239
|
-
*
|
271
|
+
* Whether the data source was deleted
|
240
272
|
*/
|
241
|
-
|
273
|
+
deleted?: boolean;
|
274
|
+
|
275
|
+
/**
|
276
|
+
* The type of the object
|
277
|
+
*/
|
278
|
+
object?: 'data_source';
|
279
|
+
}
|
280
|
+
|
281
|
+
export type DataSourceCreateParams =
|
282
|
+
| DataSourceCreateParams.NotionDataSource
|
283
|
+
| DataSourceCreateParams.LinearDataSource;
|
284
|
+
|
285
|
+
export declare namespace DataSourceCreateParams {
|
286
|
+
export interface NotionDataSource {
|
287
|
+
/**
|
288
|
+
* The type of data source to create
|
289
|
+
*/
|
290
|
+
type?: DataSourceType;
|
291
|
+
|
292
|
+
/**
|
293
|
+
* The name of the data source
|
294
|
+
*/
|
295
|
+
name: string;
|
296
|
+
|
297
|
+
/**
|
298
|
+
* The metadata of the data source
|
299
|
+
*/
|
300
|
+
metadata?: unknown;
|
301
|
+
|
302
|
+
/**
|
303
|
+
* The authentication parameters of the data source. Notion supports OAuth2 and API
|
304
|
+
* key.
|
305
|
+
*/
|
306
|
+
auth_params?: Oauth2Params | NotionDataSource.APIKeyCreateOrUpdateParams | null;
|
307
|
+
}
|
308
|
+
|
309
|
+
export namespace NotionDataSource {
|
310
|
+
/**
|
311
|
+
* Base class for API key create or update parameters.
|
312
|
+
*/
|
313
|
+
export interface APIKeyCreateOrUpdateParams {
|
314
|
+
type?: 'api_key';
|
315
|
+
|
316
|
+
/**
|
317
|
+
* The API key
|
318
|
+
*/
|
319
|
+
api_key: string;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
export interface LinearDataSource {
|
324
|
+
/**
|
325
|
+
* The type of data source to create
|
326
|
+
*/
|
327
|
+
type?: DataSourceType;
|
328
|
+
|
329
|
+
/**
|
330
|
+
* The name of the data source
|
331
|
+
*/
|
332
|
+
name: string;
|
333
|
+
|
334
|
+
/**
|
335
|
+
* The metadata of the data source
|
336
|
+
*/
|
337
|
+
metadata?: unknown;
|
338
|
+
|
339
|
+
/**
|
340
|
+
* Base class for OAuth2 create or update parameters.
|
341
|
+
*/
|
342
|
+
auth_params?: Oauth2Params | null;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
export type DataSourceUpdateParams =
|
347
|
+
| DataSourceUpdateParams.NotionDataSource
|
348
|
+
| DataSourceUpdateParams.LinearDataSource;
|
349
|
+
|
350
|
+
export declare namespace DataSourceUpdateParams {
|
351
|
+
export interface NotionDataSource {
|
352
|
+
/**
|
353
|
+
* The type of data source to create
|
354
|
+
*/
|
355
|
+
type?: DataSourceType;
|
356
|
+
|
357
|
+
/**
|
358
|
+
* The name of the data source
|
359
|
+
*/
|
360
|
+
name: string;
|
361
|
+
|
362
|
+
/**
|
363
|
+
* The metadata of the data source
|
364
|
+
*/
|
365
|
+
metadata?: unknown;
|
366
|
+
|
367
|
+
/**
|
368
|
+
* The authentication parameters of the data source. Notion supports OAuth2 and API
|
369
|
+
* key.
|
370
|
+
*/
|
371
|
+
auth_params?: Oauth2Params | NotionDataSource.APIKeyCreateOrUpdateParams | null;
|
372
|
+
}
|
373
|
+
|
374
|
+
export namespace NotionDataSource {
|
375
|
+
/**
|
376
|
+
* Base class for API key create or update parameters.
|
377
|
+
*/
|
378
|
+
export interface APIKeyCreateOrUpdateParams {
|
379
|
+
type?: 'api_key';
|
380
|
+
|
381
|
+
/**
|
382
|
+
* The API key
|
383
|
+
*/
|
384
|
+
api_key: string;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
export interface LinearDataSource {
|
389
|
+
/**
|
390
|
+
* The type of data source to create
|
391
|
+
*/
|
392
|
+
type?: DataSourceType;
|
393
|
+
|
394
|
+
/**
|
395
|
+
* The name of the data source
|
396
|
+
*/
|
397
|
+
name: string;
|
398
|
+
|
399
|
+
/**
|
400
|
+
* The metadata of the data source
|
401
|
+
*/
|
402
|
+
metadata?: unknown;
|
403
|
+
|
404
|
+
/**
|
405
|
+
* Base class for OAuth2 create or update parameters.
|
406
|
+
*/
|
407
|
+
auth_params?: Oauth2Params | null;
|
408
|
+
}
|
242
409
|
}
|
243
410
|
|
244
411
|
export interface DataSourceListParams extends LimitOffsetParams {}
|
@@ -250,6 +417,9 @@ export declare namespace DataSources {
|
|
250
417
|
type DataSource as DataSource,
|
251
418
|
type DataSourceOauth2Params as DataSourceOauth2Params,
|
252
419
|
type DataSourceType as DataSourceType,
|
420
|
+
type LinearDataSource as LinearDataSource,
|
421
|
+
type NotionDataSource as NotionDataSource,
|
422
|
+
type Oauth2Params as Oauth2Params,
|
253
423
|
type DataSourceDeleteResponse as DataSourceDeleteResponse,
|
254
424
|
type DataSourcesLimitOffset as DataSourcesLimitOffset,
|
255
425
|
type DataSourceCreateParams as DataSourceCreateParams,
|
package/src/resources/index.ts
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
2
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
4
|
+
import * as FilesAPI from './files';
|
4
5
|
import * as Shared from '../shared';
|
5
6
|
import * as VectorStoresAPI from './vector-stores';
|
6
7
|
import { APIPromise } from '../../core/api-promise';
|
7
8
|
import { LimitOffset, type LimitOffsetParams, PagePromise } from '../../core/pagination';
|
8
9
|
import { RequestOptions } from '../../internal/request-options';
|
9
|
-
import { path } from '../../internal/utils/path';
|
10
10
|
import * as polling from '../../lib/polling';
|
11
11
|
import { Uploadable } from '../../uploads';
|
12
|
+
import { path } from '../../internal/utils/path';
|
12
13
|
|
13
14
|
export class Files extends APIResource {
|
14
15
|
/**
|
15
16
|
* Upload a new file to a vector store for indexing.
|
16
17
|
*
|
17
|
-
* Args:
|
18
|
-
* upload and index
|
18
|
+
* Args: vector_store_identifier: The ID or name of the vector store to upload to
|
19
|
+
* file: The file to upload and index
|
19
20
|
*
|
20
21
|
* Returns: VectorStoreFile: Details of the uploaded and indexed file
|
21
22
|
*/
|
22
23
|
create(
|
23
|
-
|
24
|
+
vectorStoreIdentifier: string,
|
24
25
|
body: FileCreateParams,
|
25
26
|
options?: RequestOptions,
|
26
27
|
): APIPromise<VectorStoreFile> {
|
27
|
-
return this._client.post(path`/v1/vector_stores/${
|
28
|
+
return this._client.post(path`/v1/vector_stores/${vectorStoreIdentifier}/files`, { body, ...options });
|
28
29
|
}
|
29
30
|
|
30
31
|
/**
|
31
32
|
* Get details of a specific file in a vector store.
|
32
33
|
*
|
33
|
-
* Args:
|
34
|
+
* Args: vector_store_identifier: The ID or name of the vector store file_id: The
|
35
|
+
* ID of the file
|
34
36
|
*
|
35
37
|
* Returns: VectorStoreFile: Details of the vector store file
|
36
38
|
*/
|
@@ -39,25 +41,25 @@ export class Files extends APIResource {
|
|
39
41
|
params: FileRetrieveParams,
|
40
42
|
options?: RequestOptions,
|
41
43
|
): APIPromise<VectorStoreFile> {
|
42
|
-
const {
|
43
|
-
return this._client.get(path`/v1/vector_stores/${
|
44
|
+
const { vector_store_identifier } = params;
|
45
|
+
return this._client.get(path`/v1/vector_stores/${vector_store_identifier}/files/${fileID}`, options);
|
44
46
|
}
|
45
47
|
|
46
48
|
/**
|
47
49
|
* List files indexed in a vector store with pagination.
|
48
50
|
*
|
49
|
-
* Args:
|
50
|
-
* parameters
|
51
|
+
* Args: vector_store_identifier: The ID or name of the vector store pagination:
|
52
|
+
* Pagination parameters
|
51
53
|
*
|
52
54
|
* Returns: VectorStoreFileListResponse: Paginated list of vector store files
|
53
55
|
*/
|
54
56
|
list(
|
55
|
-
|
57
|
+
vectorStoreIdentifier: string,
|
56
58
|
query: FileListParams | null | undefined = {},
|
57
59
|
options?: RequestOptions,
|
58
60
|
): PagePromise<VectorStoreFilesLimitOffset, VectorStoreFile> {
|
59
61
|
return this._client.getAPIList(
|
60
|
-
path`/v1/vector_stores/${
|
62
|
+
path`/v1/vector_stores/${vectorStoreIdentifier}/files`,
|
61
63
|
LimitOffset<VectorStoreFile>,
|
62
64
|
{ query, ...options },
|
63
65
|
);
|
@@ -66,14 +68,14 @@ export class Files extends APIResource {
|
|
66
68
|
/**
|
67
69
|
* Delete a file from a vector store.
|
68
70
|
*
|
69
|
-
* Args:
|
70
|
-
* delete
|
71
|
+
* Args: vector_store_identifier: The ID or name of the vector store file_id: The
|
72
|
+
* ID of the file to delete
|
71
73
|
*
|
72
74
|
* Returns: VectorStoreFileDeleted: The deleted file
|
73
75
|
*/
|
74
76
|
delete(fileID: string, params: FileDeleteParams, options?: RequestOptions): APIPromise<FileDeleteResponse> {
|
75
|
-
const {
|
76
|
-
return this._client.delete(path`/v1/vector_stores/${
|
77
|
+
const { vector_store_identifier } = params;
|
78
|
+
return this._client.delete(path`/v1/vector_stores/${vector_store_identifier}/files/${fileID}`, options);
|
77
79
|
}
|
78
80
|
|
79
81
|
/**
|
@@ -101,7 +103,7 @@ export class Files extends APIResource {
|
|
101
103
|
/**
|
102
104
|
* Poll for a file's processing status until it reaches a terminal state.
|
103
105
|
*
|
104
|
-
* @param
|
106
|
+
* @param vectorStoreIdentifier - The identifier of the vector store
|
105
107
|
* @param fileId - The ID of the file to poll
|
106
108
|
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
107
109
|
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
@@ -109,7 +111,7 @@ export class Files extends APIResource {
|
|
109
111
|
* @returns The file object once it reaches a terminal state
|
110
112
|
*/
|
111
113
|
async poll(
|
112
|
-
|
114
|
+
vectorStoreIdentifier: string,
|
113
115
|
fileId: string,
|
114
116
|
pollIntervalMs?: number,
|
115
117
|
pollTimeoutMs?: number,
|
@@ -119,9 +121,9 @@ export class Files extends APIResource {
|
|
119
121
|
const pollingTimeoutMs = pollTimeoutMs;
|
120
122
|
|
121
123
|
return polling.poll({
|
122
|
-
fn: () => this.retrieve(fileId, {
|
124
|
+
fn: () => this.retrieve(fileId, { vector_store_identifier: vectorStoreIdentifier, ...options }),
|
123
125
|
condition: (result) =>
|
124
|
-
result.status === 'completed' || result.status === 'failed' || result.status === '
|
126
|
+
result.status === 'completed' || result.status === 'failed' || result.status === 'cancelled',
|
125
127
|
intervalSeconds: pollingIntervalMs / 1000,
|
126
128
|
...(pollingTimeoutMs && { timeoutSeconds: pollingTimeoutMs / 1000 }),
|
127
129
|
});
|
@@ -130,7 +132,7 @@ export class Files extends APIResource {
|
|
130
132
|
/**
|
131
133
|
* Create a file in a vector store and wait for it to be processed.
|
132
134
|
*
|
133
|
-
* @param
|
135
|
+
* @param vectorStoreIdentifier - The identifier of the vector store to upload to
|
134
136
|
* @param body - The file creation parameters
|
135
137
|
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
136
138
|
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
@@ -138,28 +140,28 @@ export class Files extends APIResource {
|
|
138
140
|
* @returns The file object once it reaches a terminal state
|
139
141
|
*/
|
140
142
|
async createAndPoll(
|
141
|
-
|
143
|
+
vectorStoreIdentifier: string,
|
142
144
|
body: FileCreateParams,
|
143
145
|
pollIntervalMs?: number,
|
144
146
|
pollTimeoutMs?: number,
|
145
147
|
options?: RequestOptions,
|
146
148
|
): Promise<VectorStoreFile> {
|
147
|
-
const file = await this.create(
|
148
|
-
return this.poll(
|
149
|
+
const file = await this.create(vectorStoreIdentifier, body, options);
|
150
|
+
return this.poll(vectorStoreIdentifier, file.id, pollIntervalMs, pollTimeoutMs, options);
|
149
151
|
}
|
150
152
|
|
151
153
|
/**
|
152
154
|
* Upload a file to the files API and then create a file in a vector store.
|
153
155
|
* Note the file will be asynchronously processed.
|
154
156
|
*
|
155
|
-
* @param
|
157
|
+
* @param vectorStoreIdentifier - The identifier of the vector store to add the file to
|
156
158
|
* @param file - The file to upload
|
157
159
|
* @param body - Additional parameters for the vector store file
|
158
160
|
* @param options - Additional request options
|
159
161
|
* @returns The created vector store file
|
160
162
|
*/
|
161
163
|
async upload(
|
162
|
-
|
164
|
+
vectorStoreIdentifier: string,
|
163
165
|
file: Uploadable,
|
164
166
|
body?: Omit<FileCreateParams, 'file_id'>,
|
165
167
|
options?: RequestOptions,
|
@@ -167,7 +169,7 @@ export class Files extends APIResource {
|
|
167
169
|
const fileUploadResponse = await this._client.files.create({ file }, options);
|
168
170
|
|
169
171
|
return this.create(
|
170
|
-
|
172
|
+
vectorStoreIdentifier,
|
171
173
|
{
|
172
174
|
file_id: fileUploadResponse.id,
|
173
175
|
...body,
|
@@ -179,7 +181,7 @@ export class Files extends APIResource {
|
|
179
181
|
/**
|
180
182
|
* Upload a file to files API, create a file in a vector store, and poll until processing is complete.
|
181
183
|
*
|
182
|
-
* @param
|
184
|
+
* @param vectorStoreIdentifier - The identifier of the vector store to add the file to
|
183
185
|
* @param file - The file to upload
|
184
186
|
* @param body - Additional parameters for the vector store file
|
185
187
|
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
@@ -188,20 +190,41 @@ export class Files extends APIResource {
|
|
188
190
|
* @returns The vector store file object once it reaches a terminal state
|
189
191
|
*/
|
190
192
|
async uploadAndPoll(
|
191
|
-
|
193
|
+
vectorStoreIdentifier: string,
|
192
194
|
file: Uploadable,
|
193
195
|
body?: Omit<FileCreateParams, 'file_id'>,
|
194
196
|
pollIntervalMs?: number,
|
195
197
|
pollTimeoutMs?: number,
|
196
198
|
options?: RequestOptions,
|
197
199
|
): Promise<VectorStoreFile> {
|
198
|
-
const vectorStoreFile = await this.upload(
|
199
|
-
return this.poll(
|
200
|
+
const vectorStoreFile = await this.upload(vectorStoreIdentifier, file, body, options);
|
201
|
+
return this.poll(vectorStoreIdentifier, vectorStoreFile.id, pollIntervalMs, pollTimeoutMs, options);
|
200
202
|
}
|
201
203
|
}
|
202
204
|
|
203
205
|
export type VectorStoreFilesLimitOffset = LimitOffset<VectorStoreFile>;
|
204
206
|
|
207
|
+
/**
|
208
|
+
* Represents a reranking configuration.
|
209
|
+
*/
|
210
|
+
export interface RerankConfig {
|
211
|
+
/**
|
212
|
+
* The name of the reranking model
|
213
|
+
*/
|
214
|
+
model?: string;
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Whether to include metadata in the reranked results
|
218
|
+
*/
|
219
|
+
with_metadata?: boolean | Array<string>;
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Maximum number of results to return after reranking. If None, returns all
|
223
|
+
* reranked results.
|
224
|
+
*/
|
225
|
+
top_k?: number | null;
|
226
|
+
}
|
227
|
+
|
205
228
|
/**
|
206
229
|
* Represents a scored file stored in a vector store.
|
207
230
|
*/
|
@@ -224,7 +247,7 @@ export interface ScoredVectorStoreFile {
|
|
224
247
|
/**
|
225
248
|
* Processing status of the file
|
226
249
|
*/
|
227
|
-
status?:
|
250
|
+
status?: VectorStoreFileStatus;
|
228
251
|
|
229
252
|
/**
|
230
253
|
* Last error message if processing failed
|
@@ -272,6 +295,8 @@ export interface ScoredVectorStoreFile {
|
|
272
295
|
> | null;
|
273
296
|
}
|
274
297
|
|
298
|
+
export type VectorStoreFileStatus = 'pending' | 'in_progress' | 'cancelled' | 'completed' | 'failed';
|
299
|
+
|
275
300
|
/**
|
276
301
|
* Represents a file stored in a vector store.
|
277
302
|
*/
|
@@ -294,7 +319,7 @@ export interface VectorStoreFile {
|
|
294
319
|
/**
|
295
320
|
* Processing status of the file
|
296
321
|
*/
|
297
|
-
status?:
|
322
|
+
status?: VectorStoreFileStatus;
|
298
323
|
|
299
324
|
/**
|
300
325
|
* Last error message if processing failed
|
@@ -395,18 +420,18 @@ export namespace FileCreateParams {
|
|
395
420
|
|
396
421
|
export interface FileRetrieveParams {
|
397
422
|
/**
|
398
|
-
* The ID of the vector store
|
423
|
+
* The ID or name of the vector store
|
399
424
|
*/
|
400
|
-
|
425
|
+
vector_store_identifier: string;
|
401
426
|
}
|
402
427
|
|
403
428
|
export interface FileListParams extends LimitOffsetParams {}
|
404
429
|
|
405
430
|
export interface FileDeleteParams {
|
406
431
|
/**
|
407
|
-
* The ID of the vector store
|
432
|
+
* The ID or name of the vector store
|
408
433
|
*/
|
409
|
-
|
434
|
+
vector_store_identifier: string;
|
410
435
|
}
|
411
436
|
|
412
437
|
export interface FileSearchParams {
|
@@ -416,9 +441,14 @@ export interface FileSearchParams {
|
|
416
441
|
query: string;
|
417
442
|
|
418
443
|
/**
|
419
|
-
* IDs of vector stores to search
|
444
|
+
* IDs or names of vector stores to search
|
445
|
+
*/
|
446
|
+
vector_store_identifiers?: Array<string> | null;
|
447
|
+
|
448
|
+
/**
|
449
|
+
* @deprecated
|
420
450
|
*/
|
421
|
-
vector_store_ids
|
451
|
+
vector_store_ids?: Array<string> | null;
|
422
452
|
|
423
453
|
/**
|
424
454
|
* Number of results to return
|
@@ -434,6 +464,11 @@ export interface FileSearchParams {
|
|
434
464
|
| Array<Shared.SearchFilter | Shared.SearchFilterCondition>
|
435
465
|
| null;
|
436
466
|
|
467
|
+
/**
|
468
|
+
* Optional list of file IDs to filter chunks by (inclusion filter)
|
469
|
+
*/
|
470
|
+
file_ids?: Array<unknown> | Array<string> | null;
|
471
|
+
|
437
472
|
/**
|
438
473
|
* Search configuration options
|
439
474
|
*/
|
@@ -455,6 +490,11 @@ export namespace FileSearchParams {
|
|
455
490
|
*/
|
456
491
|
rewrite_query?: boolean;
|
457
492
|
|
493
|
+
/**
|
494
|
+
* Whether to rerank results and optional reranking configuration
|
495
|
+
*/
|
496
|
+
rerank?: boolean | FilesAPI.RerankConfig | null;
|
497
|
+
|
458
498
|
/**
|
459
499
|
* Whether to return file metadata
|
460
500
|
*/
|
@@ -474,7 +514,9 @@ export namespace FileSearchParams {
|
|
474
514
|
|
475
515
|
export declare namespace Files {
|
476
516
|
export {
|
517
|
+
type RerankConfig as RerankConfig,
|
477
518
|
type ScoredVectorStoreFile as ScoredVectorStoreFile,
|
519
|
+
type VectorStoreFileStatus as VectorStoreFileStatus,
|
478
520
|
type VectorStoreFile as VectorStoreFile,
|
479
521
|
type FileDeleteResponse as FileDeleteResponse,
|
480
522
|
type FileSearchResponse as FileSearchResponse,
|