wriftai 0.16.0 → 0.17.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/dist/index.cjs +571 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +781 -0
- package/dist/index.mjs +568 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
2
|
+
[key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Represents input and output schemas.
|
|
6
|
+
*/
|
|
7
|
+
type SchemaIO = {
|
|
8
|
+
/**
|
|
9
|
+
* Schema for input, following JSON Schema Draft 2020-12 standards.
|
|
10
|
+
*/
|
|
11
|
+
input: Record<string, JsonValue>;
|
|
12
|
+
/**
|
|
13
|
+
* Schema for output, following JSON Schema Draft 2020-12 standards.
|
|
14
|
+
*/
|
|
15
|
+
output: Record<string, JsonValue>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Represents schemas of a version.
|
|
19
|
+
*/
|
|
20
|
+
type Schemas = {
|
|
21
|
+
/**
|
|
22
|
+
* The input and output schemas for a prediction.
|
|
23
|
+
*/
|
|
24
|
+
prediction: SchemaIO;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Represents a version.
|
|
28
|
+
*/
|
|
29
|
+
interface Version {
|
|
30
|
+
/**
|
|
31
|
+
* Unique identifier for the version.
|
|
32
|
+
*/
|
|
33
|
+
id: string;
|
|
34
|
+
/**
|
|
35
|
+
* Information about changes such as new features, bug fixes,
|
|
36
|
+
* or optimizations in this version.
|
|
37
|
+
*/
|
|
38
|
+
release_notes: string;
|
|
39
|
+
/**
|
|
40
|
+
* The time when the version was created.
|
|
41
|
+
*/
|
|
42
|
+
created_at: string;
|
|
43
|
+
/**
|
|
44
|
+
* The schemas of the model version.
|
|
45
|
+
*/
|
|
46
|
+
schemas: Schemas;
|
|
47
|
+
/**
|
|
48
|
+
* A sha256 hash digest of the version's container image.
|
|
49
|
+
*/
|
|
50
|
+
container_image_digest: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Represents a user.
|
|
54
|
+
*/
|
|
55
|
+
interface User {
|
|
56
|
+
/**
|
|
57
|
+
* Unique identifier of the user.
|
|
58
|
+
*/
|
|
59
|
+
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* The username of the user.
|
|
62
|
+
*/
|
|
63
|
+
username: string;
|
|
64
|
+
/**
|
|
65
|
+
* URL of the user's avatar.
|
|
66
|
+
*/
|
|
67
|
+
avatar_url: string;
|
|
68
|
+
/**
|
|
69
|
+
* The name of the user.
|
|
70
|
+
*/
|
|
71
|
+
name: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* The biography of the user.
|
|
74
|
+
*/
|
|
75
|
+
bio: string | null;
|
|
76
|
+
/**
|
|
77
|
+
* Personal or professional website URLs.
|
|
78
|
+
*/
|
|
79
|
+
urls: string[] | null;
|
|
80
|
+
/**
|
|
81
|
+
* Location of the user.
|
|
82
|
+
*/
|
|
83
|
+
location: string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Company the user is associated with.
|
|
86
|
+
*/
|
|
87
|
+
company: string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Timestamp when the user joined WriftAI.
|
|
90
|
+
*/
|
|
91
|
+
created_at: string;
|
|
92
|
+
/**
|
|
93
|
+
* Timestamp when the user was last updated.
|
|
94
|
+
*/
|
|
95
|
+
updated_at: string | null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Model visibility states.
|
|
99
|
+
*/
|
|
100
|
+
declare enum ModelVisibility {
|
|
101
|
+
private = "private",
|
|
102
|
+
public = "public"
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Represents a model.
|
|
106
|
+
*/
|
|
107
|
+
interface Model {
|
|
108
|
+
/**
|
|
109
|
+
* The unique identifier of the model.
|
|
110
|
+
*/
|
|
111
|
+
id: string;
|
|
112
|
+
/**
|
|
113
|
+
* The name of the model.
|
|
114
|
+
*/
|
|
115
|
+
name: string;
|
|
116
|
+
/**
|
|
117
|
+
* The time when the model was created.
|
|
118
|
+
*/
|
|
119
|
+
created_at: string;
|
|
120
|
+
/**
|
|
121
|
+
* The visibility of the model.
|
|
122
|
+
*/
|
|
123
|
+
visibility: ModelVisibility;
|
|
124
|
+
/**
|
|
125
|
+
* Description of the model.
|
|
126
|
+
*/
|
|
127
|
+
description: string | null;
|
|
128
|
+
/**
|
|
129
|
+
* The time when the model was updated.
|
|
130
|
+
*/
|
|
131
|
+
updated_at: string | null;
|
|
132
|
+
/**
|
|
133
|
+
* Source url from where the model's code can be referenced.
|
|
134
|
+
*/
|
|
135
|
+
source_url: string | null;
|
|
136
|
+
/**
|
|
137
|
+
* License url where the model's usage is specified.
|
|
138
|
+
*/
|
|
139
|
+
license_url: string | null;
|
|
140
|
+
/**
|
|
141
|
+
* Paper url from where research info on the model can be found.
|
|
142
|
+
*/
|
|
143
|
+
paper_url: string | null;
|
|
144
|
+
/**
|
|
145
|
+
* The details of the owner of the model.
|
|
146
|
+
*/
|
|
147
|
+
owner: User;
|
|
148
|
+
/**
|
|
149
|
+
* The details of the latest version of the model.
|
|
150
|
+
*/
|
|
151
|
+
latest_version: Version | null;
|
|
152
|
+
/**
|
|
153
|
+
* The name of the hardware used by the model.
|
|
154
|
+
*/
|
|
155
|
+
hardware_name: string;
|
|
156
|
+
/**
|
|
157
|
+
* The total number of predictions created across all versions of the model.
|
|
158
|
+
*/
|
|
159
|
+
predictions_count: number;
|
|
160
|
+
}
|
|
161
|
+
/** Pagination options interface */
|
|
162
|
+
type PaginationOptions = {
|
|
163
|
+
/** Cursor for pagination */
|
|
164
|
+
cursor?: string;
|
|
165
|
+
/** Number of items per page */
|
|
166
|
+
page_size?: number;
|
|
167
|
+
};
|
|
168
|
+
/** Paginated response interface */
|
|
169
|
+
interface PaginatedResponse<T> {
|
|
170
|
+
/** List of items returned in the current page */
|
|
171
|
+
items: T[];
|
|
172
|
+
/** Cursor pointing to the next page */
|
|
173
|
+
next_cursor: string | null;
|
|
174
|
+
/** Cursor pointing to the previous page */
|
|
175
|
+
previous_cursor: string | null;
|
|
176
|
+
/** URL to fetch the next page */
|
|
177
|
+
next_url: string | null;
|
|
178
|
+
/** URL to fetch the previous page */
|
|
179
|
+
previous_url: string | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Representation of an error from WriftAI's API.
|
|
184
|
+
*/
|
|
185
|
+
declare class WriftAIAPIError extends Error {
|
|
186
|
+
status: number;
|
|
187
|
+
body: string;
|
|
188
|
+
url: string;
|
|
189
|
+
/**
|
|
190
|
+
* Creates an instance of the error.
|
|
191
|
+
* @param status HTTP status code returned by the API
|
|
192
|
+
* @param body Raw response text body
|
|
193
|
+
* @param url Full URL of the request
|
|
194
|
+
*/
|
|
195
|
+
constructor(status: number, body: string, url: string);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Client for WriftAI's API.
|
|
199
|
+
*/
|
|
200
|
+
declare class APIClient {
|
|
201
|
+
private baseUrl;
|
|
202
|
+
private fetchImpl;
|
|
203
|
+
private defaultHeaders;
|
|
204
|
+
/**
|
|
205
|
+
* Create an instance of the API client.
|
|
206
|
+
* @param baseUrl Base URL for the API without trailing slashes.
|
|
207
|
+
* @param fetchImpl Fetch implementation to use.
|
|
208
|
+
* @param accessToken Optional bearer token used for authentication
|
|
209
|
+
* @param headers Optional additional headers (overrides defaults).
|
|
210
|
+
*/
|
|
211
|
+
constructor(baseUrl: string, fetchImpl: typeof fetch, accessToken?: string, headers?: Record<string, string>);
|
|
212
|
+
/**
|
|
213
|
+
* Makes an HTTP request to the API.
|
|
214
|
+
* @template T The expected JSON response shape
|
|
215
|
+
* @param path The path relative to `baseUrl` (e.g. `/users`)
|
|
216
|
+
* @param options Request options
|
|
217
|
+
* @param options.method The HTTP method to use
|
|
218
|
+
* @param options.params Optional query parameters
|
|
219
|
+
* @param options.body Optional JSON-serializable body
|
|
220
|
+
* @param options.headers Optional extra request headers
|
|
221
|
+
* @returns The parsed JSON response
|
|
222
|
+
* @throws {WriftAIAPIError} If the response is not ok (`!res.ok`)
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* const users = await client.request<User[]>("/users", { method: "GET" });
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
request<T>(path: string, options: {
|
|
229
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
230
|
+
params?: Record<string, string | number | boolean>;
|
|
231
|
+
body?: JsonValue;
|
|
232
|
+
headers?: Record<string, string>;
|
|
233
|
+
}): Promise<T>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Abstract base class for WriftAI API resources.
|
|
238
|
+
*/
|
|
239
|
+
declare abstract class Resource {
|
|
240
|
+
protected apiClient: APIClient;
|
|
241
|
+
protected readonly MODELS_API_PREFIX = "/models";
|
|
242
|
+
protected readonly VERSIONS_API_PREFIX = "/versions";
|
|
243
|
+
protected readonly SEARCH_API_PREFIX = "/search";
|
|
244
|
+
/**
|
|
245
|
+
* Create a new resource.
|
|
246
|
+
* @param apiClient API client instance used to
|
|
247
|
+
* communicate with WriftAI's API.
|
|
248
|
+
*/
|
|
249
|
+
constructor(apiClient: APIClient);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Enumeration of possible error sources.
|
|
254
|
+
*/
|
|
255
|
+
declare enum ErrorSource {
|
|
256
|
+
internal = "internal",
|
|
257
|
+
external = "external"
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Enumeration of possible prediction statuses.
|
|
261
|
+
*/
|
|
262
|
+
declare enum Status {
|
|
263
|
+
pending = "pending",
|
|
264
|
+
started = "started",
|
|
265
|
+
failed = "failed",
|
|
266
|
+
succeeded = "succeeded"
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Represents an error that occurred during a prediction.
|
|
270
|
+
*/
|
|
271
|
+
interface TaskError {
|
|
272
|
+
source: ErrorSource;
|
|
273
|
+
message: string;
|
|
274
|
+
detail: JsonValue;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Represents a prediction.
|
|
278
|
+
*/
|
|
279
|
+
interface Prediction {
|
|
280
|
+
/**
|
|
281
|
+
* URL to access the prediction resource.
|
|
282
|
+
*/
|
|
283
|
+
url: string;
|
|
284
|
+
/**
|
|
285
|
+
* Unique identifier for the prediction.
|
|
286
|
+
*/
|
|
287
|
+
id: string;
|
|
288
|
+
/**
|
|
289
|
+
* Identifier of the model version used.
|
|
290
|
+
*/
|
|
291
|
+
version_id: string;
|
|
292
|
+
/**
|
|
293
|
+
* Timestamp when the prediction was created.
|
|
294
|
+
*/
|
|
295
|
+
created_at: string;
|
|
296
|
+
/**
|
|
297
|
+
* Current status of the prediction.
|
|
298
|
+
*/
|
|
299
|
+
status: Status;
|
|
300
|
+
/**
|
|
301
|
+
* URL for webhook callbacks, if any.
|
|
302
|
+
*/
|
|
303
|
+
webhook_url: string | null;
|
|
304
|
+
/**
|
|
305
|
+
* Timestamp of the last update to the prediction.
|
|
306
|
+
*/
|
|
307
|
+
updated_at: string;
|
|
308
|
+
/**
|
|
309
|
+
* Time taken to set up the prediction environment.
|
|
310
|
+
*/
|
|
311
|
+
setup_time: string | null;
|
|
312
|
+
/**
|
|
313
|
+
* Time taken to execute the prediction.
|
|
314
|
+
*/
|
|
315
|
+
execution_time: string | null;
|
|
316
|
+
/**
|
|
317
|
+
* Identifier of the hardware used for prediction.
|
|
318
|
+
*/
|
|
319
|
+
hardware_id: string;
|
|
320
|
+
/**
|
|
321
|
+
* Error details if the prediction failed.
|
|
322
|
+
*/
|
|
323
|
+
error: TaskError | null;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Represents a prediction with I/O details.
|
|
327
|
+
*/
|
|
328
|
+
interface PredictionWithIO extends Prediction {
|
|
329
|
+
/**
|
|
330
|
+
* Input data provided for the prediction.
|
|
331
|
+
*/
|
|
332
|
+
input: JsonValue;
|
|
333
|
+
/**
|
|
334
|
+
* Output generated by the prediction.
|
|
335
|
+
*/
|
|
336
|
+
output: JsonValue;
|
|
337
|
+
/**
|
|
338
|
+
* Logs generated during prediction execution.
|
|
339
|
+
*/
|
|
340
|
+
logs: string[] | null;
|
|
341
|
+
/**
|
|
342
|
+
* Logs generated during setup.
|
|
343
|
+
*/
|
|
344
|
+
setup_logs: string[] | null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Prediction creation parameters.
|
|
348
|
+
*/
|
|
349
|
+
interface CreatePredictionParams {
|
|
350
|
+
/**
|
|
351
|
+
* Input data provided for the prediction.
|
|
352
|
+
*/
|
|
353
|
+
input: JsonValue;
|
|
354
|
+
/**
|
|
355
|
+
* An HTTP URL to POST prediction updates to.
|
|
356
|
+
*/
|
|
357
|
+
webhook_url?: string;
|
|
358
|
+
/**
|
|
359
|
+
* Enable input validation against the schema before processing.
|
|
360
|
+
*/
|
|
361
|
+
validate_input?: boolean;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Options for creating a prediction using the latest version of a model.
|
|
365
|
+
*/
|
|
366
|
+
type ModelOptions = {
|
|
367
|
+
/**
|
|
368
|
+
* Username of the model's owner
|
|
369
|
+
*/
|
|
370
|
+
model_owner: string;
|
|
371
|
+
/**
|
|
372
|
+
* Name of the model
|
|
373
|
+
*/
|
|
374
|
+
model_name: string;
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Options for creating a prediction using a specific version of a model.
|
|
378
|
+
*/
|
|
379
|
+
type VersionOptions = {
|
|
380
|
+
/**
|
|
381
|
+
* Unique identifier of the model's version.
|
|
382
|
+
*/
|
|
383
|
+
version_id: string;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Union type for prediction creation options.
|
|
387
|
+
* Accepts either model owner and name or a version_id,
|
|
388
|
+
* along with prediction creation parameters.
|
|
389
|
+
*/
|
|
390
|
+
type CreateOptions = (ModelOptions | VersionOptions) & CreatePredictionParams;
|
|
391
|
+
/**
|
|
392
|
+
* Resource class for interacting with predictions.
|
|
393
|
+
*/
|
|
394
|
+
declare class PredictionsResource extends Resource {
|
|
395
|
+
private readonly PREDICTIONS_API_PREFIX;
|
|
396
|
+
private readonly ERROR_MSG_INVALID_PREDICTION_PARAMS;
|
|
397
|
+
/**
|
|
398
|
+
* Get a prediction by its ID.
|
|
399
|
+
* @param id The ID of the prediction to fetch.
|
|
400
|
+
* @returns The prediction object.
|
|
401
|
+
*/
|
|
402
|
+
get(id: string): Promise<PredictionWithIO>;
|
|
403
|
+
/**
|
|
404
|
+
* Constructs the API path to create a prediction.
|
|
405
|
+
* @param options Options for prediction creation.
|
|
406
|
+
* @returns The API path.
|
|
407
|
+
* @throws {TypeError} When an invalid combination of version_id,
|
|
408
|
+
* model_owner and model_name is provided.
|
|
409
|
+
*/
|
|
410
|
+
private predictionPath;
|
|
411
|
+
/**
|
|
412
|
+
* Create a prediction.
|
|
413
|
+
* This method creates a prediction using either the latest version of a model
|
|
414
|
+
* or a specific model version.
|
|
415
|
+
* @param options Options for prediction creation.
|
|
416
|
+
* @returns The new prediction.
|
|
417
|
+
* @throws {TypeError} When an invalid combination of version_id,
|
|
418
|
+
* model_owner and model_name is provided.
|
|
419
|
+
*/
|
|
420
|
+
create(options: CreateOptions): Promise<PredictionWithIO>;
|
|
421
|
+
/**
|
|
422
|
+
* List predictions.
|
|
423
|
+
* @param options Optional settings to control pagination behavior.
|
|
424
|
+
* @returns Paginated response containing predictions and navigation metadata.
|
|
425
|
+
*/
|
|
426
|
+
list(options?: PaginationOptions): Promise<PaginatedResponse<Prediction>>;
|
|
427
|
+
/**
|
|
428
|
+
* Waits for a prediction to complete.
|
|
429
|
+
* This method uses short polling to check the prediction status at
|
|
430
|
+
* regular intervals until it reaches a terminal state.
|
|
431
|
+
* @param prediction Initial prediction object.
|
|
432
|
+
* @param pollInterval Time in milliseconds between polling attempts to check
|
|
433
|
+
* the prediction status. Defaults to 1000ms.
|
|
434
|
+
* @returns Prediction after completion.
|
|
435
|
+
*/
|
|
436
|
+
wait(prediction: PredictionWithIO, pollInterval?: number): Promise<PredictionWithIO>;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Parameters for updating a model.
|
|
441
|
+
*/
|
|
442
|
+
type UpdateModelParams = {
|
|
443
|
+
/**
|
|
444
|
+
* The name of the model.
|
|
445
|
+
*/
|
|
446
|
+
name?: string;
|
|
447
|
+
/**
|
|
448
|
+
* Description of the model.
|
|
449
|
+
*/
|
|
450
|
+
description?: string | null;
|
|
451
|
+
/**
|
|
452
|
+
* The visibility of the model.
|
|
453
|
+
*/
|
|
454
|
+
visibility?: ModelVisibility;
|
|
455
|
+
/**
|
|
456
|
+
* The name of the hardware used by the model.
|
|
457
|
+
*/
|
|
458
|
+
hardware_name?: string;
|
|
459
|
+
/**
|
|
460
|
+
* Source url from where the model's code can be referenced.
|
|
461
|
+
*/
|
|
462
|
+
source_url?: string | null;
|
|
463
|
+
/**
|
|
464
|
+
* License url where the model's usage is specified.
|
|
465
|
+
*/
|
|
466
|
+
license_url?: string | null;
|
|
467
|
+
/**
|
|
468
|
+
* Paper url from where research info on the model can be found.
|
|
469
|
+
*/
|
|
470
|
+
paper_url?: string | null;
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Parameters for creating a model.
|
|
474
|
+
*/
|
|
475
|
+
type CreateModelParams = {
|
|
476
|
+
/**
|
|
477
|
+
* The name of the model.
|
|
478
|
+
*/
|
|
479
|
+
name: string;
|
|
480
|
+
/**
|
|
481
|
+
* The visibility of the model.
|
|
482
|
+
*/
|
|
483
|
+
visibility?: ModelVisibility;
|
|
484
|
+
/**
|
|
485
|
+
* The name of the hardware used by the model.
|
|
486
|
+
*/
|
|
487
|
+
hardware_name: string;
|
|
488
|
+
/**
|
|
489
|
+
* Description of the model.
|
|
490
|
+
*/
|
|
491
|
+
description?: string;
|
|
492
|
+
/**
|
|
493
|
+
* Source url from where the model's code can be referenced.
|
|
494
|
+
*/
|
|
495
|
+
source_url?: string;
|
|
496
|
+
/**
|
|
497
|
+
* License url where the model's usage is specified.
|
|
498
|
+
*/
|
|
499
|
+
license_url?: string;
|
|
500
|
+
/**
|
|
501
|
+
* Paper url from where research info on the model can be found.
|
|
502
|
+
*/
|
|
503
|
+
paper_url?: string;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Enumeration of possible sorting options for querying models.
|
|
507
|
+
*/
|
|
508
|
+
declare enum ModelsSortBy {
|
|
509
|
+
created_at_asc = "created_at_asc",
|
|
510
|
+
prediction_count_desc = "prediction_count_desc"
|
|
511
|
+
}
|
|
512
|
+
/** Pagination options for querying models */
|
|
513
|
+
type ModelPaginationOptions = PaginationOptions & {
|
|
514
|
+
/**
|
|
515
|
+
* The sorting criteria
|
|
516
|
+
*/
|
|
517
|
+
sort_by?: ModelsSortBy;
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* Resource for operations related to models.
|
|
521
|
+
*/
|
|
522
|
+
declare class Models extends Resource {
|
|
523
|
+
/**
|
|
524
|
+
* Delete a model.
|
|
525
|
+
* @param owner Username of the model's owner.
|
|
526
|
+
* @param name Name of the model.
|
|
527
|
+
*/
|
|
528
|
+
delete(owner: string, name: string): Promise<void>;
|
|
529
|
+
/**
|
|
530
|
+
* Create a model.
|
|
531
|
+
* @param options Parameters for creating a model.
|
|
532
|
+
* @returns The new model.
|
|
533
|
+
*/
|
|
534
|
+
create(options: CreateModelParams): Promise<Model>;
|
|
535
|
+
/**
|
|
536
|
+
* Get a model.
|
|
537
|
+
* @param owner Username of the model's owner.
|
|
538
|
+
* @param name Name of the model.
|
|
539
|
+
* @returns A model object.
|
|
540
|
+
*/
|
|
541
|
+
get(owner: string, name: string): Promise<Model>;
|
|
542
|
+
/**
|
|
543
|
+
* Constructs the API path for listing models.
|
|
544
|
+
* @param owner - Username of the model's owner to fetch models for.
|
|
545
|
+
* If not passed, returns a path to fetch all models.
|
|
546
|
+
* @returns The constructed API path for listing models.
|
|
547
|
+
*/
|
|
548
|
+
private buildListPath;
|
|
549
|
+
/**
|
|
550
|
+
* List models.
|
|
551
|
+
* @param options Optional settings to control pagination behavior.
|
|
552
|
+
* @param owner Optional username of the model's owner to fetch models for.
|
|
553
|
+
* If not passed, all models are fetched.
|
|
554
|
+
* @returns Paginated response containing models and navigation metadata.
|
|
555
|
+
*/
|
|
556
|
+
list(options?: ModelPaginationOptions, owner?: string): Promise<PaginatedResponse<Model>>;
|
|
557
|
+
/**
|
|
558
|
+
* Update a model.
|
|
559
|
+
* @param owner Username of the model's owner.
|
|
560
|
+
* @param name Name of the model.
|
|
561
|
+
* @param params The fields to update.
|
|
562
|
+
* @returns The updated model.
|
|
563
|
+
*/
|
|
564
|
+
update(owner: string, name: string, params: UpdateModelParams): Promise<Model>;
|
|
565
|
+
/**
|
|
566
|
+
* Search models.
|
|
567
|
+
* @param q The search query.
|
|
568
|
+
* @param options Optional settings to control pagination behavior.
|
|
569
|
+
* @returns Paginated response containing models and navigation metadata.
|
|
570
|
+
*/
|
|
571
|
+
search(q: string, options?: PaginationOptions): Promise<PaginatedResponse<Model>>;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Represents a hardware item.
|
|
576
|
+
*/
|
|
577
|
+
interface Hardware {
|
|
578
|
+
/** Unique identifier for the hardware. */
|
|
579
|
+
id: string;
|
|
580
|
+
/** Name of the hardware. */
|
|
581
|
+
name: string;
|
|
582
|
+
/** Number of GPUs available on the hardware. */
|
|
583
|
+
gpus: number;
|
|
584
|
+
/** Number of CPUs available on the hardware. */
|
|
585
|
+
cpus: number;
|
|
586
|
+
/** Amount of RAM (in GB) allocated per GPU. */
|
|
587
|
+
ram_per_gpu_gb: number;
|
|
588
|
+
/** Total RAM (in GB) available on the hardware. */
|
|
589
|
+
ram_gb: number;
|
|
590
|
+
/** Timestamp when the hardware was created. */
|
|
591
|
+
created_at: string;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Resource for operations related to hardware.
|
|
595
|
+
*/
|
|
596
|
+
declare class HardwareResource extends Resource {
|
|
597
|
+
/**
|
|
598
|
+
* List hardware.
|
|
599
|
+
* @param options Optional settings to control pagination behavior.
|
|
600
|
+
* @returns Paginated response containing hardware and navigation metadata.
|
|
601
|
+
*/
|
|
602
|
+
list(options?: PaginationOptions): Promise<PaginatedResponse<Hardware>>;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Resource class for interacting with model versions.
|
|
607
|
+
*/
|
|
608
|
+
declare class Versions extends Resource {
|
|
609
|
+
/**
|
|
610
|
+
* Get a model version by its ID.
|
|
611
|
+
* @param id The ID of the model version to retrieve.
|
|
612
|
+
* @returns The model version object.
|
|
613
|
+
*/
|
|
614
|
+
get(id: string): Promise<Version>;
|
|
615
|
+
/**
|
|
616
|
+
* Create a version of a model.
|
|
617
|
+
* @param modelOwner The username of the model's owner.
|
|
618
|
+
* @param modelName The name of the model.
|
|
619
|
+
* @param release_notes Information about changes such as new features,
|
|
620
|
+
* bug fixes, or optimizations in this version.
|
|
621
|
+
* @param schemas The schemas of the model version.
|
|
622
|
+
* @param container_image_digest A sha256 hash digest of the version's
|
|
623
|
+
* container image.
|
|
624
|
+
* @returns The new version object.
|
|
625
|
+
*/
|
|
626
|
+
create(modelOwner: string, modelName: string, release_notes: string, schemas: Schemas, container_image_digest: string): Promise<Version>;
|
|
627
|
+
/**
|
|
628
|
+
* Delete a model version by its ID.
|
|
629
|
+
* @param id The ID of the model version to delete.
|
|
630
|
+
*/
|
|
631
|
+
delete(id: string): Promise<void>;
|
|
632
|
+
/**
|
|
633
|
+
* List versions.
|
|
634
|
+
* @param modelOwner Username of the model's owner.
|
|
635
|
+
* @param modelName Name of the model.
|
|
636
|
+
* @param options Pagination options.
|
|
637
|
+
* @returns A paginated response containing model versions.
|
|
638
|
+
*/
|
|
639
|
+
list(modelOwner: string, modelName: string, options?: PaginationOptions): Promise<PaginatedResponse<Version>>;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
declare class Users extends Resource {
|
|
643
|
+
private readonly API_PREFIX;
|
|
644
|
+
/**
|
|
645
|
+
* Fetch a user by their username.
|
|
646
|
+
* @param username The username of the user.
|
|
647
|
+
* @returns The user object.
|
|
648
|
+
*/
|
|
649
|
+
get(username: string): Promise<User>;
|
|
650
|
+
/**
|
|
651
|
+
* List users.
|
|
652
|
+
* @param options Optional settings to control pagination behavior.
|
|
653
|
+
* @returns Paginated response containing users and navigation metadata.
|
|
654
|
+
*/
|
|
655
|
+
list(options?: PaginationOptions): Promise<PaginatedResponse<User>>;
|
|
656
|
+
/**
|
|
657
|
+
* Search users.
|
|
658
|
+
* @param q The search query.
|
|
659
|
+
* @param options Optional settings to control pagination behavior.
|
|
660
|
+
* @returns Paginated response containing users and navigation metadata.
|
|
661
|
+
*/
|
|
662
|
+
search(q: string, options?: PaginationOptions): Promise<PaginatedResponse<User>>;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Parameters for updating a user.
|
|
667
|
+
*/
|
|
668
|
+
type UpdateUserParams = {
|
|
669
|
+
/**
|
|
670
|
+
* The new username of the user.
|
|
671
|
+
*/
|
|
672
|
+
username?: string;
|
|
673
|
+
/**
|
|
674
|
+
* The new name of the user.
|
|
675
|
+
*/
|
|
676
|
+
name?: string | null;
|
|
677
|
+
/**
|
|
678
|
+
* The new biography of the user.
|
|
679
|
+
*/
|
|
680
|
+
bio?: string | null;
|
|
681
|
+
/**
|
|
682
|
+
* The new URLs associated with the user.
|
|
683
|
+
*/
|
|
684
|
+
urls?: string[] | null;
|
|
685
|
+
/**
|
|
686
|
+
* The new company of the user.
|
|
687
|
+
*/
|
|
688
|
+
company?: string | null;
|
|
689
|
+
/**
|
|
690
|
+
* The new location of the user.
|
|
691
|
+
*/
|
|
692
|
+
location?: string | null;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* Resource for operations related to the authenticated user.
|
|
696
|
+
*/
|
|
697
|
+
declare class AuthenticatedUser extends Resource {
|
|
698
|
+
private readonly API_PREFIX;
|
|
699
|
+
get(): Promise<User>;
|
|
700
|
+
/**
|
|
701
|
+
* Update the authenticated user.
|
|
702
|
+
* @param params - The fields to update.
|
|
703
|
+
* @returns The updated user object.
|
|
704
|
+
*/
|
|
705
|
+
update(params: UpdateUserParams): Promise<User>;
|
|
706
|
+
/**
|
|
707
|
+
* List models of the authenticated user.
|
|
708
|
+
* @param options - Optional settings to control pagination behavior.
|
|
709
|
+
* @returns A paginated response containing models and navigation metadata.
|
|
710
|
+
*/
|
|
711
|
+
models(options?: PaginationOptions): Promise<PaginatedResponse<Model>>;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
interface WriftAIClientOptions {
|
|
715
|
+
/**
|
|
716
|
+
* Optional base URL for the API. It must not contain
|
|
717
|
+
* a trailing slash.
|
|
718
|
+
*/
|
|
719
|
+
apiBaseUrl?: string;
|
|
720
|
+
/**
|
|
721
|
+
* Optional bearer token for authorization.
|
|
722
|
+
*/
|
|
723
|
+
accessToken?: string;
|
|
724
|
+
/**
|
|
725
|
+
* Optional custom fetch implementation.
|
|
726
|
+
*/
|
|
727
|
+
fetch?: typeof fetch;
|
|
728
|
+
/**
|
|
729
|
+
* Optional headers to inject in requests to
|
|
730
|
+
* WriftAI's API.
|
|
731
|
+
*/
|
|
732
|
+
headers?: Record<string, string>;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Client for WriftAI.
|
|
736
|
+
*/
|
|
737
|
+
declare class WriftAI {
|
|
738
|
+
private apiClient;
|
|
739
|
+
/**
|
|
740
|
+
* Interface for accessing prediction related
|
|
741
|
+
* resources and operations.
|
|
742
|
+
*/
|
|
743
|
+
predictions: PredictionsResource;
|
|
744
|
+
/**
|
|
745
|
+
* Interface for accessing version related
|
|
746
|
+
* resources and operations.
|
|
747
|
+
*/
|
|
748
|
+
versions: Versions;
|
|
749
|
+
/**
|
|
750
|
+
* Interface for accessing user related
|
|
751
|
+
* resources and operations.
|
|
752
|
+
*/
|
|
753
|
+
users: Users;
|
|
754
|
+
/**
|
|
755
|
+
* Interface for accessing model related
|
|
756
|
+
* resources and operations.
|
|
757
|
+
*/
|
|
758
|
+
models: Models;
|
|
759
|
+
authenticatedUser: AuthenticatedUser;
|
|
760
|
+
/**
|
|
761
|
+
* Interface for accessing hardware related
|
|
762
|
+
* resources and operations
|
|
763
|
+
*/
|
|
764
|
+
hardware: HardwareResource;
|
|
765
|
+
/**
|
|
766
|
+
* Create an instance of the WriftAI client.
|
|
767
|
+
* @param options Client options
|
|
768
|
+
* @param options.apiBaseUrl Base URL for the API without
|
|
769
|
+
* trailing slashes. Defaults to {@link API_BASE_URL} if not provided.
|
|
770
|
+
* @param options.fetch Fetch implementation to use.
|
|
771
|
+
* Defaults to `globalThis.fetch`.
|
|
772
|
+
* @param options.accessToken Bearer token used for
|
|
773
|
+
* authentication. Defaults to `process.env.WRIFTAI_API_ACCESS_TOKEN`
|
|
774
|
+
* if available.
|
|
775
|
+
* @param options.headers Optional additional headers (overrides defaults).
|
|
776
|
+
*/
|
|
777
|
+
constructor(options?: WriftAIClientOptions);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export { ErrorSource, ModelVisibility, ModelsSortBy, Status, WriftAI, WriftAIAPIError };
|
|
781
|
+
export type { Hardware, Model, PaginatedResponse, Prediction, PredictionWithIO, SchemaIO, Schemas, TaskError, User, Version, WriftAIClientOptions };
|