@mixedbread/sdk 0.1.0-alpha.10
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 +230 -0
- package/LICENSE +201 -0
- package/README.md +360 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +241 -0
- package/core.d.ts.map +1 -0
- package/core.js +915 -0
- package/core.js.map +1 -0
- package/core.mjs +883 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +47 -0
- package/error.d.ts.map +1 -0
- package/error.js +113 -0
- package/error.js.map +1 -0
- package/error.mjs +97 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +169 -0
- package/index.d.ts +169 -0
- package/index.d.ts.map +1 -0
- package/index.js +175 -0
- package/index.js.map +1 -0
- package/index.mjs +132 -0
- package/index.mjs.map +1 -0
- package/lib/polling.d.ts +48 -0
- package/lib/polling.d.ts.map +1 -0
- package/lib/polling.js +75 -0
- package/lib/polling.js.map +1 -0
- package/lib/polling.mjs +71 -0
- package/lib/polling.mjs.map +1 -0
- package/package.json +124 -0
- package/pagination.d.ts +30 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +45 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +41 -0
- package/pagination.mjs.map +1 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/embeddings.d.ts +177 -0
- package/resources/embeddings.d.ts.map +1 -0
- package/resources/embeddings.js +20 -0
- package/resources/embeddings.js.map +1 -0
- package/resources/embeddings.mjs +16 -0
- package/resources/embeddings.mjs.map +1 -0
- package/resources/extractions/content.d.ts +33 -0
- package/resources/extractions/content.d.ts.map +1 -0
- package/resources/extractions/content.js +19 -0
- package/resources/extractions/content.js.map +1 -0
- package/resources/extractions/content.mjs +15 -0
- package/resources/extractions/content.mjs.map +1 -0
- package/resources/extractions/extractions.d.ts +18 -0
- package/resources/extractions/extractions.d.ts.map +1 -0
- package/resources/extractions/extractions.js +47 -0
- package/resources/extractions/extractions.js.map +1 -0
- package/resources/extractions/extractions.mjs +20 -0
- package/resources/extractions/extractions.mjs.map +1 -0
- package/resources/extractions/index.d.ts +5 -0
- package/resources/extractions/index.d.ts.map +1 -0
- package/resources/extractions/index.js +13 -0
- package/resources/extractions/index.js.map +1 -0
- package/resources/extractions/index.mjs +6 -0
- package/resources/extractions/index.mjs.map +1 -0
- package/resources/extractions/jobs.d.ts +84 -0
- package/resources/extractions/jobs.d.ts.map +1 -0
- package/resources/extractions/jobs.js +29 -0
- package/resources/extractions/jobs.js.map +1 -0
- package/resources/extractions/jobs.mjs +25 -0
- package/resources/extractions/jobs.mjs.map +1 -0
- package/resources/extractions/schema.d.ts +85 -0
- package/resources/extractions/schema.d.ts.map +1 -0
- package/resources/extractions/schema.js +39 -0
- package/resources/extractions/schema.js.map +1 -0
- package/resources/extractions/schema.mjs +35 -0
- package/resources/extractions/schema.mjs.map +1 -0
- package/resources/files.d.ts +125 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +99 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +71 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.ts +8 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +32 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +8 -0
- package/resources/index.mjs.map +1 -0
- package/resources/parsing/index.d.ts +3 -0
- package/resources/parsing/index.d.ts.map +1 -0
- package/resources/parsing/index.js +10 -0
- package/resources/parsing/index.js.map +1 -0
- package/resources/parsing/index.mjs +4 -0
- package/resources/parsing/index.mjs.map +1 -0
- package/resources/parsing/jobs.d.ts +290 -0
- package/resources/parsing/jobs.d.ts.map +1 -0
- package/resources/parsing/jobs.js +147 -0
- package/resources/parsing/jobs.js.map +1 -0
- package/resources/parsing/jobs.mjs +119 -0
- package/resources/parsing/jobs.mjs.map +1 -0
- package/resources/parsing/parsing.d.ts +10 -0
- package/resources/parsing/parsing.d.ts.map +1 -0
- package/resources/parsing/parsing.js +40 -0
- package/resources/parsing/parsing.js.map +1 -0
- package/resources/parsing/parsing.mjs +13 -0
- package/resources/parsing/parsing.mjs.map +1 -0
- package/resources/shared.d.ts +35 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/resources/top-level.d.ts +165 -0
- package/resources/top-level.d.ts.map +1 -0
- package/resources/top-level.js +4 -0
- package/resources/top-level.js.map +1 -0
- package/resources/top-level.mjs +3 -0
- package/resources/top-level.mjs.map +1 -0
- package/resources/vector-stores/files.d.ts +284 -0
- package/resources/vector-stores/files.d.ts.map +1 -0
- package/resources/vector-stores/files.js +167 -0
- package/resources/vector-stores/files.js.map +1 -0
- package/resources/vector-stores/files.mjs +139 -0
- package/resources/vector-stores/files.mjs.map +1 -0
- package/resources/vector-stores/index.d.ts +3 -0
- package/resources/vector-stores/index.d.ts.map +1 -0
- package/resources/vector-stores/index.js +11 -0
- package/resources/vector-stores/index.js.map +1 -0
- package/resources/vector-stores/index.mjs +4 -0
- package/resources/vector-stores/index.mjs.map +1 -0
- package/resources/vector-stores/vector-stores.d.ts +425 -0
- package/resources/vector-stores/vector-stores.d.ts.map +1 -0
- package/resources/vector-stores/vector-stores.js +121 -0
- package/resources/vector-stores/vector-stores.js.map +1 -0
- package/resources/vector-stores/vector-stores.mjs +93 -0
- package/resources/vector-stores/vector-stores.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1208 -0
- package/src/error.ts +130 -0
- package/src/index.ts +346 -0
- package/src/lib/.keep +4 -0
- package/src/lib/polling.ts +115 -0
- package/src/pagination.ts +82 -0
- package/src/resource.ts +11 -0
- package/src/resources/embeddings.ts +248 -0
- package/src/resources/extractions/content.ts +42 -0
- package/src/resources/extractions/extractions.ts +47 -0
- package/src/resources/extractions/index.ts +14 -0
- package/src/resources/extractions/jobs.ts +105 -0
- package/src/resources/extractions/schema.ts +111 -0
- package/src/resources/files.ts +181 -0
- package/src/resources/index.ts +39 -0
- package/src/resources/parsing/index.ts +12 -0
- package/src/resources/parsing/jobs.ts +453 -0
- package/src/resources/parsing/parsing.ts +32 -0
- package/src/resources/shared.ts +41 -0
- package/src/resources/top-level.ts +231 -0
- package/src/resources/vector-stores/files.ts +439 -0
- package/src/resources/vector-stores/index.ts +31 -0
- package/src/resources/vector-stores/vector-stores.ts +592 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +255 -0
- package/src/version.ts +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +171 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +158 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
@@ -0,0 +1,181 @@
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
import { APIResource } from '../resource';
|
4
|
+
import { isRequestOptions } from '../core';
|
5
|
+
import * as Core from '../core';
|
6
|
+
import { LimitOffset, type LimitOffsetParams } from '../pagination';
|
7
|
+
import { type Response } from '../_shims/index';
|
8
|
+
|
9
|
+
export class Files extends APIResource {
|
10
|
+
/**
|
11
|
+
* Upload a new file.
|
12
|
+
*
|
13
|
+
* Args: file: The file to upload.
|
14
|
+
*
|
15
|
+
* Returns: FileResponse: The response containing the details of the uploaded file.
|
16
|
+
*/
|
17
|
+
create(body: FileCreateParams, options?: Core.RequestOptions): Core.APIPromise<FileObject> {
|
18
|
+
return this._client.post('/v1/files', Core.multipartFormRequestOptions({ body, ...options }));
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Retrieve details of a specific file by its ID.
|
23
|
+
*
|
24
|
+
* Args: file_id: The ID of the file to retrieve.
|
25
|
+
*
|
26
|
+
* Returns: FileResponse: The response containing the file details.
|
27
|
+
*/
|
28
|
+
retrieve(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileObject> {
|
29
|
+
return this._client.get(`/v1/files/${fileId}`, options);
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Update the details of a specific file.
|
34
|
+
*
|
35
|
+
* Args: file_id: The ID of the file to update. file: The new details for the file.
|
36
|
+
*
|
37
|
+
* Returns: FileObject: The updated file details.
|
38
|
+
*/
|
39
|
+
update(fileId: string, body: FileUpdateParams, options?: Core.RequestOptions): Core.APIPromise<FileObject> {
|
40
|
+
return this._client.post(`/v1/files/${fileId}`, Core.multipartFormRequestOptions({ body, ...options }));
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* List all files for the authenticated user.
|
45
|
+
*
|
46
|
+
* Args: pagination: The pagination options
|
47
|
+
*
|
48
|
+
* Returns: A list of files belonging to the user.
|
49
|
+
*/
|
50
|
+
list(
|
51
|
+
query?: FileListParams,
|
52
|
+
options?: Core.RequestOptions,
|
53
|
+
): Core.PagePromise<FileObjectsLimitOffset, FileObject>;
|
54
|
+
list(options?: Core.RequestOptions): Core.PagePromise<FileObjectsLimitOffset, FileObject>;
|
55
|
+
list(
|
56
|
+
query: FileListParams | Core.RequestOptions = {},
|
57
|
+
options?: Core.RequestOptions,
|
58
|
+
): Core.PagePromise<FileObjectsLimitOffset, FileObject> {
|
59
|
+
if (isRequestOptions(query)) {
|
60
|
+
return this.list({}, query);
|
61
|
+
}
|
62
|
+
return this._client.getAPIList('/v1/files', FileObjectsLimitOffset, { query, ...options });
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Delete a specific file by its ID.
|
67
|
+
*
|
68
|
+
* Args: file_id: The ID of the file to delete.
|
69
|
+
*
|
70
|
+
* Returns: FileDeleted: The response containing the details of the deleted file.
|
71
|
+
*/
|
72
|
+
delete(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileDeleteResponse> {
|
73
|
+
return this._client.delete(`/v1/files/${fileId}`, options);
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Download a specific file by its ID.
|
78
|
+
*
|
79
|
+
* Args: file_id: The ID of the file to download.
|
80
|
+
*
|
81
|
+
* Returns: FileStreamResponse: The response containing the file to be downloaded.
|
82
|
+
*/
|
83
|
+
content(fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
|
84
|
+
return this._client.get(`/v1/files/${fileId}/content`, {
|
85
|
+
...options,
|
86
|
+
headers: { Accept: 'application/octet-stream', ...options?.headers },
|
87
|
+
__binaryResponse: true,
|
88
|
+
});
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
export class FileObjectsLimitOffset extends LimitOffset<FileObject> {}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* A model representing a file object in the system.
|
96
|
+
*
|
97
|
+
* This model contains metadata about files stored in the system, including
|
98
|
+
* identifiers, size information, and timestamps.
|
99
|
+
*/
|
100
|
+
export interface FileObject {
|
101
|
+
/**
|
102
|
+
* Unique identifier for the file
|
103
|
+
*/
|
104
|
+
id: string;
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Name of the file including extension
|
108
|
+
*/
|
109
|
+
filename: string;
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Size of the file in bytes
|
113
|
+
*/
|
114
|
+
bytes: number;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* MIME type of the file
|
118
|
+
*/
|
119
|
+
mime_type: string;
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Version of the file
|
123
|
+
*/
|
124
|
+
version: number;
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Timestamp when the file was created
|
128
|
+
*/
|
129
|
+
created_at: string;
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Timestamp when the file was last updated
|
133
|
+
*/
|
134
|
+
updated_at: string;
|
135
|
+
}
|
136
|
+
|
137
|
+
export interface FileDeleteResponse {
|
138
|
+
/**
|
139
|
+
* The ID of the deleted file
|
140
|
+
*/
|
141
|
+
id: string;
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Whether the file was deleted
|
145
|
+
*/
|
146
|
+
deleted?: boolean;
|
147
|
+
|
148
|
+
/**
|
149
|
+
* The type of the deleted object
|
150
|
+
*/
|
151
|
+
object?: 'file';
|
152
|
+
}
|
153
|
+
|
154
|
+
export interface FileCreateParams {
|
155
|
+
/**
|
156
|
+
* The file to upload
|
157
|
+
*/
|
158
|
+
file: Core.Uploadable;
|
159
|
+
}
|
160
|
+
|
161
|
+
export interface FileUpdateParams {
|
162
|
+
/**
|
163
|
+
* The file to update
|
164
|
+
*/
|
165
|
+
file: Core.Uploadable;
|
166
|
+
}
|
167
|
+
|
168
|
+
export interface FileListParams extends LimitOffsetParams {}
|
169
|
+
|
170
|
+
Files.FileObjectsLimitOffset = FileObjectsLimitOffset;
|
171
|
+
|
172
|
+
export declare namespace Files {
|
173
|
+
export {
|
174
|
+
type FileObject as FileObject,
|
175
|
+
type FileDeleteResponse as FileDeleteResponse,
|
176
|
+
FileObjectsLimitOffset as FileObjectsLimitOffset,
|
177
|
+
type FileCreateParams as FileCreateParams,
|
178
|
+
type FileUpdateParams as FileUpdateParams,
|
179
|
+
type FileListParams as FileListParams,
|
180
|
+
};
|
181
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
export * from './shared';
|
4
|
+
export {
|
5
|
+
Embeddings,
|
6
|
+
type Embedding,
|
7
|
+
type EmbeddingCreateResponse,
|
8
|
+
type EmbeddingCreateParams,
|
9
|
+
} from './embeddings';
|
10
|
+
export { Extractions } from './extractions/extractions';
|
11
|
+
export {
|
12
|
+
FileObjectsLimitOffset,
|
13
|
+
Files,
|
14
|
+
type FileObject,
|
15
|
+
type FileDeleteResponse,
|
16
|
+
type FileCreateParams,
|
17
|
+
type FileUpdateParams,
|
18
|
+
type FileListParams,
|
19
|
+
} from './files';
|
20
|
+
export { Parsing } from './parsing/parsing';
|
21
|
+
export {
|
22
|
+
VectorStoresLimitOffset,
|
23
|
+
VectorStores,
|
24
|
+
type ExpiresAfter,
|
25
|
+
type FileCounts,
|
26
|
+
type ScoredVectorStoreChunk,
|
27
|
+
type VectorStore,
|
28
|
+
type VectorStoreChunkSearchOptions,
|
29
|
+
type VectorStoreFileSearchOptions,
|
30
|
+
type VectorStoreDeleteResponse,
|
31
|
+
type VectorStoreQuestionAnsweringResponse,
|
32
|
+
type VectorStoreSearchResponse,
|
33
|
+
type VectorStoreCreateParams,
|
34
|
+
type VectorStoreUpdateParams,
|
35
|
+
type VectorStoreListParams,
|
36
|
+
type VectorStoreQuestionAnsweringParams,
|
37
|
+
type VectorStoreSearchParams,
|
38
|
+
} from './vector-stores/vector-stores';
|
39
|
+
export { type InfoResponse, type RerankResponse, type EmbedParams, type RerankParams } from './top-level';
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
export {
|
4
|
+
JobListResponsesLimitOffset,
|
5
|
+
Jobs,
|
6
|
+
type ParsingJob,
|
7
|
+
type JobListResponse,
|
8
|
+
type JobDeleteResponse,
|
9
|
+
type JobCreateParams,
|
10
|
+
type JobListParams,
|
11
|
+
} from './jobs';
|
12
|
+
export { Parsing } from './parsing';
|
@@ -0,0 +1,453 @@
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
import { APIResource } from '../../resource';
|
4
|
+
import { isRequestOptions } from '../../core';
|
5
|
+
import * as Core from '../../core';
|
6
|
+
import { LimitOffset, type LimitOffsetParams } from '../../pagination';
|
7
|
+
import * as polling from '../../lib/polling';
|
8
|
+
import { Uploadable } from '../../uploads';
|
9
|
+
|
10
|
+
export class Jobs extends APIResource {
|
11
|
+
/**
|
12
|
+
* Start a parse job for the provided file.
|
13
|
+
*
|
14
|
+
* Args: params: The parameters for creating a parse job.
|
15
|
+
*
|
16
|
+
* Returns: The created parsing job.
|
17
|
+
*/
|
18
|
+
create(body: JobCreateParams, options?: Core.RequestOptions): Core.APIPromise<ParsingJob> {
|
19
|
+
return this._client.post('/v1/parsing/jobs', { body, ...options });
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Get detailed information about a specific parse job.
|
24
|
+
*
|
25
|
+
* Args: job_id: The ID of the parse job.
|
26
|
+
*
|
27
|
+
* Returns: Detailed information about the parse job.
|
28
|
+
*/
|
29
|
+
retrieve(jobId: string, options?: Core.RequestOptions): Core.APIPromise<ParsingJob> {
|
30
|
+
return this._client.get(`/v1/parsing/jobs/${jobId}`, options);
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* List parsing jobs with pagination.
|
35
|
+
*
|
36
|
+
* Args: limit: The number of items to return. offset: The number of items to skip.
|
37
|
+
*
|
38
|
+
* Returns: List of parsing jobs with pagination.
|
39
|
+
*/
|
40
|
+
list(
|
41
|
+
query?: JobListParams,
|
42
|
+
options?: Core.RequestOptions,
|
43
|
+
): Core.PagePromise<JobListResponsesLimitOffset, JobListResponse>;
|
44
|
+
list(options?: Core.RequestOptions): Core.PagePromise<JobListResponsesLimitOffset, JobListResponse>;
|
45
|
+
list(
|
46
|
+
query: JobListParams | Core.RequestOptions = {},
|
47
|
+
options?: Core.RequestOptions,
|
48
|
+
): Core.PagePromise<JobListResponsesLimitOffset, JobListResponse> {
|
49
|
+
if (isRequestOptions(query)) {
|
50
|
+
return this.list({}, query);
|
51
|
+
}
|
52
|
+
return this._client.getAPIList('/v1/parsing/jobs', JobListResponsesLimitOffset, { query, ...options });
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Delete a specific parse job.
|
57
|
+
*
|
58
|
+
* Args: job_id: The ID of the parse job to delete.
|
59
|
+
*
|
60
|
+
* Returns: The deleted parsing job.
|
61
|
+
*/
|
62
|
+
delete(jobId: string, options?: Core.RequestOptions): Core.APIPromise<JobDeleteResponse> {
|
63
|
+
return this._client.delete(`/v1/parsing/jobs/${jobId}`, options);
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Cancel a specific parse job.
|
68
|
+
*
|
69
|
+
* Args: job_id: The ID of the parse job to cancel.
|
70
|
+
*
|
71
|
+
* Returns: The cancelled parsing job.
|
72
|
+
*/
|
73
|
+
cancel(jobId: string, options?: Core.RequestOptions): Core.APIPromise<ParsingJob> {
|
74
|
+
return this._client.patch(`/v1/parsing/jobs/${jobId}`, options);
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Poll for a job's status until it reaches a terminal state.
|
79
|
+
*
|
80
|
+
* @param jobId - The ID of the job to poll
|
81
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
82
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
83
|
+
* @param options - Additional request options
|
84
|
+
* @returns The job object once it reaches a terminal state
|
85
|
+
*/
|
86
|
+
async poll(
|
87
|
+
jobId: string,
|
88
|
+
pollIntervalMs?: number,
|
89
|
+
pollTimeoutMs?: number,
|
90
|
+
options?: Core.RequestOptions,
|
91
|
+
): Promise<ParsingJob> {
|
92
|
+
const pollingIntervalMs = pollIntervalMs || 500;
|
93
|
+
const pollingTimeoutMs = pollTimeoutMs;
|
94
|
+
|
95
|
+
return polling.poll({
|
96
|
+
fn: () => this.retrieve(jobId, options),
|
97
|
+
condition: (result) =>
|
98
|
+
result.status === 'completed' || result.status === 'failed' || result.status === 'cancelled',
|
99
|
+
intervalSeconds: pollingIntervalMs / 1000,
|
100
|
+
...(pollingTimeoutMs && { timeoutSeconds: pollingTimeoutMs / 1000 }),
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Create a parsing job and wait for it to complete.
|
106
|
+
*
|
107
|
+
* @param body - Parameters for creating a parse job
|
108
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
109
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
110
|
+
* @param options - Additional request options
|
111
|
+
* @returns The job object once it reaches a terminal state
|
112
|
+
*/
|
113
|
+
async createAndPoll(
|
114
|
+
body: JobCreateParams,
|
115
|
+
pollIntervalMs?: number,
|
116
|
+
pollTimeoutMs?: number,
|
117
|
+
options?: Core.RequestOptions,
|
118
|
+
): Promise<ParsingJob> {
|
119
|
+
const job = await this.create(body, options);
|
120
|
+
return this.poll(job.id, pollIntervalMs, pollTimeoutMs, options);
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Upload a file to the files API and then create a parsing job for it.
|
125
|
+
* Note the job will be asynchronously processed.
|
126
|
+
*
|
127
|
+
* @param file - The file to upload
|
128
|
+
* @param body - Additional parameters for creating a parse job
|
129
|
+
* @param options - Additional request options
|
130
|
+
* @returns The created parsing job
|
131
|
+
*/
|
132
|
+
async upload(
|
133
|
+
file: Uploadable,
|
134
|
+
body?: Omit<JobCreateParams, 'file_id'>,
|
135
|
+
options?: Core.RequestOptions,
|
136
|
+
): Promise<ParsingJob> {
|
137
|
+
const fileUploadResponse = await this._client.files.create({ file }, options);
|
138
|
+
|
139
|
+
return this.create(
|
140
|
+
{
|
141
|
+
file_id: fileUploadResponse.id,
|
142
|
+
...body,
|
143
|
+
},
|
144
|
+
options,
|
145
|
+
);
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Upload a file and create a parsing job, then poll until processing is complete.
|
150
|
+
*
|
151
|
+
* @param file - The file to upload
|
152
|
+
* @param body - Additional parameters for creating a parse job
|
153
|
+
* @param pollIntervalMs - The interval between polls in milliseconds (default: 500)
|
154
|
+
* @param pollTimeoutMs - The maximum time to poll for in milliseconds (default: no timeout)
|
155
|
+
* @param options - Additional request options
|
156
|
+
* @returns The job object once it reaches a terminal state
|
157
|
+
*/
|
158
|
+
async uploadAndPoll(
|
159
|
+
file: Uploadable,
|
160
|
+
body?: Omit<JobCreateParams, 'file_id'>,
|
161
|
+
pollIntervalMs?: number,
|
162
|
+
pollTimeoutMs?: number,
|
163
|
+
options?: Core.RequestOptions,
|
164
|
+
): Promise<ParsingJob> {
|
165
|
+
const job = await this.upload(file, body, options);
|
166
|
+
return this.poll(job.id, pollIntervalMs, pollTimeoutMs, options);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
export class JobListResponsesLimitOffset extends LimitOffset<JobListResponse> {}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* A job for parsing documents with its current state and result.
|
174
|
+
*/
|
175
|
+
export interface ParsingJob {
|
176
|
+
/**
|
177
|
+
* The ID of the job
|
178
|
+
*/
|
179
|
+
id: string;
|
180
|
+
|
181
|
+
/**
|
182
|
+
* The ID of the file to parse
|
183
|
+
*/
|
184
|
+
file_id: string;
|
185
|
+
|
186
|
+
/**
|
187
|
+
* The status of the job
|
188
|
+
*/
|
189
|
+
status: 'pending' | 'in_progress' | 'cancelled' | 'completed' | 'failed';
|
190
|
+
|
191
|
+
/**
|
192
|
+
* The error of the job
|
193
|
+
*/
|
194
|
+
error?: unknown;
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Result of document parsing operation.
|
198
|
+
*/
|
199
|
+
result?: ParsingJob.Result | null;
|
200
|
+
|
201
|
+
/**
|
202
|
+
* The started time of the job
|
203
|
+
*/
|
204
|
+
started_at?: string | null;
|
205
|
+
|
206
|
+
/**
|
207
|
+
* The finished time of the job
|
208
|
+
*/
|
209
|
+
finished_at?: string | null;
|
210
|
+
|
211
|
+
/**
|
212
|
+
* The creation time of the job
|
213
|
+
*/
|
214
|
+
created_at?: string;
|
215
|
+
|
216
|
+
/**
|
217
|
+
* The updated time of the job
|
218
|
+
*/
|
219
|
+
updated_at?: string | null;
|
220
|
+
|
221
|
+
/**
|
222
|
+
* The type of the object
|
223
|
+
*/
|
224
|
+
object?: 'parsing_job';
|
225
|
+
}
|
226
|
+
|
227
|
+
export namespace ParsingJob {
|
228
|
+
/**
|
229
|
+
* Result of document parsing operation.
|
230
|
+
*/
|
231
|
+
export interface Result {
|
232
|
+
/**
|
233
|
+
* The strategy used for chunking the document
|
234
|
+
*/
|
235
|
+
chunking_strategy: 'page';
|
236
|
+
|
237
|
+
/**
|
238
|
+
* The format of the returned content
|
239
|
+
*/
|
240
|
+
return_format: 'html' | 'markdown' | 'plain';
|
241
|
+
|
242
|
+
/**
|
243
|
+
* The types of elements extracted
|
244
|
+
*/
|
245
|
+
element_types: Array<
|
246
|
+
| 'caption'
|
247
|
+
| 'footnote'
|
248
|
+
| 'formula'
|
249
|
+
| 'list-item'
|
250
|
+
| 'page-footer'
|
251
|
+
| 'page-header'
|
252
|
+
| 'picture'
|
253
|
+
| 'section-header'
|
254
|
+
| 'table'
|
255
|
+
| 'text'
|
256
|
+
| 'title'
|
257
|
+
>;
|
258
|
+
|
259
|
+
/**
|
260
|
+
* List of extracted chunks from the document
|
261
|
+
*/
|
262
|
+
chunks: Array<Result.Chunk>;
|
263
|
+
|
264
|
+
/**
|
265
|
+
* List of (width, height) tuples for each page
|
266
|
+
*/
|
267
|
+
page_sizes?: Array<Array<unknown>>;
|
268
|
+
}
|
269
|
+
|
270
|
+
export namespace Result {
|
271
|
+
/**
|
272
|
+
* A chunk of text extracted from a document page.
|
273
|
+
*/
|
274
|
+
export interface Chunk {
|
275
|
+
/**
|
276
|
+
* The full content of the chunk
|
277
|
+
*/
|
278
|
+
content: string;
|
279
|
+
|
280
|
+
/**
|
281
|
+
* The content to be used for embedding
|
282
|
+
*/
|
283
|
+
content_to_embed: string;
|
284
|
+
|
285
|
+
/**
|
286
|
+
* List of elements contained in this chunk
|
287
|
+
*/
|
288
|
+
elements: Array<Chunk.Element>;
|
289
|
+
}
|
290
|
+
|
291
|
+
export namespace Chunk {
|
292
|
+
/**
|
293
|
+
* Represents an extracted element from a document with its content and metadata.
|
294
|
+
*/
|
295
|
+
export interface Element {
|
296
|
+
/**
|
297
|
+
* The type of the extracted element
|
298
|
+
*/
|
299
|
+
type:
|
300
|
+
| 'caption'
|
301
|
+
| 'footnote'
|
302
|
+
| 'formula'
|
303
|
+
| 'list-item'
|
304
|
+
| 'page-footer'
|
305
|
+
| 'page-header'
|
306
|
+
| 'picture'
|
307
|
+
| 'section-header'
|
308
|
+
| 'table'
|
309
|
+
| 'text'
|
310
|
+
| 'title';
|
311
|
+
|
312
|
+
/**
|
313
|
+
* The confidence score of the extraction
|
314
|
+
*/
|
315
|
+
confidence: number;
|
316
|
+
|
317
|
+
/**
|
318
|
+
* The bounding box coordinates [x1, y1, x2, y2]
|
319
|
+
*/
|
320
|
+
bbox: Array<unknown>;
|
321
|
+
|
322
|
+
/**
|
323
|
+
* The page number where the element was found
|
324
|
+
*/
|
325
|
+
page: number;
|
326
|
+
|
327
|
+
/**
|
328
|
+
* The full content of the extracted element
|
329
|
+
*/
|
330
|
+
content: string;
|
331
|
+
|
332
|
+
/**
|
333
|
+
* A brief summary of the element's content
|
334
|
+
*/
|
335
|
+
summary?: string | null;
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
341
|
+
/**
|
342
|
+
* A parsing job item for list responses, omitting result and error fields.
|
343
|
+
*/
|
344
|
+
export interface JobListResponse {
|
345
|
+
/**
|
346
|
+
* The ID of the job
|
347
|
+
*/
|
348
|
+
id: string;
|
349
|
+
|
350
|
+
/**
|
351
|
+
* The ID of the file to parse
|
352
|
+
*/
|
353
|
+
file_id: string;
|
354
|
+
|
355
|
+
/**
|
356
|
+
* The status of the job
|
357
|
+
*/
|
358
|
+
status: 'pending' | 'in_progress' | 'cancelled' | 'completed' | 'failed';
|
359
|
+
|
360
|
+
/**
|
361
|
+
* The started time of the job
|
362
|
+
*/
|
363
|
+
started_at?: string | null;
|
364
|
+
|
365
|
+
/**
|
366
|
+
* The finished time of the job
|
367
|
+
*/
|
368
|
+
finished_at?: string | null;
|
369
|
+
|
370
|
+
/**
|
371
|
+
* The creation time of the job
|
372
|
+
*/
|
373
|
+
created_at?: string;
|
374
|
+
|
375
|
+
/**
|
376
|
+
* The updated time of the job
|
377
|
+
*/
|
378
|
+
updated_at?: string | null;
|
379
|
+
|
380
|
+
/**
|
381
|
+
* The type of the object
|
382
|
+
*/
|
383
|
+
object?: 'parsing_job';
|
384
|
+
}
|
385
|
+
|
386
|
+
/**
|
387
|
+
* A deleted parsing job.
|
388
|
+
*/
|
389
|
+
export interface JobDeleteResponse {
|
390
|
+
/**
|
391
|
+
* The ID of the deleted job
|
392
|
+
*/
|
393
|
+
id: string;
|
394
|
+
|
395
|
+
/**
|
396
|
+
* Whether the job was deleted
|
397
|
+
*/
|
398
|
+
deleted?: boolean;
|
399
|
+
|
400
|
+
/**
|
401
|
+
* The type of the object
|
402
|
+
*/
|
403
|
+
object?: 'parsing_job';
|
404
|
+
}
|
405
|
+
|
406
|
+
export interface JobCreateParams {
|
407
|
+
/**
|
408
|
+
* The ID of the file to parse
|
409
|
+
*/
|
410
|
+
file_id: string;
|
411
|
+
|
412
|
+
/**
|
413
|
+
* The elements to extract from the document
|
414
|
+
*/
|
415
|
+
element_types?: Array<
|
416
|
+
| 'caption'
|
417
|
+
| 'footnote'
|
418
|
+
| 'formula'
|
419
|
+
| 'list-item'
|
420
|
+
| 'page-footer'
|
421
|
+
| 'page-header'
|
422
|
+
| 'picture'
|
423
|
+
| 'section-header'
|
424
|
+
| 'table'
|
425
|
+
| 'text'
|
426
|
+
| 'title'
|
427
|
+
> | null;
|
428
|
+
|
429
|
+
/**
|
430
|
+
* The strategy to use for chunking the content
|
431
|
+
*/
|
432
|
+
chunking_strategy?: 'page';
|
433
|
+
|
434
|
+
/**
|
435
|
+
* The format of the returned content
|
436
|
+
*/
|
437
|
+
return_format?: 'html' | 'markdown' | 'plain';
|
438
|
+
}
|
439
|
+
|
440
|
+
export interface JobListParams extends LimitOffsetParams {}
|
441
|
+
|
442
|
+
Jobs.JobListResponsesLimitOffset = JobListResponsesLimitOffset;
|
443
|
+
|
444
|
+
export declare namespace Jobs {
|
445
|
+
export {
|
446
|
+
type ParsingJob as ParsingJob,
|
447
|
+
type JobListResponse as JobListResponse,
|
448
|
+
type JobDeleteResponse as JobDeleteResponse,
|
449
|
+
JobListResponsesLimitOffset as JobListResponsesLimitOffset,
|
450
|
+
type JobCreateParams as JobCreateParams,
|
451
|
+
type JobListParams as JobListParams,
|
452
|
+
};
|
453
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
import { APIResource } from '../../resource';
|
4
|
+
import * as JobsAPI from './jobs';
|
5
|
+
import {
|
6
|
+
JobCreateParams,
|
7
|
+
JobDeleteResponse,
|
8
|
+
JobListParams,
|
9
|
+
JobListResponse,
|
10
|
+
JobListResponsesLimitOffset,
|
11
|
+
Jobs,
|
12
|
+
ParsingJob,
|
13
|
+
} from './jobs';
|
14
|
+
|
15
|
+
export class Parsing extends APIResource {
|
16
|
+
jobs: JobsAPI.Jobs = new JobsAPI.Jobs(this._client);
|
17
|
+
}
|
18
|
+
|
19
|
+
Parsing.Jobs = Jobs;
|
20
|
+
Parsing.JobListResponsesLimitOffset = JobListResponsesLimitOffset;
|
21
|
+
|
22
|
+
export declare namespace Parsing {
|
23
|
+
export {
|
24
|
+
Jobs as Jobs,
|
25
|
+
type ParsingJob as ParsingJob,
|
26
|
+
type JobListResponse as JobListResponse,
|
27
|
+
type JobDeleteResponse as JobDeleteResponse,
|
28
|
+
JobListResponsesLimitOffset as JobListResponsesLimitOffset,
|
29
|
+
type JobCreateParams as JobCreateParams,
|
30
|
+
type JobListParams as JobListParams,
|
31
|
+
};
|
32
|
+
}
|