@mixedbread/sdk 0.30.0 → 0.31.1
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 +16 -0
- package/README.md +18 -18
- package/bin/migration-config.json +70 -0
- package/client.d.mts +3 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +3 -0
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/stores/files.d.mts +593 -0
- package/resources/stores/files.d.mts.map +1 -0
- package/resources/stores/files.d.ts +593 -0
- package/resources/stores/files.d.ts.map +1 -0
- package/resources/stores/files.js +136 -0
- package/resources/stores/files.js.map +1 -0
- package/resources/stores/files.mjs +131 -0
- package/resources/stores/files.mjs.map +1 -0
- package/resources/stores/index.d.mts +3 -0
- package/resources/stores/index.d.mts.map +1 -0
- package/resources/stores/index.d.ts +3 -0
- package/resources/stores/index.d.ts.map +1 -0
- package/resources/stores/index.js +9 -0
- package/resources/stores/index.js.map +1 -0
- package/resources/stores/index.mjs +4 -0
- package/resources/stores/index.mjs.map +1 -0
- package/resources/stores/stores.d.mts +372 -0
- package/resources/stores/stores.d.mts.map +1 -0
- package/resources/stores/stores.d.ts +372 -0
- package/resources/stores/stores.d.ts.map +1 -0
- package/resources/stores/stores.js +100 -0
- package/resources/stores/stores.js.map +1 -0
- package/resources/stores/stores.mjs +95 -0
- package/resources/stores/stores.mjs.map +1 -0
- package/resources/stores.d.mts +2 -0
- package/resources/stores.d.mts.map +1 -0
- package/resources/stores.d.ts +2 -0
- package/resources/stores.d.ts.map +1 -0
- package/resources/stores.js +6 -0
- package/resources/stores.js.map +1 -0
- package/resources/stores.mjs +3 -0
- package/resources/stores.mjs.map +1 -0
- package/resources/vector-stores/files.d.mts +11 -10
- package/resources/vector-stores/files.d.mts.map +1 -1
- package/resources/vector-stores/files.d.ts +11 -10
- package/resources/vector-stores/files.d.ts.map +1 -1
- package/resources/vector-stores/files.js +5 -5
- package/resources/vector-stores/files.js.map +1 -1
- package/resources/vector-stores/files.mjs +5 -5
- package/resources/vector-stores/files.mjs.map +1 -1
- package/resources/vector-stores/vector-stores.d.mts +7 -7
- package/resources/vector-stores/vector-stores.d.ts +7 -7
- package/resources/vector-stores/vector-stores.js +7 -7
- package/resources/vector-stores/vector-stores.mjs +7 -7
- package/src/client.ts +31 -0
- package/src/resources/index.ts +14 -0
- package/src/resources/stores/files.ts +796 -0
- package/src/resources/stores/index.ts +30 -0
- package/src/resources/stores/stores.ts +523 -0
- package/src/resources/stores.ts +3 -0
- package/src/resources/vector-stores/files.ts +11 -10
- package/src/resources/vector-stores/vector-stores.ts +7 -7
- 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
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Files = void 0;
|
|
5
|
+
const tslib_1 = require("../../internal/tslib.js");
|
|
6
|
+
const resource_1 = require("../../core/resource.js");
|
|
7
|
+
const polling = tslib_1.__importStar(require("../../lib/polling.js"));
|
|
8
|
+
const path_1 = require("../../internal/utils/path.js");
|
|
9
|
+
class Files extends resource_1.APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Upload a file to a store.
|
|
12
|
+
*
|
|
13
|
+
* Args: store_identifier: The ID or name of the store. file_add_params: The file
|
|
14
|
+
* to add to the store.
|
|
15
|
+
*
|
|
16
|
+
* Returns: VectorStoreFile: The uploaded file details.
|
|
17
|
+
*/
|
|
18
|
+
create(storeIdentifier, body, options) {
|
|
19
|
+
return this._client.post((0, path_1.path) `/v1/stores/${storeIdentifier}/files`, { body, ...options });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a file from a store.
|
|
23
|
+
*
|
|
24
|
+
* Args: store_identifier: The ID or name of the store. file_id: The ID or name of
|
|
25
|
+
* the file. options: Get file options.
|
|
26
|
+
*
|
|
27
|
+
* Returns: VectorStoreFile: The file details.
|
|
28
|
+
*/
|
|
29
|
+
retrieve(fileID, params, options) {
|
|
30
|
+
const { store_identifier, ...query } = params;
|
|
31
|
+
return this._client.get((0, path_1.path) `/v1/stores/${store_identifier}/files/${fileID}`, { query, ...options });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List files indexed in a vector store with pagination and metadata filter.
|
|
35
|
+
*
|
|
36
|
+
* Args: vector_store_identifier: The ID or name of the vector store pagination:
|
|
37
|
+
* Pagination parameters and metadata filter
|
|
38
|
+
*
|
|
39
|
+
* Returns: VectorStoreFileListResponse: Paginated list of vector store files
|
|
40
|
+
*/
|
|
41
|
+
list(storeIdentifier, body, options) {
|
|
42
|
+
return this._client.post((0, path_1.path) `/v1/stores/${storeIdentifier}/files/list`, { body, ...options });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Delete a file from a store.
|
|
46
|
+
*
|
|
47
|
+
* Args: store_identifier: The ID or name of the store. file_id: The ID or name of
|
|
48
|
+
* the file to delete.
|
|
49
|
+
*
|
|
50
|
+
* Returns: VectorStoreFileDeleted: The deleted file details.
|
|
51
|
+
*/
|
|
52
|
+
delete(fileID, params, options) {
|
|
53
|
+
const { store_identifier } = params;
|
|
54
|
+
return this._client.delete((0, path_1.path) `/v1/stores/${store_identifier}/files/${fileID}`, options);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Search for files within a store based on semantic similarity.
|
|
58
|
+
*
|
|
59
|
+
* Args: store_identifier: The ID or name of the store to search within
|
|
60
|
+
* search_params: Search configuration including query text, pagination, and
|
|
61
|
+
* filters
|
|
62
|
+
*
|
|
63
|
+
* Returns: StoreFileSearchResponse: List of matching files with relevance scores
|
|
64
|
+
*/
|
|
65
|
+
search(body, options) {
|
|
66
|
+
return this._client.post('/v1/stores/files/search', { body, ...options });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Poll for a file's processing status until it reaches a terminal state.
|
|
70
|
+
*
|
|
71
|
+
* @param storeIdentifier - The identifier of the store
|
|
72
|
+
* @param fileId - The ID of the file to poll
|
|
73
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
|
74
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
|
75
|
+
* @param options - Additional request options
|
|
76
|
+
* @returns The file object once it reaches a terminal state
|
|
77
|
+
*/
|
|
78
|
+
async poll(storeIdentifier, fileId, pollIntervalMs, pollTimeoutMs, options) {
|
|
79
|
+
const pollingIntervalMs = pollIntervalMs || 500;
|
|
80
|
+
const pollingTimeoutMs = pollTimeoutMs;
|
|
81
|
+
return polling.poll({
|
|
82
|
+
fn: () => this.retrieve(fileId, { store_identifier: storeIdentifier, ...options }),
|
|
83
|
+
condition: (result) => result.status === 'completed' || result.status === 'failed' || result.status === 'cancelled',
|
|
84
|
+
intervalSeconds: pollingIntervalMs / 1000,
|
|
85
|
+
...(pollingTimeoutMs && { timeoutSeconds: pollingTimeoutMs / 1000 }),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a file in a vector store and wait for it to be processed.
|
|
90
|
+
*
|
|
91
|
+
* @param storeIdentifier - The identifier of the store to upload to
|
|
92
|
+
* @param body - The file creation parameters
|
|
93
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
|
94
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
|
95
|
+
* @param options - Additional request options
|
|
96
|
+
* @returns The file object once it reaches a terminal state
|
|
97
|
+
*/
|
|
98
|
+
async createAndPoll(storeIdentifier, body, pollIntervalMs, pollTimeoutMs, options) {
|
|
99
|
+
const file = await this.create(storeIdentifier, body, options);
|
|
100
|
+
return this.poll(storeIdentifier, file.id, pollIntervalMs, pollTimeoutMs, options);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Upload a file to the files API and then create a file in a vector store.
|
|
104
|
+
* Note the file will be asynchronously processed.
|
|
105
|
+
*
|
|
106
|
+
* @param storeIdentifier - The identifier of the store to add the file to
|
|
107
|
+
* @param file - The file to upload
|
|
108
|
+
* @param body - Additional parameters for the vector store file
|
|
109
|
+
* @param options - Additional request options
|
|
110
|
+
* @returns The created vector store file
|
|
111
|
+
*/
|
|
112
|
+
async upload(storeIdentifier, file, body, options) {
|
|
113
|
+
const fileUploadResponse = await this._client.files.create({ file }, options);
|
|
114
|
+
return this.create(storeIdentifier, {
|
|
115
|
+
file_id: fileUploadResponse.id,
|
|
116
|
+
...body,
|
|
117
|
+
}, options);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Upload a file to files API, create a file in a vector store, and poll until processing is complete.
|
|
121
|
+
*
|
|
122
|
+
* @param storeIdentifier - The identifier of the store to add the file to
|
|
123
|
+
* @param file - The file to upload
|
|
124
|
+
* @param body - Additional parameters for the vector store file
|
|
125
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
|
126
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
|
127
|
+
* @param options - Additional request options
|
|
128
|
+
* @returns The vector store file object once it reaches a terminal state
|
|
129
|
+
*/
|
|
130
|
+
async uploadAndPoll(storeIdentifier, file, body, pollIntervalMs, pollTimeoutMs, options) {
|
|
131
|
+
const vectorStoreFile = await this.upload(storeIdentifier, file, body, options);
|
|
132
|
+
return this.poll(storeIdentifier, vectorStoreFile.id, pollIntervalMs, pollTimeoutMs, options);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.Files = Files;
|
|
136
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/resources/stores/files.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAMlD,sEAA6C;AAE7C,uDAAiD;AAEjD,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,eAAuB,EAAE,IAAsB,EAAE,OAAwB;QAC9E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,cAAc,eAAe,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAc,EAAE,MAA0B,EAAE,OAAwB;QAC3E,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,cAAc,gBAAgB,UAAU,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACvG,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CACF,eAAuB,EACvB,IAAoB,EACpB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,cAAc,eAAe,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjG,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAc,EAAE,MAAwB,EAAE,OAAwB;QACvE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,cAAc,gBAAgB,UAAU,MAAM,EAAE,EAA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ACH,KAAK,CAAC,MAAM,CACV,eAAuB,EACvB,IAAgB,EAChB,IAAwC,EACxC,OAAwB;QAExB,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC,MAAM,CAChB,eAAe,EACf;YACE,OAAO,EAAE,kBAAkB,CAAC,EAAE;YAC9B,GAAG,IAAI;SACR,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,aAAa,CACjB,eAAuB,EACvB,IAAgB,EAChB,IAAwC,EACxC,cAAuB,EACvB,aAAsB,EACtB,OAAwB;QAExB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAChG,CAAC;CACF;AAzKD,sBAyKC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../../core/resource.mjs";
|
|
3
|
+
import * as polling from "../../lib/polling.mjs";
|
|
4
|
+
import { path } from "../../internal/utils/path.mjs";
|
|
5
|
+
export class Files extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Upload a file to a store.
|
|
8
|
+
*
|
|
9
|
+
* Args: store_identifier: The ID or name of the store. file_add_params: The file
|
|
10
|
+
* to add to the store.
|
|
11
|
+
*
|
|
12
|
+
* Returns: VectorStoreFile: The uploaded file details.
|
|
13
|
+
*/
|
|
14
|
+
create(storeIdentifier, body, options) {
|
|
15
|
+
return this._client.post(path `/v1/stores/${storeIdentifier}/files`, { body, ...options });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get a file from a store.
|
|
19
|
+
*
|
|
20
|
+
* Args: store_identifier: The ID or name of the store. file_id: The ID or name of
|
|
21
|
+
* the file. options: Get file options.
|
|
22
|
+
*
|
|
23
|
+
* Returns: VectorStoreFile: The file details.
|
|
24
|
+
*/
|
|
25
|
+
retrieve(fileID, params, options) {
|
|
26
|
+
const { store_identifier, ...query } = params;
|
|
27
|
+
return this._client.get(path `/v1/stores/${store_identifier}/files/${fileID}`, { query, ...options });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* List files indexed in a vector store with pagination and metadata filter.
|
|
31
|
+
*
|
|
32
|
+
* Args: vector_store_identifier: The ID or name of the vector store pagination:
|
|
33
|
+
* Pagination parameters and metadata filter
|
|
34
|
+
*
|
|
35
|
+
* Returns: VectorStoreFileListResponse: Paginated list of vector store files
|
|
36
|
+
*/
|
|
37
|
+
list(storeIdentifier, body, options) {
|
|
38
|
+
return this._client.post(path `/v1/stores/${storeIdentifier}/files/list`, { body, ...options });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Delete a file from a store.
|
|
42
|
+
*
|
|
43
|
+
* Args: store_identifier: The ID or name of the store. file_id: The ID or name of
|
|
44
|
+
* the file to delete.
|
|
45
|
+
*
|
|
46
|
+
* Returns: VectorStoreFileDeleted: The deleted file details.
|
|
47
|
+
*/
|
|
48
|
+
delete(fileID, params, options) {
|
|
49
|
+
const { store_identifier } = params;
|
|
50
|
+
return this._client.delete(path `/v1/stores/${store_identifier}/files/${fileID}`, options);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Search for files within a store based on semantic similarity.
|
|
54
|
+
*
|
|
55
|
+
* Args: store_identifier: The ID or name of the store to search within
|
|
56
|
+
* search_params: Search configuration including query text, pagination, and
|
|
57
|
+
* filters
|
|
58
|
+
*
|
|
59
|
+
* Returns: StoreFileSearchResponse: List of matching files with relevance scores
|
|
60
|
+
*/
|
|
61
|
+
search(body, options) {
|
|
62
|
+
return this._client.post('/v1/stores/files/search', { body, ...options });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Poll for a file's processing status until it reaches a terminal state.
|
|
66
|
+
*
|
|
67
|
+
* @param storeIdentifier - The identifier of the store
|
|
68
|
+
* @param fileId - The ID of the file to poll
|
|
69
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
|
70
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
|
71
|
+
* @param options - Additional request options
|
|
72
|
+
* @returns The file object once it reaches a terminal state
|
|
73
|
+
*/
|
|
74
|
+
async poll(storeIdentifier, fileId, pollIntervalMs, pollTimeoutMs, options) {
|
|
75
|
+
const pollingIntervalMs = pollIntervalMs || 500;
|
|
76
|
+
const pollingTimeoutMs = pollTimeoutMs;
|
|
77
|
+
return polling.poll({
|
|
78
|
+
fn: () => this.retrieve(fileId, { store_identifier: storeIdentifier, ...options }),
|
|
79
|
+
condition: (result) => result.status === 'completed' || result.status === 'failed' || result.status === 'cancelled',
|
|
80
|
+
intervalSeconds: pollingIntervalMs / 1000,
|
|
81
|
+
...(pollingTimeoutMs && { timeoutSeconds: pollingTimeoutMs / 1000 }),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a file in a vector store and wait for it to be processed.
|
|
86
|
+
*
|
|
87
|
+
* @param storeIdentifier - The identifier of the store to upload to
|
|
88
|
+
* @param body - The file creation parameters
|
|
89
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
|
90
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
|
91
|
+
* @param options - Additional request options
|
|
92
|
+
* @returns The file object once it reaches a terminal state
|
|
93
|
+
*/
|
|
94
|
+
async createAndPoll(storeIdentifier, body, pollIntervalMs, pollTimeoutMs, options) {
|
|
95
|
+
const file = await this.create(storeIdentifier, body, options);
|
|
96
|
+
return this.poll(storeIdentifier, file.id, pollIntervalMs, pollTimeoutMs, options);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Upload a file to the files API and then create a file in a vector store.
|
|
100
|
+
* Note the file will be asynchronously processed.
|
|
101
|
+
*
|
|
102
|
+
* @param storeIdentifier - The identifier of the store to add the file to
|
|
103
|
+
* @param file - The file to upload
|
|
104
|
+
* @param body - Additional parameters for the vector store file
|
|
105
|
+
* @param options - Additional request options
|
|
106
|
+
* @returns The created vector store file
|
|
107
|
+
*/
|
|
108
|
+
async upload(storeIdentifier, file, body, options) {
|
|
109
|
+
const fileUploadResponse = await this._client.files.create({ file }, options);
|
|
110
|
+
return this.create(storeIdentifier, {
|
|
111
|
+
file_id: fileUploadResponse.id,
|
|
112
|
+
...body,
|
|
113
|
+
}, options);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Upload a file to files API, create a file in a vector store, and poll until processing is complete.
|
|
117
|
+
*
|
|
118
|
+
* @param storeIdentifier - The identifier of the store to add the file to
|
|
119
|
+
* @param file - The file to upload
|
|
120
|
+
* @param body - Additional parameters for the vector store file
|
|
121
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
|
122
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
|
123
|
+
* @param options - Additional request options
|
|
124
|
+
* @returns The vector store file object once it reaches a terminal state
|
|
125
|
+
*/
|
|
126
|
+
async uploadAndPoll(storeIdentifier, file, body, pollIntervalMs, pollTimeoutMs, options) {
|
|
127
|
+
const vectorStoreFile = await this.upload(storeIdentifier, file, body, options);
|
|
128
|
+
return this.poll(storeIdentifier, vectorStoreFile.id, pollIntervalMs, pollTimeoutMs, options);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=files.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.mjs","sourceRoot":"","sources":["../../src/resources/stores/files.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE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C,CAAC;QAE9E,OAAO,IAAI,CAAC,MAAM,CAChB,eAAe,EACf;YACE,OAAO,EAAE,kBAAkB,CAAC,EAAE;YAC9B,GAAG,IAAI;SACR,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,aAAa,CACjB,eAAuB,EACvB,IAAgB,EAChB,IAAwC,EACxC,cAAuB,EACvB,aAAsB,EACtB,OAAwB;QAExB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAChG,CAAC;CACF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Files, type ScoredStoreFile, type StoreFileStatus, type StoreFile, type FileListResponse, type FileDeleteResponse, type FileSearchResponse, type FileCreateParams, type FileRetrieveParams, type FileListParams, type FileDeleteParams, type FileSearchParams, } from "./files.mjs";
|
|
2
|
+
export { Stores, type Store, type StoreChunkSearchOptions, type StoreDeleteResponse, type StoreQuestionAnsweringResponse, type StoreSearchResponse, type StoreCreateParams, type StoreUpdateParams, type StoreListParams, type StoreQuestionAnsweringParams, type StoreSearchParams, type StoresCursor, } from "./stores.mjs";
|
|
3
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/resources/stores/index.ts"],"names":[],"mappings":"OAEO,EACL,KAAK,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB;OACM,EACL,MAAM,EACN,KAAK,KAAK,EACV,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Files, type ScoredStoreFile, type StoreFileStatus, type StoreFile, type FileListResponse, type FileDeleteResponse, type FileSearchResponse, type FileCreateParams, type FileRetrieveParams, type FileListParams, type FileDeleteParams, type FileSearchParams, } from "./files.js";
|
|
2
|
+
export { Stores, type Store, type StoreChunkSearchOptions, type StoreDeleteResponse, type StoreQuestionAnsweringResponse, type StoreSearchResponse, type StoreCreateParams, type StoreUpdateParams, type StoreListParams, type StoreQuestionAnsweringParams, type StoreSearchParams, type StoresCursor, } from "./stores.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/stores/index.ts"],"names":[],"mappings":"OAEO,EACL,KAAK,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB;OACM,EACL,MAAM,EACN,KAAK,KAAK,EACV,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Stores = exports.Files = void 0;
|
|
5
|
+
var files_1 = require("./files.js");
|
|
6
|
+
Object.defineProperty(exports, "Files", { enumerable: true, get: function () { return files_1.Files; } });
|
|
7
|
+
var stores_1 = require("./stores.js");
|
|
8
|
+
Object.defineProperty(exports, "Stores", { enumerable: true, get: function () { return stores_1.Stores; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/stores/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,oCAaiB;AAZf,8FAAA,KAAK,OAAA;AAaP,sCAakB;AAZhB,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/stores/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EACL,KAAK,GAYN;OACM,EACL,MAAM,GAYP"}
|