wriftai 0.54.0 → 0.56.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/README.md +6 -8
- package/dist/index.cjs +328 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +249 -142
- package/dist/index.mjs +328 -170
- package/dist/index.mjs.map +1 -1
- package/dist/wriftai.umd.min.js +2 -2
- package/dist/wriftai.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
import { lookup } from 'mrmime';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Incrementally decodes a server-sent events byte stream.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately not a full WHATWG implementation. Upstream output is
|
|
7
|
+
* validated by the platform, so we only handle what it can emit:
|
|
8
|
+
* `\n` and `\r\n` line endings (no lone `\r`), no leading BOM, and
|
|
9
|
+
* no `retry` field (unknown fields are ignored). `data` is always JSON.
|
|
10
|
+
*
|
|
11
|
+
* Holds the state of one stream, so use a new decoder per connection.
|
|
12
|
+
*/
|
|
13
|
+
class SSEDecoder {
|
|
14
|
+
buffer = '';
|
|
15
|
+
id = '';
|
|
16
|
+
event = '';
|
|
17
|
+
data = [];
|
|
18
|
+
decoder = new TextDecoder('utf-8');
|
|
19
|
+
/**
|
|
20
|
+
* Feeds the next chunk of the stream.
|
|
21
|
+
* @param chunk Raw bytes of any size.
|
|
22
|
+
* @returns The events completed by this chunk, in order.
|
|
23
|
+
*/
|
|
24
|
+
feed(chunk) {
|
|
25
|
+
const text = this.decoder.decode(chunk, { stream: true });
|
|
26
|
+
this.buffer += text;
|
|
27
|
+
// no complete line yet, so don't re-split a long partial line per chunk.
|
|
28
|
+
if (!text.includes('\n'))
|
|
29
|
+
return [];
|
|
30
|
+
const lines = this.buffer.split('\n');
|
|
31
|
+
// split() always returns at least one element.
|
|
32
|
+
this.buffer = lines.pop();
|
|
33
|
+
const events = [];
|
|
34
|
+
for (const rawLine of lines) {
|
|
35
|
+
const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;
|
|
36
|
+
// blank line ends the event
|
|
37
|
+
if (line === '') {
|
|
38
|
+
if (this.data.length > 0) {
|
|
39
|
+
events.push({
|
|
40
|
+
id: this.id,
|
|
41
|
+
event: this.event,
|
|
42
|
+
data: JSON.parse(this.data.join('\n')),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
this.data = [];
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const colon = line.indexOf(':');
|
|
49
|
+
const field = colon === -1 ? line : line.slice(0, colon);
|
|
50
|
+
let value = colon === -1 ? '' : line.slice(colon + 1);
|
|
51
|
+
if (value.startsWith(' ')) {
|
|
52
|
+
value = value.slice(1);
|
|
53
|
+
}
|
|
54
|
+
if (field === 'id') {
|
|
55
|
+
this.id = value;
|
|
56
|
+
}
|
|
57
|
+
else if (field === 'event') {
|
|
58
|
+
this.event = value;
|
|
59
|
+
}
|
|
60
|
+
else if (field === 'data') {
|
|
61
|
+
this.data.push(value);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return events;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
3
68
|
/**
|
|
4
69
|
* Representation of an error from WriftAI's API.
|
|
5
70
|
*/
|
|
@@ -30,6 +95,7 @@ class API {
|
|
|
30
95
|
fetchImpl;
|
|
31
96
|
maxRetries;
|
|
32
97
|
defaultHeaders;
|
|
98
|
+
static SSE_HEADERS = { 'Accept-Encoding': 'identity' };
|
|
33
99
|
/**
|
|
34
100
|
* Create an instance of the API client.
|
|
35
101
|
* @param baseUrl Base URL for the API without trailing slashes.
|
|
@@ -123,23 +189,11 @@ class API {
|
|
|
123
189
|
}
|
|
124
190
|
/**
|
|
125
191
|
* Sends an HTTP request with automatic retries on transient errors.
|
|
126
|
-
* @template T The expected JSON response shape
|
|
127
192
|
* @param path The path relative to `baseUrl` (e.g. `/users`)
|
|
128
193
|
* @param options Request options
|
|
129
|
-
* @
|
|
130
|
-
* @param options.params Optional query parameters. Entries
|
|
131
|
-
* with `undefined` values are silently skipped.
|
|
132
|
-
* @param options.body Optional JSON-serializable body
|
|
133
|
-
* @param options.headers Optional extra request headers
|
|
134
|
-
* @param options.signal Optional AbortSignal to cancel the request.
|
|
135
|
-
* @returns The parsed JSON response
|
|
136
|
-
* @throws {WriftAIAPIError} If the response is not ok (`!res.ok`)
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* const users = await client.request<User[]>("/users", { method: "GET" });
|
|
140
|
-
* ```
|
|
194
|
+
* @returns The successful response with its body not yet read.
|
|
141
195
|
*/
|
|
142
|
-
async
|
|
196
|
+
async send(path, options) {
|
|
143
197
|
const url = new URL(this.baseUrl + path);
|
|
144
198
|
if (options.params) {
|
|
145
199
|
for (const [k, v] of Object.entries(options.params)) {
|
|
@@ -177,11 +231,84 @@ class API {
|
|
|
177
231
|
const errorBody = await res.text();
|
|
178
232
|
throw new WriftAIAPIError(res.status, errorBody, url.toString());
|
|
179
233
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
234
|
+
return res;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Sends an HTTP request with automatic retries on transient errors.
|
|
239
|
+
* @template T The expected JSON response shape
|
|
240
|
+
* @param path The path relative to `baseUrl` (e.g. `/users`)
|
|
241
|
+
* @param options Request options
|
|
242
|
+
* @returns The parsed JSON response
|
|
243
|
+
* @throws {WriftAIAPIError} If the response is not ok (`!res.ok`)
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* const users = await client.request<User[]>("/users", { method: "GET" });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
async request(path, options) {
|
|
250
|
+
const res = await this.send(path, options);
|
|
251
|
+
// handle empty-body responses safely
|
|
252
|
+
if (res.status === 204) {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
return res.json();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Iterates over server-sent events from a streaming HTTP response.
|
|
259
|
+
* Consumes the response body incrementally, decodes SSE messages as
|
|
260
|
+
* chunks arrive, and yields each completed event in order.
|
|
261
|
+
* @param response The streaming HTTP response containing SSE data.
|
|
262
|
+
* @yields Decoded server-sent events from the response stream.
|
|
263
|
+
*/
|
|
264
|
+
static async *iterEvents(response) {
|
|
265
|
+
if (!response.body) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const decoder = new SSEDecoder();
|
|
269
|
+
const reader = response.body.getReader();
|
|
270
|
+
try {
|
|
271
|
+
for (;;) {
|
|
272
|
+
const { done, value } = await reader.read();
|
|
273
|
+
if (done)
|
|
274
|
+
break;
|
|
275
|
+
for (const event of decoder.feed(value)) {
|
|
276
|
+
yield event;
|
|
277
|
+
}
|
|
183
278
|
}
|
|
184
|
-
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
// getReader() creates a reader and locks the stream to it.
|
|
282
|
+
// No other reader can be acquired until the lock is released.
|
|
283
|
+
reader.releaseLock();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Opens a single server-sent events (SSE) connection.
|
|
288
|
+
* The request is sent when iteration begins and the connection remains
|
|
289
|
+
* open until the stream ends, iteration stops, or the consumer cancels
|
|
290
|
+
* the operation. Retries on transient errors apply only while opening
|
|
291
|
+
* the connection.
|
|
292
|
+
* @param path The path relative to `baseUrl` (e.g. `/events`)
|
|
293
|
+
* @param options Request options
|
|
294
|
+
* @yields Decoded server-sent events from the connection in the order
|
|
295
|
+
* they are received.
|
|
296
|
+
*/
|
|
297
|
+
async *streamSSE(path, options) {
|
|
298
|
+
const response = await this.send(path, {
|
|
299
|
+
...options,
|
|
300
|
+
headers: {
|
|
301
|
+
...options.headers,
|
|
302
|
+
...API.SSE_HEADERS,
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
try {
|
|
306
|
+
yield* API.iterEvents(response);
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
// Clean up the response stream when consumption stops early
|
|
310
|
+
// or an error is thrown.
|
|
311
|
+
await response.body?.cancel();
|
|
185
312
|
}
|
|
186
313
|
}
|
|
187
314
|
}
|
|
@@ -409,10 +536,11 @@ class Files {
|
|
|
409
536
|
* `Uint8Array` require the data to already be in memory.
|
|
410
537
|
* Large files are split into parts by the server and uploaded concurrently.
|
|
411
538
|
* @param file The file to upload.
|
|
412
|
-
* @param
|
|
539
|
+
* @param options Options for the call.
|
|
413
540
|
* @returns Result of the completed upload.
|
|
414
541
|
*/
|
|
415
|
-
async upload(file,
|
|
542
|
+
async upload(file, options) {
|
|
543
|
+
const signal = options?.signal;
|
|
416
544
|
// wrap Uint8Array in a Blob.
|
|
417
545
|
const body = file.content instanceof Blob
|
|
418
546
|
? file.content
|
|
@@ -421,9 +549,10 @@ class Files {
|
|
|
421
549
|
const upload = await this.uploads.create({
|
|
422
550
|
size,
|
|
423
551
|
mime_type: file.mimeType,
|
|
424
|
-
|
|
552
|
+
signal,
|
|
553
|
+
});
|
|
425
554
|
const etags = await this.uploadParts(body, upload.urls, upload.part_size, file.mimeType, signal);
|
|
426
|
-
return await this.uploads.complete(upload.id, { etags
|
|
555
|
+
return await this.uploads.complete(upload.id, { etags, signal });
|
|
427
556
|
}
|
|
428
557
|
}
|
|
429
558
|
|
|
@@ -486,6 +615,13 @@ var Status;
|
|
|
486
615
|
* Default wait options.
|
|
487
616
|
*/
|
|
488
617
|
const DEFAULT_WAIT_OPTIONS = { pollInterval: 1000 };
|
|
618
|
+
/**
|
|
619
|
+
* Default wait options for prediction creation.
|
|
620
|
+
*/
|
|
621
|
+
const DEFAULT_CREATE_WAIT_OPTIONS = {
|
|
622
|
+
...DEFAULT_WAIT_OPTIONS,
|
|
623
|
+
poll: true,
|
|
624
|
+
};
|
|
489
625
|
/**
|
|
490
626
|
* Resource class for interacting with predictions.
|
|
491
627
|
*/
|
|
@@ -504,25 +640,25 @@ class PredictionsResource extends Resource {
|
|
|
504
640
|
/**
|
|
505
641
|
* Get a prediction by its ID.
|
|
506
642
|
* @param id The ID of the prediction to fetch.
|
|
507
|
-
* @param
|
|
643
|
+
* @param options Options for the call.
|
|
508
644
|
* @returns The prediction object.
|
|
509
645
|
*/
|
|
510
|
-
async get(id,
|
|
646
|
+
async get(id, options) {
|
|
511
647
|
const response = await this.api.request(`${this.PREDICTIONS_API_PREFIX}/${id}`, {
|
|
512
648
|
method: 'GET',
|
|
513
|
-
signal,
|
|
649
|
+
signal: options?.signal,
|
|
514
650
|
});
|
|
515
651
|
return response;
|
|
516
652
|
}
|
|
517
653
|
/**
|
|
518
654
|
* Cancel a prediction by its ID.
|
|
519
655
|
* @param id The ID of the prediction to cancel.
|
|
520
|
-
* @param
|
|
656
|
+
* @param options Options for the call.
|
|
521
657
|
*/
|
|
522
|
-
async cancel(id,
|
|
658
|
+
async cancel(id, options) {
|
|
523
659
|
await this.api.request(`${this.PREDICTIONS_API_PREFIX}/${id}/cancel`, {
|
|
524
660
|
method: 'POST',
|
|
525
|
-
signal,
|
|
661
|
+
signal: options?.signal,
|
|
526
662
|
});
|
|
527
663
|
}
|
|
528
664
|
/**
|
|
@@ -535,7 +671,7 @@ class PredictionsResource extends Resource {
|
|
|
535
671
|
async fileUploader(value, limit) {
|
|
536
672
|
if (value instanceof FileData) {
|
|
537
673
|
return limit(async (signal) => {
|
|
538
|
-
const uploaded = await this.files.upload(value, signal);
|
|
674
|
+
const uploaded = await this.files.upload(value, { signal });
|
|
539
675
|
return uploaded.download_url;
|
|
540
676
|
});
|
|
541
677
|
}
|
|
@@ -548,51 +684,84 @@ class PredictionsResource extends Resource {
|
|
|
548
684
|
}
|
|
549
685
|
return value;
|
|
550
686
|
}
|
|
687
|
+
/**
|
|
688
|
+
* Build request headers for a prediction create call.
|
|
689
|
+
* @param params Parameters for prediction creation.
|
|
690
|
+
* @param waitOptions Wait options, or undefined if not waiting.
|
|
691
|
+
* @returns The headers to send.
|
|
692
|
+
*/
|
|
693
|
+
buildCreateHeaders(params, waitOptions) {
|
|
694
|
+
const headers = {};
|
|
695
|
+
if (params.validateInput !== undefined) {
|
|
696
|
+
headers['Validate-Input'] = String(params.validateInput);
|
|
697
|
+
}
|
|
698
|
+
if (waitOptions) {
|
|
699
|
+
headers['Prefer'] =
|
|
700
|
+
waitOptions.duration === undefined
|
|
701
|
+
? 'wait'
|
|
702
|
+
: `wait=${String(waitOptions.duration)}`;
|
|
703
|
+
}
|
|
704
|
+
return headers;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Determines whether a prediction status is terminal.
|
|
708
|
+
* @param status The current prediction status.
|
|
709
|
+
* @returns whether the status is terminal.
|
|
710
|
+
*/
|
|
711
|
+
static isStatusTerminal(status) {
|
|
712
|
+
return (status === Status.succeeded ||
|
|
713
|
+
status === Status.failed ||
|
|
714
|
+
status === Status.cancelled ||
|
|
715
|
+
status === Status.abandoned);
|
|
716
|
+
}
|
|
551
717
|
/**
|
|
552
718
|
* Create a prediction.
|
|
553
719
|
* This method creates a prediction using either the latest version of a model
|
|
554
720
|
* or a specific model version. Files in the input are uploaded concurrently
|
|
555
721
|
* before the prediction is created.
|
|
556
|
-
* @param
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
* {@link DEFAULT_WAIT_OPTIONS} are used.
|
|
561
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
722
|
+
* @param params Parameters for prediction creation.
|
|
723
|
+
* If `wait` is set, the prediction is awaited until it finishes; `true`
|
|
724
|
+
* uses {@link DEFAULT_CREATE_WAIT_OPTIONS} and an object overrides
|
|
725
|
+
* individual values. Otherwise it is returned immediately.
|
|
562
726
|
* @returns The new prediction.
|
|
563
727
|
*/
|
|
564
|
-
async create(
|
|
565
|
-
const { input, webhook,
|
|
728
|
+
async create(params) {
|
|
729
|
+
const { input, webhook, model, wait, signal } = params;
|
|
730
|
+
const waitOptions = wait
|
|
731
|
+
? {
|
|
732
|
+
...DEFAULT_CREATE_WAIT_OPTIONS,
|
|
733
|
+
...(wait === true ? undefined : wait),
|
|
734
|
+
}
|
|
735
|
+
: undefined;
|
|
736
|
+
const headers = this.buildCreateHeaders(params, waitOptions);
|
|
566
737
|
const uploadedInput = await this.fileUploader(input, createConcurrencyLimit(16, signal));
|
|
567
738
|
const body = {
|
|
568
739
|
model,
|
|
569
740
|
input: uploadedInput,
|
|
570
741
|
...(webhook !== undefined && { webhook }),
|
|
571
742
|
};
|
|
572
|
-
const headers = validate_input !== undefined
|
|
573
|
-
? { 'Validate-Input': String(validate_input) }
|
|
574
|
-
: undefined;
|
|
575
743
|
const prediction = await this.api.request(this.PREDICTIONS_API_PREFIX, {
|
|
576
744
|
method: 'POST',
|
|
577
745
|
body,
|
|
578
746
|
headers,
|
|
579
747
|
signal,
|
|
580
748
|
});
|
|
581
|
-
if (
|
|
582
|
-
|
|
749
|
+
if (waitOptions?.poll &&
|
|
750
|
+
!PredictionsResource.isStatusTerminal(prediction.status)) {
|
|
751
|
+
return await this.wait(prediction.id, { ...waitOptions, signal });
|
|
583
752
|
}
|
|
584
753
|
return prediction;
|
|
585
754
|
}
|
|
586
755
|
/**
|
|
587
756
|
* List predictions.
|
|
588
|
-
* @param options
|
|
589
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
757
|
+
* @param options Options for listing predictions.
|
|
590
758
|
* @returns Paginated response containing predictions and navigation metadata.
|
|
591
759
|
*/
|
|
592
|
-
async list(options
|
|
760
|
+
async list(options) {
|
|
761
|
+
const { signal, ...query } = options ?? {};
|
|
593
762
|
const response = await this.api.request(this.PREDICTIONS_API_PREFIX, {
|
|
594
763
|
method: 'GET',
|
|
595
|
-
params:
|
|
764
|
+
params: query,
|
|
596
765
|
signal,
|
|
597
766
|
});
|
|
598
767
|
return response;
|
|
@@ -602,13 +771,16 @@ class PredictionsResource extends Resource {
|
|
|
602
771
|
* This method uses short polling to check the prediction status at
|
|
603
772
|
* regular intervals until it reaches a terminal state.
|
|
604
773
|
* @param predictionID The ID of the prediction.
|
|
605
|
-
* @param options Options for
|
|
606
|
-
* {@link DEFAULT_WAIT_OPTIONS}
|
|
607
|
-
* @param signal Optional AbortSignal that can be used to cancel the polling
|
|
608
|
-
* operation.
|
|
774
|
+
* @param options Options for waiting. Any omitted values use
|
|
775
|
+
* {@link DEFAULT_WAIT_OPTIONS}.
|
|
609
776
|
* @returns Prediction after completion.
|
|
610
777
|
*/
|
|
611
|
-
async wait(predictionID, options
|
|
778
|
+
async wait(predictionID, options) {
|
|
779
|
+
const { signal, ...waitOptions } = options ?? {};
|
|
780
|
+
const mergedOptions = {
|
|
781
|
+
...DEFAULT_WAIT_OPTIONS,
|
|
782
|
+
...waitOptions,
|
|
783
|
+
};
|
|
612
784
|
const sleep = (delay, signal) => {
|
|
613
785
|
return new Promise((resolve, reject) => {
|
|
614
786
|
let timeout = undefined;
|
|
@@ -644,17 +816,14 @@ class PredictionsResource extends Resource {
|
|
|
644
816
|
});
|
|
645
817
|
};
|
|
646
818
|
for (;;) {
|
|
647
|
-
const result = await this.get(predictionID, signal);
|
|
648
|
-
if (
|
|
649
|
-
await
|
|
819
|
+
const result = await this.get(predictionID, { signal });
|
|
820
|
+
if (mergedOptions.onPoll) {
|
|
821
|
+
await mergedOptions.onPoll(result);
|
|
650
822
|
}
|
|
651
|
-
if (result
|
|
652
|
-
result.status === Status.succeeded ||
|
|
653
|
-
result.status === Status.cancelled ||
|
|
654
|
-
result.status === Status.abandoned) {
|
|
823
|
+
if (PredictionsResource.isStatusTerminal(result['status'])) {
|
|
655
824
|
return result;
|
|
656
825
|
}
|
|
657
|
-
await sleep(
|
|
826
|
+
await sleep(mergedOptions.pollInterval, signal);
|
|
658
827
|
}
|
|
659
828
|
}
|
|
660
829
|
}
|
|
@@ -699,13 +868,13 @@ class ModelVersions extends Resource {
|
|
|
699
868
|
* Get a model version.
|
|
700
869
|
* @param identifier The model version identifier in owner/name:version-number
|
|
701
870
|
* format (for example: deepseek-ai/deepseek-r1:2).
|
|
702
|
-
* @param
|
|
871
|
+
* @param options Options for the call.
|
|
703
872
|
* @returns The model version object.
|
|
704
873
|
*/
|
|
705
|
-
async get(identifier,
|
|
874
|
+
async get(identifier, options) {
|
|
706
875
|
const [modelOwner, modelName, number] = this.parseModelVersionIdentifier(identifier);
|
|
707
876
|
const response = await this.api.request(`${this.MODELS_API_PREFIX}/${modelOwner}/${modelName}` +
|
|
708
|
-
`${this.MODEL_VERSION_PATH}/${number}`, { method: 'GET', signal });
|
|
877
|
+
`${this.MODEL_VERSION_PATH}/${number}`, { method: 'GET', signal: options?.signal });
|
|
709
878
|
return response;
|
|
710
879
|
}
|
|
711
880
|
/**
|
|
@@ -713,16 +882,16 @@ class ModelVersions extends Resource {
|
|
|
713
882
|
* @param identifier The model identifier in owner/name format
|
|
714
883
|
* (for example: deepseek-ai/deepseek-r1).
|
|
715
884
|
* @param params Model version creation parameters.
|
|
716
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
717
885
|
* @returns The new version object.
|
|
718
886
|
*/
|
|
719
|
-
async create(identifier, params
|
|
887
|
+
async create(identifier, params) {
|
|
888
|
+
const { signal, ...body } = params;
|
|
720
889
|
const [modelOwner, modelName] = this.parseModelIdentifier(identifier);
|
|
721
890
|
const path = `${this.MODELS_API_PREFIX}/${modelOwner}/` +
|
|
722
891
|
`${modelName}${this.MODEL_VERSION_PATH}`;
|
|
723
892
|
const response = await this.api.request(path, {
|
|
724
893
|
method: 'POST',
|
|
725
|
-
body
|
|
894
|
+
body,
|
|
726
895
|
signal,
|
|
727
896
|
});
|
|
728
897
|
return response;
|
|
@@ -731,31 +900,31 @@ class ModelVersions extends Resource {
|
|
|
731
900
|
* Delete a model version.
|
|
732
901
|
* @param identifier The model version identifier in owner/name:version-number
|
|
733
902
|
* format (for example: deepseek-ai/deepseek-r1:2).
|
|
734
|
-
* @param
|
|
903
|
+
* @param options Options for the call.
|
|
735
904
|
*/
|
|
736
|
-
async delete(identifier,
|
|
905
|
+
async delete(identifier, options) {
|
|
737
906
|
const [modelOwner, modelName, number] = this.parseModelVersionIdentifier(identifier);
|
|
738
907
|
await this.api.request(`${this.MODELS_API_PREFIX}/${modelOwner}/${modelName}` +
|
|
739
908
|
`${this.MODEL_VERSION_PATH}/${number}`, {
|
|
740
909
|
method: 'DELETE',
|
|
741
|
-
signal,
|
|
910
|
+
signal: options?.signal,
|
|
742
911
|
});
|
|
743
912
|
}
|
|
744
913
|
/**
|
|
745
914
|
* List model versions.
|
|
746
915
|
* @param identifier The model identifier in owner/name format
|
|
747
916
|
* (for example: deepseek-ai/deepseek-r1).
|
|
748
|
-
* @param options
|
|
749
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
917
|
+
* @param options Options for listing model versions.
|
|
750
918
|
* @returns A paginated response containing model versions.
|
|
751
919
|
*/
|
|
752
|
-
async list(identifier, options
|
|
920
|
+
async list(identifier, options) {
|
|
921
|
+
const { signal, ...query } = options ?? {};
|
|
753
922
|
const [modelOwner, modelName] = this.parseModelIdentifier(identifier);
|
|
754
923
|
const path = `${this.MODELS_API_PREFIX}/${modelOwner}/` +
|
|
755
924
|
`${modelName}${this.MODEL_VERSION_PATH}`;
|
|
756
925
|
const response = await this.api.request(path, {
|
|
757
926
|
method: 'GET',
|
|
758
|
-
params:
|
|
927
|
+
params: query,
|
|
759
928
|
signal,
|
|
760
929
|
});
|
|
761
930
|
return response;
|
|
@@ -765,16 +934,16 @@ class ModelVersions extends Resource {
|
|
|
765
934
|
* @param identifier The model version identifier in owner/name:version-number
|
|
766
935
|
* format (for example: deepseek-ai/deepseek-r1:1).
|
|
767
936
|
* @param params Parameters for updating the configuration.
|
|
768
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
769
937
|
* @returns The updated model version configuration.
|
|
770
938
|
*/
|
|
771
|
-
async updateConfiguration(identifier, params
|
|
939
|
+
async updateConfiguration(identifier, params) {
|
|
940
|
+
const { signal, ...body } = params;
|
|
772
941
|
const [modelOwner, modelName, number] = this.parseModelVersionIdentifier(identifier);
|
|
773
942
|
const path = `${this.MODELS_API_PREFIX}/${modelOwner}/${modelName}` +
|
|
774
943
|
`${this.MODEL_VERSION_PATH}/${number}${this.CONFIGURATION_PATH}`;
|
|
775
944
|
const response = await this.api.request(path, {
|
|
776
945
|
method: 'PATCH',
|
|
777
|
-
body
|
|
946
|
+
body,
|
|
778
947
|
signal,
|
|
779
948
|
});
|
|
780
949
|
return response;
|
|
@@ -783,16 +952,16 @@ class ModelVersions extends Resource {
|
|
|
783
952
|
* Get the configuration of a model version.
|
|
784
953
|
* @param identifier The model version identifier in owner/name:version-number
|
|
785
954
|
* format (for example: deepseek-ai/deepseek-r1:1).
|
|
786
|
-
* @param
|
|
955
|
+
* @param options Options for the call.
|
|
787
956
|
* @returns The model version configuration.
|
|
788
957
|
*/
|
|
789
|
-
async getConfiguration(identifier,
|
|
958
|
+
async getConfiguration(identifier, options) {
|
|
790
959
|
const [modelOwner, modelName, number] = this.parseModelVersionIdentifier(identifier);
|
|
791
960
|
const path = `${this.MODELS_API_PREFIX}/${modelOwner}/${modelName}` +
|
|
792
961
|
`${this.MODEL_VERSION_PATH}/${number}${this.CONFIGURATION_PATH}`;
|
|
793
962
|
const response = await this.api.request(path, {
|
|
794
963
|
method: 'GET',
|
|
795
|
-
signal,
|
|
964
|
+
signal: options?.signal,
|
|
796
965
|
});
|
|
797
966
|
return response;
|
|
798
967
|
}
|
|
@@ -832,25 +1001,25 @@ class Models extends Resource {
|
|
|
832
1001
|
* Delete a model.
|
|
833
1002
|
* @param identifier The model identifier in owner/name format
|
|
834
1003
|
* (for example: deepseek-ai/deepseek-r1).
|
|
835
|
-
* @param
|
|
1004
|
+
* @param options Options for the call.
|
|
836
1005
|
*/
|
|
837
|
-
async delete(identifier,
|
|
1006
|
+
async delete(identifier, options) {
|
|
838
1007
|
const [owner, name] = this.parseModelIdentifier(identifier);
|
|
839
1008
|
await this.api.request(`${this.MODELS_API_PREFIX}/${owner}/${name}`, {
|
|
840
1009
|
method: 'DELETE',
|
|
841
|
-
signal,
|
|
1010
|
+
signal: options?.signal,
|
|
842
1011
|
});
|
|
843
1012
|
}
|
|
844
1013
|
/**
|
|
845
1014
|
* Create a model.
|
|
846
|
-
* @param
|
|
847
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1015
|
+
* @param params Parameters for creating a model.
|
|
848
1016
|
* @returns The new model.
|
|
849
1017
|
*/
|
|
850
|
-
async create(
|
|
1018
|
+
async create(params) {
|
|
1019
|
+
const { signal, ...body } = params;
|
|
851
1020
|
const response = await this.api.request(this.MODELS_API_PREFIX, {
|
|
852
1021
|
method: 'POST',
|
|
853
|
-
body
|
|
1022
|
+
body,
|
|
854
1023
|
signal,
|
|
855
1024
|
});
|
|
856
1025
|
return response;
|
|
@@ -859,14 +1028,14 @@ class Models extends Resource {
|
|
|
859
1028
|
* Get a model.
|
|
860
1029
|
* @param identifier The model identifier in owner/name format
|
|
861
1030
|
* (for example: deepseek-ai/deepseek-r1).
|
|
862
|
-
* @param
|
|
1031
|
+
* @param options Options for the call.
|
|
863
1032
|
* @returns A model object.
|
|
864
1033
|
*/
|
|
865
|
-
async get(identifier,
|
|
1034
|
+
async get(identifier, options) {
|
|
866
1035
|
const [owner, name] = this.parseModelIdentifier(identifier);
|
|
867
1036
|
const response = await this.api.request(`${this.MODELS_API_PREFIX}/${owner}/${name}`, {
|
|
868
1037
|
method: 'GET',
|
|
869
|
-
signal,
|
|
1038
|
+
signal: options?.signal,
|
|
870
1039
|
});
|
|
871
1040
|
return response;
|
|
872
1041
|
}
|
|
@@ -883,17 +1052,16 @@ class Models extends Resource {
|
|
|
883
1052
|
}
|
|
884
1053
|
/**
|
|
885
1054
|
* List models.
|
|
886
|
-
* @param options
|
|
887
|
-
*
|
|
888
|
-
* If not passed, all models are fetched.
|
|
889
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1055
|
+
* @param options Options for listing models. If no owner is given,
|
|
1056
|
+
* all models are listed.
|
|
890
1057
|
* @returns Paginated response containing models and navigation metadata.
|
|
891
1058
|
*/
|
|
892
|
-
async list(options
|
|
1059
|
+
async list(options) {
|
|
1060
|
+
const { owner, signal, ...query } = options ?? {};
|
|
893
1061
|
const path = this.buildListPath(owner);
|
|
894
1062
|
const response = await this.api.request(path, {
|
|
895
1063
|
method: 'GET',
|
|
896
|
-
params:
|
|
1064
|
+
params: query,
|
|
897
1065
|
signal,
|
|
898
1066
|
});
|
|
899
1067
|
return response;
|
|
@@ -902,15 +1070,15 @@ class Models extends Resource {
|
|
|
902
1070
|
* Update a model.
|
|
903
1071
|
* @param identifier The model identifier in owner/name format
|
|
904
1072
|
* (for example: deepseek-ai/deepseek-r1).
|
|
905
|
-
* @param params
|
|
906
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1073
|
+
* @param params Parameters for updating the model.
|
|
907
1074
|
* @returns The updated model.
|
|
908
1075
|
*/
|
|
909
|
-
async update(identifier, params
|
|
1076
|
+
async update(identifier, params) {
|
|
1077
|
+
const { signal, ...body } = params;
|
|
910
1078
|
const [owner, name] = this.parseModelIdentifier(identifier);
|
|
911
1079
|
const response = await this.api.request(`${this.MODELS_API_PREFIX}/${owner}/${name}`, {
|
|
912
1080
|
method: 'PATCH',
|
|
913
|
-
body
|
|
1081
|
+
body,
|
|
914
1082
|
signal,
|
|
915
1083
|
});
|
|
916
1084
|
return response;
|
|
@@ -918,15 +1086,12 @@ class Models extends Resource {
|
|
|
918
1086
|
/**
|
|
919
1087
|
* Search models.
|
|
920
1088
|
* @param q The search query.
|
|
921
|
-
* @param options
|
|
922
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1089
|
+
* @param options Options for the search.
|
|
923
1090
|
* @returns Paginated response containing models and navigation metadata.
|
|
924
1091
|
*/
|
|
925
|
-
async search(q, options
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
q,
|
|
929
|
-
};
|
|
1092
|
+
async search(q, options) {
|
|
1093
|
+
const { signal, ...query } = options ?? {};
|
|
1094
|
+
const params = { ...query, q };
|
|
930
1095
|
const response = await this.api.request(`${this.SEARCH_API_PREFIX}/models`, {
|
|
931
1096
|
method: 'GET',
|
|
932
1097
|
params: params,
|
|
@@ -951,23 +1116,23 @@ class Users extends Resource {
|
|
|
951
1116
|
/**
|
|
952
1117
|
* Fetch a user by their name.
|
|
953
1118
|
* @param name The name of the user.
|
|
954
|
-
* @param
|
|
1119
|
+
* @param options Options for the call.
|
|
955
1120
|
* @returns The user object.
|
|
956
1121
|
*/
|
|
957
|
-
async get(name,
|
|
958
|
-
const response = await this.api.request(`${this.API_PREFIX}/${name}`, { method: 'GET', signal });
|
|
1122
|
+
async get(name, options) {
|
|
1123
|
+
const response = await this.api.request(`${this.API_PREFIX}/${name}`, { method: 'GET', signal: options?.signal });
|
|
959
1124
|
return response;
|
|
960
1125
|
}
|
|
961
1126
|
/**
|
|
962
1127
|
* List users.
|
|
963
|
-
* @param options
|
|
964
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1128
|
+
* @param options Options for listing users.
|
|
965
1129
|
* @returns Paginated response containing users and navigation metadata.
|
|
966
1130
|
*/
|
|
967
|
-
async list(options
|
|
1131
|
+
async list(options) {
|
|
1132
|
+
const { signal, ...query } = options ?? {};
|
|
968
1133
|
const response = await this.api.request(this.API_PREFIX, {
|
|
969
1134
|
method: 'GET',
|
|
970
|
-
params:
|
|
1135
|
+
params: query,
|
|
971
1136
|
signal,
|
|
972
1137
|
});
|
|
973
1138
|
return response;
|
|
@@ -975,15 +1140,12 @@ class Users extends Resource {
|
|
|
975
1140
|
/**
|
|
976
1141
|
* Search users.
|
|
977
1142
|
* @param q The search query.
|
|
978
|
-
* @param options
|
|
979
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1143
|
+
* @param options Options for the search.
|
|
980
1144
|
* @returns Paginated response containing users and navigation metadata.
|
|
981
1145
|
*/
|
|
982
|
-
async search(q, options
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
q,
|
|
986
|
-
};
|
|
1146
|
+
async search(q, options) {
|
|
1147
|
+
const { signal, ...query } = options ?? {};
|
|
1148
|
+
const params = { ...query, q };
|
|
987
1149
|
const response = await this.api.request(`${this.SEARCH_API_PREFIX}/users`, {
|
|
988
1150
|
method: 'GET',
|
|
989
1151
|
params: params,
|
|
@@ -1048,16 +1210,11 @@ class WebhookTimestampOutsideToleranceError extends WebhookSignatureVerification
|
|
|
1048
1210
|
}
|
|
1049
1211
|
/**
|
|
1050
1212
|
* Verify webhook signature.
|
|
1051
|
-
* @param
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
1056
|
-
* @param scheme Key for signatures in the signature. Defaults to "v1".
|
|
1057
|
-
* @param keyCacheSize Maximum number of HMAC keys to keep in the
|
|
1058
|
-
* module-scoped cache. When exceeded, the oldest cached key is evicted.
|
|
1059
|
-
* This is a performance optimization only. Defaults to 50. Set to 0 or
|
|
1060
|
-
* a negative value to disable caching.
|
|
1213
|
+
* @param params Parameters for verifying the webhook signature.
|
|
1214
|
+
* `tolerance` defaults to 300, `scheme` defaults to "v1" and `keyCacheSize`
|
|
1215
|
+
* defaults to 50. When the cache size is exceeded, the oldest cached key is
|
|
1216
|
+
* evicted. The cache is a performance optimization only, and a size of 0 or
|
|
1217
|
+
* a negative value disables caching.
|
|
1061
1218
|
* @throws {WebhookNoTimestampError} Error thrown when the timestamp is
|
|
1062
1219
|
* missing from the signature.
|
|
1063
1220
|
* @throws {WebhookNoSignatureError} Error thrown when a signature
|
|
@@ -1067,7 +1224,8 @@ class WebhookTimestampOutsideToleranceError extends WebhookSignatureVerification
|
|
|
1067
1224
|
* @throws {WebhookTimestampOutsideToleranceError} Error thrown when the
|
|
1068
1225
|
* timestamp is outside the tolerance window.
|
|
1069
1226
|
*/
|
|
1070
|
-
async function verify(
|
|
1227
|
+
async function verify(params) {
|
|
1228
|
+
const { payload, signature, secret, tolerance = 300, scheme = 'v1', keyCacheSize = 50, } = params;
|
|
1071
1229
|
const { timestamp, matchedSignature } = parseSignature(signature, scheme);
|
|
1072
1230
|
verifyTimestamp(timestamp, tolerance);
|
|
1073
1231
|
const timestampBytes = textEncoder.encode(`${String(timestamp)}.`);
|
|
@@ -1249,40 +1407,40 @@ class AuthenticatedUser extends Resource {
|
|
|
1249
1407
|
API_PREFIX = '/user';
|
|
1250
1408
|
/**
|
|
1251
1409
|
* Get the authenticated user.
|
|
1252
|
-
* @param
|
|
1410
|
+
* @param options - Options for the call.
|
|
1253
1411
|
* @returns The user object.
|
|
1254
1412
|
*/
|
|
1255
|
-
async get(
|
|
1413
|
+
async get(options) {
|
|
1256
1414
|
const response = await this.api.request(this.API_PREFIX, {
|
|
1257
1415
|
method: 'GET',
|
|
1258
|
-
signal,
|
|
1416
|
+
signal: options?.signal,
|
|
1259
1417
|
});
|
|
1260
1418
|
return response;
|
|
1261
1419
|
}
|
|
1262
1420
|
/**
|
|
1263
1421
|
* Update the authenticated user.
|
|
1264
|
-
* @param params -
|
|
1265
|
-
* @param signal - Optional AbortSignal to cancel the request.
|
|
1422
|
+
* @param params - Parameters for updating the user.
|
|
1266
1423
|
* @returns The updated user object.
|
|
1267
1424
|
*/
|
|
1268
|
-
async update(params
|
|
1425
|
+
async update(params) {
|
|
1426
|
+
const { signal, ...body } = params;
|
|
1269
1427
|
const response = await this.api.request(this.API_PREFIX, {
|
|
1270
1428
|
method: 'PATCH',
|
|
1271
|
-
body
|
|
1429
|
+
body,
|
|
1272
1430
|
signal,
|
|
1273
1431
|
});
|
|
1274
1432
|
return response;
|
|
1275
1433
|
}
|
|
1276
1434
|
/**
|
|
1277
1435
|
* List models of the authenticated user.
|
|
1278
|
-
* @param options -
|
|
1279
|
-
* @param signal - Optional AbortSignal to cancel the request.
|
|
1436
|
+
* @param options - Options for listing models.
|
|
1280
1437
|
* @returns A paginated response containing models and navigation metadata.
|
|
1281
1438
|
*/
|
|
1282
|
-
async models(options
|
|
1439
|
+
async models(options) {
|
|
1440
|
+
const { signal, ...query } = options ?? {};
|
|
1283
1441
|
const response = await this.api.request(`${this.API_PREFIX}/models`, {
|
|
1284
1442
|
method: 'GET',
|
|
1285
|
-
params:
|
|
1443
|
+
params: query,
|
|
1286
1444
|
signal,
|
|
1287
1445
|
});
|
|
1288
1446
|
return response;
|
|
@@ -1295,14 +1453,14 @@ class AuthenticatedUser extends Resource {
|
|
|
1295
1453
|
class HardwareResource extends Resource {
|
|
1296
1454
|
/**
|
|
1297
1455
|
* List hardware.
|
|
1298
|
-
* @param options
|
|
1299
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1456
|
+
* @param options Options for listing hardware.
|
|
1300
1457
|
* @returns Paginated response containing hardware and navigation metadata.
|
|
1301
1458
|
*/
|
|
1302
|
-
async list(options
|
|
1459
|
+
async list(options) {
|
|
1460
|
+
const { signal, ...query } = options ?? {};
|
|
1303
1461
|
const response = await this.api.request('/hardware', {
|
|
1304
1462
|
method: 'GET',
|
|
1305
|
-
params:
|
|
1463
|
+
params: query,
|
|
1306
1464
|
signal,
|
|
1307
1465
|
});
|
|
1308
1466
|
return response;
|
|
@@ -1315,15 +1473,15 @@ class HardwareResource extends Resource {
|
|
|
1315
1473
|
class ModelCategories extends Resource {
|
|
1316
1474
|
/**
|
|
1317
1475
|
* List model categories.
|
|
1318
|
-
* @param options
|
|
1319
|
-
* @param signal Optional AbortSignal to cancel request.
|
|
1476
|
+
* @param options Options for listing model categories.
|
|
1320
1477
|
* @returns Paginated response containing model categories and
|
|
1321
1478
|
* navigation metadata.
|
|
1322
1479
|
*/
|
|
1323
|
-
async list(options
|
|
1480
|
+
async list(options) {
|
|
1481
|
+
const { signal, ...query } = options ?? {};
|
|
1324
1482
|
const response = await this.api.request('/model_categories', {
|
|
1325
1483
|
method: 'GET',
|
|
1326
|
-
params:
|
|
1484
|
+
params: query,
|
|
1327
1485
|
signal,
|
|
1328
1486
|
});
|
|
1329
1487
|
return response;
|
|
@@ -1338,13 +1496,13 @@ class Variables extends Resource {
|
|
|
1338
1496
|
/**
|
|
1339
1497
|
* Create a new variable.
|
|
1340
1498
|
* @param params Parameters for creating the variable.
|
|
1341
|
-
* @param signal Optional abort signal.
|
|
1342
1499
|
* @returns The created variable.
|
|
1343
1500
|
*/
|
|
1344
|
-
async create(params
|
|
1501
|
+
async create(params) {
|
|
1502
|
+
const { signal, ...body } = params;
|
|
1345
1503
|
const response = await this.api.request(this.VARIABLES_API_PREFIX, {
|
|
1346
1504
|
method: 'POST',
|
|
1347
|
-
body
|
|
1505
|
+
body,
|
|
1348
1506
|
signal,
|
|
1349
1507
|
});
|
|
1350
1508
|
return response;
|
|
@@ -1352,39 +1510,39 @@ class Variables extends Resource {
|
|
|
1352
1510
|
/**
|
|
1353
1511
|
* Delete a variable.
|
|
1354
1512
|
* @param name The name of the variable to be deleted.
|
|
1355
|
-
* @param
|
|
1513
|
+
* @param options Options for the call.
|
|
1356
1514
|
*/
|
|
1357
|
-
async delete(name,
|
|
1515
|
+
async delete(name, options) {
|
|
1358
1516
|
await this.api.request(`${this.VARIABLES_API_PREFIX}/${name}`, {
|
|
1359
1517
|
method: 'DELETE',
|
|
1360
|
-
signal,
|
|
1518
|
+
signal: options?.signal,
|
|
1361
1519
|
});
|
|
1362
1520
|
}
|
|
1363
1521
|
/**
|
|
1364
1522
|
* Update a variable.
|
|
1365
1523
|
* @param name The name of the variable to be updated.
|
|
1366
1524
|
* @param params The parameters for updating the variable.
|
|
1367
|
-
* @param signal Optional abort signal.
|
|
1368
1525
|
* @returns The updated variable.
|
|
1369
1526
|
*/
|
|
1370
|
-
async update(name, params
|
|
1527
|
+
async update(name, params) {
|
|
1528
|
+
const { signal, ...body } = params;
|
|
1371
1529
|
const response = await this.api.request(`${this.VARIABLES_API_PREFIX}/${name}`, {
|
|
1372
1530
|
method: 'PATCH',
|
|
1373
|
-
body
|
|
1531
|
+
body,
|
|
1374
1532
|
signal,
|
|
1375
1533
|
});
|
|
1376
1534
|
return response;
|
|
1377
1535
|
}
|
|
1378
1536
|
/**
|
|
1379
1537
|
* List variables.
|
|
1380
|
-
* @param options
|
|
1381
|
-
* @param signal Optional abort signal.
|
|
1538
|
+
* @param options Options for listing variables.
|
|
1382
1539
|
* @returns Paginated response containing variables and navigation metadata.
|
|
1383
1540
|
*/
|
|
1384
|
-
async list(options
|
|
1541
|
+
async list(options) {
|
|
1542
|
+
const { signal, ...query } = options ?? {};
|
|
1385
1543
|
const response = await this.api.request(this.VARIABLES_API_PREFIX, {
|
|
1386
1544
|
method: 'GET',
|
|
1387
|
-
params:
|
|
1545
|
+
params: query,
|
|
1388
1546
|
signal,
|
|
1389
1547
|
});
|
|
1390
1548
|
return response;
|
|
@@ -1399,13 +1557,13 @@ class Uploads extends Resource {
|
|
|
1399
1557
|
/**
|
|
1400
1558
|
* Create an upload.
|
|
1401
1559
|
* @param params Upload creation parameters.
|
|
1402
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1403
1560
|
* @returns The new upload.
|
|
1404
1561
|
*/
|
|
1405
|
-
async create(params
|
|
1562
|
+
async create(params) {
|
|
1563
|
+
const { signal, ...body } = params;
|
|
1406
1564
|
const response = await this.api.request(this.UPLOADS_API_PREFIX, {
|
|
1407
1565
|
method: 'POST',
|
|
1408
|
-
body
|
|
1566
|
+
body,
|
|
1409
1567
|
signal,
|
|
1410
1568
|
});
|
|
1411
1569
|
return response;
|
|
@@ -1414,13 +1572,13 @@ class Uploads extends Resource {
|
|
|
1414
1572
|
* Complete an upload.
|
|
1415
1573
|
* @param id The unique identifier of the upload.
|
|
1416
1574
|
* @param params Parameters to complete an upload.
|
|
1417
|
-
* @param signal Optional AbortSignal to cancel the request.
|
|
1418
1575
|
* @returns The completion result.
|
|
1419
1576
|
*/
|
|
1420
|
-
async complete(id, params
|
|
1577
|
+
async complete(id, params) {
|
|
1578
|
+
const { signal, ...body } = params;
|
|
1421
1579
|
const response = await this.api.request(`${this.UPLOADS_API_PREFIX}/${id}/complete`, {
|
|
1422
1580
|
method: 'POST',
|
|
1423
|
-
body
|
|
1581
|
+
body,
|
|
1424
1582
|
signal,
|
|
1425
1583
|
});
|
|
1426
1584
|
return response;
|
|
@@ -1515,7 +1673,7 @@ class WriftAI {
|
|
|
1515
1673
|
// Window" errors).
|
|
1516
1674
|
const fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1517
1675
|
const defaultHeaders = {
|
|
1518
|
-
'User-Agent': 'wriftai-javascript/' + "0.
|
|
1676
|
+
'User-Agent': 'wriftai-javascript/' + "0.56.0",
|
|
1519
1677
|
...options.headers,
|
|
1520
1678
|
};
|
|
1521
1679
|
this.api = new API(apiBaseUrl, fetchImpl, maxRetries, accessToken, defaultHeaders);
|
|
@@ -1532,5 +1690,5 @@ class WriftAI {
|
|
|
1532
1690
|
}
|
|
1533
1691
|
}
|
|
1534
1692
|
|
|
1535
|
-
export { DEFAULT_WAIT_OPTIONS, ErrorSource, FileData, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
|
|
1693
|
+
export { DEFAULT_CREATE_WAIT_OPTIONS, DEFAULT_WAIT_OPTIONS, ErrorSource, FileData, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
|
|
1536
1694
|
//# sourceMappingURL=index.mjs.map
|