hume 0.2.7 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.d.ts +11 -0
- package/Client.js +42 -7
- package/api/client/requests/ListJobsRequest.d.ts +9 -0
- package/api/types/FaceModelConfig.d.ts +4 -17
- package/api/types/ModelConfig.d.ts +0 -5
- package/api/types/ModelsInput.d.ts +1 -9
- package/api/types/TextPosition.d.ts +0 -1
- package/api/types/index.d.ts +11 -11
- package/api/types/index.js +11 -11
- package/core/fetcher/APIResponse.d.ts +1 -0
- package/core/fetcher/Fetcher.d.ts +1 -4
- package/core/fetcher/Fetcher.js +52 -31
- package/core/fetcher/getHeader.d.ts +1 -0
- package/{dist/core/streaming-fetcher → core/fetcher}/getHeader.js +2 -2
- package/core/fetcher/index.d.ts +1 -0
- package/core/fetcher/index.js +3 -1
- package/core/index.d.ts +0 -1
- package/core/index.js +0 -1
- package/dist/Client.d.ts +11 -0
- package/dist/Client.js +42 -7
- package/dist/api/client/requests/ListJobsRequest.d.ts +9 -0
- package/dist/api/types/FaceModelConfig.d.ts +4 -17
- package/dist/api/types/ModelConfig.d.ts +0 -5
- package/dist/api/types/ModelsInput.d.ts +1 -9
- package/dist/api/types/TextPosition.d.ts +0 -1
- package/dist/api/types/index.d.ts +11 -11
- package/dist/api/types/index.js +11 -11
- package/dist/core/fetcher/APIResponse.d.ts +1 -0
- package/dist/core/fetcher/Fetcher.d.ts +1 -4
- package/dist/core/fetcher/Fetcher.js +52 -31
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/{core/streaming-fetcher → dist/core/fetcher}/getHeader.js +2 -2
- package/dist/core/fetcher/index.d.ts +1 -0
- package/dist/core/fetcher/index.js +3 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +0 -1
- package/dist/serialization/types/index.d.ts +11 -11
- package/dist/serialization/types/index.js +11 -11
- package/package.json +6 -4
- package/serialization/types/index.d.ts +11 -11
- package/serialization/types/index.js +11 -11
- package/core/streaming-fetcher/Stream.d.ts +0 -14
- package/core/streaming-fetcher/Stream.js +0 -75
- package/core/streaming-fetcher/StreamingFetcher.d.ts +0 -24
- package/core/streaming-fetcher/StreamingFetcher.js +0 -58
- package/core/streaming-fetcher/getHeader.d.ts +0 -2
- package/core/streaming-fetcher/index.d.ts +0 -4
- package/core/streaming-fetcher/index.js +0 -9
- package/dist/core/streaming-fetcher/Stream.d.ts +0 -14
- package/dist/core/streaming-fetcher/Stream.js +0 -75
- package/dist/core/streaming-fetcher/StreamingFetcher.d.ts +0 -24
- package/dist/core/streaming-fetcher/StreamingFetcher.js +0 -58
- package/dist/core/streaming-fetcher/getHeader.d.ts +0 -2
- package/dist/core/streaming-fetcher/index.d.ts +0 -4
- package/dist/core/streaming-fetcher/index.js +0 -9
package/dist/Client.js
CHANGED
|
@@ -50,6 +50,14 @@ class HumeClient {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Sort and filter jobs.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* await hume.listJobs({
|
|
56
|
+
* status: Hume.Status.Queued,
|
|
57
|
+
* when: Hume.When.CreatedBefore,
|
|
58
|
+
* sortBy: Hume.SortBy.Created,
|
|
59
|
+
* direction: Hume.Direction.Asc
|
|
60
|
+
* })
|
|
53
61
|
*/
|
|
54
62
|
listJobs(request = {}, requestOptions) {
|
|
55
63
|
var _a;
|
|
@@ -86,7 +94,7 @@ class HumeClient {
|
|
|
86
94
|
"X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
|
|
87
95
|
"X-Fern-Language": "JavaScript",
|
|
88
96
|
"X-Fern-SDK-Name": "hume",
|
|
89
|
-
"X-Fern-SDK-Version": "0.
|
|
97
|
+
"X-Fern-SDK-Version": "0.3.1",
|
|
90
98
|
},
|
|
91
99
|
contentType: "application/json",
|
|
92
100
|
queryParameters: _queryParams,
|
|
@@ -135,7 +143,7 @@ class HumeClient {
|
|
|
135
143
|
"X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
|
|
136
144
|
"X-Fern-Language": "JavaScript",
|
|
137
145
|
"X-Fern-SDK-Name": "hume",
|
|
138
|
-
"X-Fern-SDK-Version": "0.
|
|
146
|
+
"X-Fern-SDK-Version": "0.3.1",
|
|
139
147
|
},
|
|
140
148
|
contentType: "application/json",
|
|
141
149
|
body: yield serializers.BaseRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -173,6 +181,9 @@ class HumeClient {
|
|
|
173
181
|
}
|
|
174
182
|
/**
|
|
175
183
|
* Get the JSON predictions of a completed job.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* await hume.getJobPredictions("id")
|
|
176
187
|
*/
|
|
177
188
|
getJobPredictions(id, requestOptions) {
|
|
178
189
|
var _a;
|
|
@@ -184,7 +195,7 @@ class HumeClient {
|
|
|
184
195
|
"X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
|
|
185
196
|
"X-Fern-Language": "JavaScript",
|
|
186
197
|
"X-Fern-SDK-Name": "hume",
|
|
187
|
-
"X-Fern-SDK-Version": "0.
|
|
198
|
+
"X-Fern-SDK-Version": "0.3.1",
|
|
188
199
|
},
|
|
189
200
|
contentType: "application/json",
|
|
190
201
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -225,18 +236,42 @@ class HumeClient {
|
|
|
225
236
|
getJobArtifacts(id, requestOptions) {
|
|
226
237
|
var _a;
|
|
227
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
const _response = yield core.
|
|
239
|
+
const _response = yield core.fetcher({
|
|
229
240
|
url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Default, `v0/batch/jobs/${id}/artifacts`),
|
|
230
241
|
method: "GET",
|
|
231
242
|
headers: {
|
|
232
243
|
"X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
|
|
233
244
|
"X-Fern-Language": "JavaScript",
|
|
234
245
|
"X-Fern-SDK-Name": "hume",
|
|
235
|
-
"X-Fern-SDK-Version": "0.
|
|
246
|
+
"X-Fern-SDK-Version": "0.3.1",
|
|
236
247
|
},
|
|
248
|
+
contentType: "application/json",
|
|
249
|
+
responseType: "streaming",
|
|
237
250
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
251
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
238
252
|
});
|
|
239
|
-
|
|
253
|
+
if (_response.ok) {
|
|
254
|
+
return _response.body;
|
|
255
|
+
}
|
|
256
|
+
if (_response.error.reason === "status-code") {
|
|
257
|
+
throw new errors.HumeError({
|
|
258
|
+
statusCode: _response.error.statusCode,
|
|
259
|
+
body: _response.error.body,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
switch (_response.error.reason) {
|
|
263
|
+
case "non-json":
|
|
264
|
+
throw new errors.HumeError({
|
|
265
|
+
statusCode: _response.error.statusCode,
|
|
266
|
+
body: _response.error.rawBody,
|
|
267
|
+
});
|
|
268
|
+
case "timeout":
|
|
269
|
+
throw new errors.HumeTimeoutError();
|
|
270
|
+
case "unknown":
|
|
271
|
+
throw new errors.HumeError({
|
|
272
|
+
message: _response.error.errorMessage,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
240
275
|
});
|
|
241
276
|
}
|
|
242
277
|
/**
|
|
@@ -252,7 +287,7 @@ class HumeClient {
|
|
|
252
287
|
"X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
|
|
253
288
|
"X-Fern-Language": "JavaScript",
|
|
254
289
|
"X-Fern-SDK-Name": "hume",
|
|
255
|
-
"X-Fern-SDK-Version": "0.
|
|
290
|
+
"X-Fern-SDK-Version": "0.3.1",
|
|
256
291
|
},
|
|
257
292
|
contentType: "application/json",
|
|
258
293
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
import * as Hume from "../..";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* status: Hume.Status.Queued,
|
|
9
|
+
* when: Hume.When.CreatedBefore,
|
|
10
|
+
* sortBy: Hume.SortBy.Created,
|
|
11
|
+
* direction: Hume.Direction.Asc
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
5
14
|
export interface ListJobsRequest {
|
|
6
15
|
/**
|
|
7
16
|
* The maximum number of jobs to include in the response.
|
|
@@ -5,31 +5,18 @@
|
|
|
5
5
|
* Configuration for the facial expression emotion model.
|
|
6
6
|
*
|
|
7
7
|
* Note: Using the `reset_stream` parameter does not have any effect on face identification. A single face identifier cache is maintained over a full session whether `reset_stream` is used or not.
|
|
8
|
-
*
|
|
9
8
|
*/
|
|
10
9
|
export interface FaceModelConfig {
|
|
11
10
|
/** Configuration for FACS predictions. If missing or null, no FACS predictions will be generated. */
|
|
12
11
|
facs?: Record<string, unknown>;
|
|
13
12
|
/** Configuration for Descriptions predictions. If missing or null, no Descriptions predictions will be generated. */
|
|
14
13
|
descriptions?: Record<string, unknown>;
|
|
15
|
-
/**
|
|
16
|
-
* Whether to return identifiers for faces across frames. If true, unique identifiers will be assigned to face bounding boxes to differentiate different faces. If false, all faces will be tagged with an "unknown" ID.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
14
|
+
/** Whether to return identifiers for faces across frames. If true, unique identifiers will be assigned to face bounding boxes to differentiate different faces. If false, all faces will be tagged with an "unknown" ID. */
|
|
19
15
|
identifyFaces?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Number of frames per second to process. Other frames will be omitted from the response.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
16
|
+
/** Number of frames per second to process. Other frames will be omitted from the response. */
|
|
24
17
|
fpsPred?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Face detection probability threshold. Faces detected with a probability less than this threshold will be omitted from the response.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
18
|
+
/** Face detection probability threshold. Faces detected with a probability less than this threshold will be omitted from the response. */
|
|
29
19
|
probThreshold?: number;
|
|
30
|
-
/**
|
|
31
|
-
* Minimum bounding box side length in pixels to treat as a face. Faces detected with a bounding box side length in pixels less than this threshold will be omitted from the response.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
20
|
+
/** Minimum bounding box side length in pixels to treat as a face. Faces detected with a bounding box side length in pixels less than this threshold will be omitted from the response. */
|
|
34
21
|
minFaceSize?: number;
|
|
35
22
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import * as Hume from "..";
|
|
5
5
|
/**
|
|
6
6
|
* Configuration used to specify which models should be used and with what settings.
|
|
7
|
-
*
|
|
8
7
|
*/
|
|
9
8
|
export interface ModelConfig {
|
|
10
9
|
/**
|
|
@@ -13,14 +12,12 @@ export interface ModelConfig {
|
|
|
13
12
|
* Note: Model configuration is not currently available in streaming.
|
|
14
13
|
*
|
|
15
14
|
* Please use the default configuration by passing an empty object `{}`.
|
|
16
|
-
*
|
|
17
15
|
*/
|
|
18
16
|
burst?: Record<string, unknown>;
|
|
19
17
|
/**
|
|
20
18
|
* Configuration for the facial expression emotion model.
|
|
21
19
|
*
|
|
22
20
|
* Note: Using the `reset_stream` parameter does not have any effect on face identification. A single face identifier cache is maintained over a full session whether `reset_stream` is used or not.
|
|
23
|
-
*
|
|
24
21
|
*/
|
|
25
22
|
face?: Hume.FaceModelConfig;
|
|
26
23
|
/**
|
|
@@ -29,7 +26,6 @@ export interface ModelConfig {
|
|
|
29
26
|
* Note: Model configuration is not currently available in streaming.
|
|
30
27
|
*
|
|
31
28
|
* Please use the default configuration by passing an empty object `{}`.
|
|
32
|
-
*
|
|
33
29
|
*/
|
|
34
30
|
facemesh?: Record<string, unknown>;
|
|
35
31
|
/** Configuration for the language emotion model. */
|
|
@@ -40,7 +36,6 @@ export interface ModelConfig {
|
|
|
40
36
|
* Note: Model configuration is not currently available in streaming.
|
|
41
37
|
*
|
|
42
38
|
* Please use the default configuration by passing an empty object `{}`.
|
|
43
|
-
*
|
|
44
39
|
*/
|
|
45
40
|
prosody?: Record<string, unknown>;
|
|
46
41
|
}
|
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
import * as Hume from "..";
|
|
5
5
|
export interface ModelsInput {
|
|
6
6
|
data?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Configuration used to specify which models should be used and with what settings.
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
7
|
+
/** Configuration used to specify which models should be used and with what settings. */
|
|
11
8
|
models?: Hume.ModelConfig;
|
|
12
9
|
/**
|
|
13
10
|
* Length in milliseconds of streaming sliding window.
|
|
@@ -19,7 +16,6 @@ export interface ModelsInput {
|
|
|
19
16
|
* A window of 600ms would append the full 500ms of the second payload to the last 100ms of the first payload.
|
|
20
17
|
*
|
|
21
18
|
* Note: This feature is currently only supported for audio data and audio models. For other file types and models this parameter will be ignored.
|
|
22
|
-
*
|
|
23
19
|
*/
|
|
24
20
|
streamWindowMs?: number;
|
|
25
21
|
/**
|
|
@@ -28,13 +24,11 @@ export interface ModelsInput {
|
|
|
28
24
|
* If this parameter is set to `true` then past context will be deleted before processing the current payload.
|
|
29
25
|
*
|
|
30
26
|
* Use reset_stream when one audio file is done being processed and you do not want context to leak across files.
|
|
31
|
-
*
|
|
32
27
|
*/
|
|
33
28
|
resetStream?: boolean;
|
|
34
29
|
/**
|
|
35
30
|
* Set to `true` to enable the data parameter to be parsed as raw text rather than base64 encoded bytes.
|
|
36
31
|
* This parameter is useful if you want to send text to be processed by the language model, but it cannot be used with other file types like audio, image, or video.
|
|
37
|
-
*
|
|
38
32
|
*/
|
|
39
33
|
rawText?: boolean;
|
|
40
34
|
/**
|
|
@@ -43,14 +37,12 @@ export interface ModelsInput {
|
|
|
43
37
|
* This parameter can be set in the same payload as data or it can be set without data and models configuration to get the job details between payloads.
|
|
44
38
|
*
|
|
45
39
|
* This parameter is useful to get the unique job ID.
|
|
46
|
-
*
|
|
47
40
|
*/
|
|
48
41
|
jobDetails?: boolean;
|
|
49
42
|
/**
|
|
50
43
|
* Pass an arbitrary string as the payload ID and get it back at the top level of the socket response.
|
|
51
44
|
*
|
|
52
45
|
* This can be useful if you have multiple requests running asynchronously and want to disambiguate responses as they are received.
|
|
53
|
-
*
|
|
54
46
|
*/
|
|
55
47
|
payloadId?: string;
|
|
56
48
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Position of a segment of text within a larger document, measured in characters. Uses zero-based indexing. The beginning index is inclusive and the end index is exclusive.
|
|
6
|
-
*
|
|
7
6
|
*/
|
|
8
7
|
export interface TextPosition {
|
|
9
8
|
/** The index of the first character in the text segment, inclusive. */
|
|
@@ -62,28 +62,28 @@ export * from "./TranscriptionMetadata";
|
|
|
62
62
|
export * from "./Url";
|
|
63
63
|
export * from "./When";
|
|
64
64
|
export * from "./Window";
|
|
65
|
-
export * from "./ModelsInput";
|
|
66
|
-
export * from "./ModelConfig";
|
|
67
65
|
export * from "./FaceModelConfig";
|
|
68
66
|
export * from "./LanguageConfig";
|
|
69
|
-
export * from "./
|
|
70
|
-
export * from "./
|
|
67
|
+
export * from "./ModelConfig";
|
|
68
|
+
export * from "./ModelsInput";
|
|
71
69
|
export * from "./ModelsSuccessBurstPredictionsItem";
|
|
72
|
-
export * from "./
|
|
70
|
+
export * from "./BurstResponse";
|
|
73
71
|
export * from "./ModelsSuccessFacePredictionsItem";
|
|
74
|
-
export * from "./
|
|
72
|
+
export * from "./FaceResponse";
|
|
75
73
|
export * from "./ModelsSuccessFacemeshPredictionsItem";
|
|
76
|
-
export * from "./
|
|
74
|
+
export * from "./FacemeshResponse";
|
|
77
75
|
export * from "./ModelsSuccessLanguagePredictionsItem";
|
|
78
|
-
export * from "./
|
|
76
|
+
export * from "./LanguageResponse";
|
|
79
77
|
export * from "./ModelsSuccessProsodyPredictionsItem";
|
|
78
|
+
export * from "./ProsodyResponse";
|
|
79
|
+
export * from "./ModelResponse";
|
|
80
80
|
export * from "./ModelsError";
|
|
81
81
|
export * from "./ModelsWarning";
|
|
82
|
-
export * from "./EmotionEmbedding";
|
|
83
82
|
export * from "./EmotionEmbeddingItem";
|
|
83
|
+
export * from "./EmotionEmbedding";
|
|
84
84
|
export * from "./TimeRange";
|
|
85
85
|
export * from "./TextPosition";
|
|
86
|
-
export * from "./Sentiment";
|
|
87
86
|
export * from "./SentimentItem";
|
|
88
|
-
export * from "./
|
|
87
|
+
export * from "./Sentiment";
|
|
89
88
|
export * from "./ToxicityItem";
|
|
89
|
+
export * from "./Toxicity";
|
package/dist/api/types/index.js
CHANGED
|
@@ -78,28 +78,28 @@ __exportStar(require("./TranscriptionMetadata"), exports);
|
|
|
78
78
|
__exportStar(require("./Url"), exports);
|
|
79
79
|
__exportStar(require("./When"), exports);
|
|
80
80
|
__exportStar(require("./Window"), exports);
|
|
81
|
-
__exportStar(require("./ModelsInput"), exports);
|
|
82
|
-
__exportStar(require("./ModelConfig"), exports);
|
|
83
81
|
__exportStar(require("./FaceModelConfig"), exports);
|
|
84
82
|
__exportStar(require("./LanguageConfig"), exports);
|
|
85
|
-
__exportStar(require("./
|
|
86
|
-
__exportStar(require("./
|
|
83
|
+
__exportStar(require("./ModelConfig"), exports);
|
|
84
|
+
__exportStar(require("./ModelsInput"), exports);
|
|
87
85
|
__exportStar(require("./ModelsSuccessBurstPredictionsItem"), exports);
|
|
88
|
-
__exportStar(require("./
|
|
86
|
+
__exportStar(require("./BurstResponse"), exports);
|
|
89
87
|
__exportStar(require("./ModelsSuccessFacePredictionsItem"), exports);
|
|
90
|
-
__exportStar(require("./
|
|
88
|
+
__exportStar(require("./FaceResponse"), exports);
|
|
91
89
|
__exportStar(require("./ModelsSuccessFacemeshPredictionsItem"), exports);
|
|
92
|
-
__exportStar(require("./
|
|
90
|
+
__exportStar(require("./FacemeshResponse"), exports);
|
|
93
91
|
__exportStar(require("./ModelsSuccessLanguagePredictionsItem"), exports);
|
|
94
|
-
__exportStar(require("./
|
|
92
|
+
__exportStar(require("./LanguageResponse"), exports);
|
|
95
93
|
__exportStar(require("./ModelsSuccessProsodyPredictionsItem"), exports);
|
|
94
|
+
__exportStar(require("./ProsodyResponse"), exports);
|
|
95
|
+
__exportStar(require("./ModelResponse"), exports);
|
|
96
96
|
__exportStar(require("./ModelsError"), exports);
|
|
97
97
|
__exportStar(require("./ModelsWarning"), exports);
|
|
98
|
-
__exportStar(require("./EmotionEmbedding"), exports);
|
|
99
98
|
__exportStar(require("./EmotionEmbeddingItem"), exports);
|
|
99
|
+
__exportStar(require("./EmotionEmbedding"), exports);
|
|
100
100
|
__exportStar(require("./TimeRange"), exports);
|
|
101
101
|
__exportStar(require("./TextPosition"), exports);
|
|
102
|
-
__exportStar(require("./Sentiment"), exports);
|
|
103
102
|
__exportStar(require("./SentimentItem"), exports);
|
|
104
|
-
__exportStar(require("./
|
|
103
|
+
__exportStar(require("./Sentiment"), exports);
|
|
105
104
|
__exportStar(require("./ToxicityItem"), exports);
|
|
105
|
+
__exportStar(require("./Toxicity"), exports);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AxiosAdapter } from "axios";
|
|
2
1
|
import { APIResponse } from "./APIResponse";
|
|
3
2
|
export declare type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
4
3
|
export declare namespace Fetcher {
|
|
@@ -12,9 +11,7 @@ export declare namespace Fetcher {
|
|
|
12
11
|
timeoutMs?: number;
|
|
13
12
|
maxRetries?: number;
|
|
14
13
|
withCredentials?: boolean;
|
|
15
|
-
responseType?: "json" | "blob";
|
|
16
|
-
adapter?: AxiosAdapter;
|
|
17
|
-
onUploadProgress?: (event: ProgressEvent) => void;
|
|
14
|
+
responseType?: "json" | "blob" | "streaming";
|
|
18
15
|
}
|
|
19
16
|
type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
|
|
20
17
|
interface FailedStatusCodeError {
|
|
@@ -13,8 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.fetcher = void 0;
|
|
16
|
-
const
|
|
16
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
17
17
|
const qs_1 = __importDefault(require("qs"));
|
|
18
|
+
if (typeof window === "undefined") {
|
|
19
|
+
global.fetch = require("node-fetch");
|
|
20
|
+
}
|
|
18
21
|
const INITIAL_RETRY_DELAY = 1;
|
|
19
22
|
const MAX_RETRY_DELAY = 60;
|
|
20
23
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -32,60 +35,68 @@ function fetcherImpl(args) {
|
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
}
|
|
38
|
+
const url = Object.keys((_a = args.queryParameters) !== null && _a !== void 0 ? _a : {}).length > 0
|
|
39
|
+
? `${args.url}?${qs_1.default.stringify(args.queryParameters, { arrayFormat: "repeat" })}`
|
|
40
|
+
: args.url;
|
|
41
|
+
let body = undefined;
|
|
42
|
+
if (args.body instanceof form_data_1.default) {
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
body = args.body;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
body = JSON.stringify(args.body);
|
|
48
|
+
}
|
|
35
49
|
const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
50
|
+
const controller = new AbortController();
|
|
51
|
+
let abortId = undefined;
|
|
52
|
+
if (args.timeoutMs != null) {
|
|
53
|
+
abortId = setTimeout(() => controller.abort(), args.timeoutMs);
|
|
54
|
+
}
|
|
55
|
+
const response = yield fetch(url, {
|
|
43
56
|
method: args.method,
|
|
44
57
|
headers,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
timeout: args.timeoutMs,
|
|
49
|
-
transitional: {
|
|
50
|
-
clarifyTimeoutError: true,
|
|
51
|
-
},
|
|
52
|
-
withCredentials: args.withCredentials,
|
|
53
|
-
adapter: args.adapter,
|
|
54
|
-
onUploadProgress: args.onUploadProgress,
|
|
55
|
-
maxBodyLength: Infinity,
|
|
56
|
-
maxContentLength: Infinity,
|
|
57
|
-
responseType: (_d = args.responseType) !== null && _d !== void 0 ? _d : "json",
|
|
58
|
+
body,
|
|
59
|
+
signal: controller.signal,
|
|
60
|
+
credentials: args.withCredentials ? "same-origin" : undefined,
|
|
58
61
|
});
|
|
62
|
+
if (abortId != null) {
|
|
63
|
+
clearTimeout(abortId);
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
59
66
|
});
|
|
60
67
|
try {
|
|
61
68
|
let response = yield makeRequest();
|
|
62
|
-
for (let i = 0; i < ((
|
|
69
|
+
for (let i = 0; i < ((_b = args.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_MAX_RETRIES); ++i) {
|
|
63
70
|
if (response.status === 408 ||
|
|
64
71
|
response.status === 409 ||
|
|
65
72
|
response.status === 429 ||
|
|
66
73
|
response.status >= 500) {
|
|
67
74
|
const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(i, 2), MAX_RETRY_DELAY);
|
|
68
|
-
|
|
75
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
76
|
+
response = yield makeRequest();
|
|
69
77
|
}
|
|
70
78
|
else {
|
|
71
79
|
break;
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
82
|
let body;
|
|
75
|
-
if (args.responseType === "blob") {
|
|
76
|
-
body = response.
|
|
83
|
+
if (response.body != null && args.responseType === "blob") {
|
|
84
|
+
body = yield response.blob();
|
|
77
85
|
}
|
|
78
|
-
else if (response.
|
|
86
|
+
else if (response.body != null && args.responseType === "streaming") {
|
|
87
|
+
body = response.body;
|
|
88
|
+
}
|
|
89
|
+
else if (response.body != null) {
|
|
79
90
|
try {
|
|
80
|
-
body =
|
|
91
|
+
body = yield response.json();
|
|
81
92
|
}
|
|
82
|
-
catch (
|
|
93
|
+
catch (err) {
|
|
83
94
|
return {
|
|
84
95
|
ok: false,
|
|
85
96
|
error: {
|
|
86
97
|
reason: "non-json",
|
|
87
98
|
statusCode: response.status,
|
|
88
|
-
rawBody: response.
|
|
99
|
+
rawBody: yield response.text(),
|
|
89
100
|
},
|
|
90
101
|
};
|
|
91
102
|
}
|
|
@@ -94,6 +105,7 @@ function fetcherImpl(args) {
|
|
|
94
105
|
return {
|
|
95
106
|
ok: true,
|
|
96
107
|
body: body,
|
|
108
|
+
headers: response.headers,
|
|
97
109
|
};
|
|
98
110
|
}
|
|
99
111
|
else {
|
|
@@ -108,7 +120,7 @@ function fetcherImpl(args) {
|
|
|
108
120
|
}
|
|
109
121
|
}
|
|
110
122
|
catch (error) {
|
|
111
|
-
if (error.
|
|
123
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
112
124
|
return {
|
|
113
125
|
ok: false,
|
|
114
126
|
error: {
|
|
@@ -116,11 +128,20 @@ function fetcherImpl(args) {
|
|
|
116
128
|
},
|
|
117
129
|
};
|
|
118
130
|
}
|
|
131
|
+
else if (error instanceof Error) {
|
|
132
|
+
return {
|
|
133
|
+
ok: false,
|
|
134
|
+
error: {
|
|
135
|
+
reason: "unknown",
|
|
136
|
+
errorMessage: error.message,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
119
140
|
return {
|
|
120
141
|
ok: false,
|
|
121
142
|
error: {
|
|
122
143
|
reason: "unknown",
|
|
123
|
-
errorMessage: error
|
|
144
|
+
errorMessage: JSON.stringify(error),
|
|
124
145
|
},
|
|
125
146
|
};
|
|
126
147
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getHeader(headers: Record<string, any>, header: string): string | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getHeader = void 0;
|
|
4
|
-
function getHeader(
|
|
5
|
-
for (const [headerKey, headerValue] of Object.entries(
|
|
4
|
+
function getHeader(headers, header) {
|
|
5
|
+
for (const [headerKey, headerValue] of Object.entries(headers)) {
|
|
6
6
|
if (headerKey.toLowerCase() === header.toLowerCase()) {
|
|
7
7
|
return headerValue;
|
|
8
8
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Supplier = exports.fetcher = void 0;
|
|
3
|
+
exports.Supplier = exports.getHeader = exports.fetcher = void 0;
|
|
4
4
|
var Fetcher_1 = require("./Fetcher");
|
|
5
5
|
Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return Fetcher_1.fetcher; } });
|
|
6
|
+
var getHeader_1 = require("./getHeader");
|
|
7
|
+
Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_1.getHeader; } });
|
|
6
8
|
var Supplier_1 = require("./Supplier");
|
|
7
9
|
Object.defineProperty(exports, "Supplier", { enumerable: true, get: function () { return Supplier_1.Supplier; } });
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -28,5 +28,4 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.serialization = void 0;
|
|
30
30
|
__exportStar(require("./fetcher"), exports);
|
|
31
|
-
__exportStar(require("./streaming-fetcher"), exports);
|
|
32
31
|
exports.serialization = __importStar(require("./schemas"));
|
|
@@ -62,28 +62,28 @@ export * from "./TranscriptionMetadata";
|
|
|
62
62
|
export * from "./Url";
|
|
63
63
|
export * from "./When";
|
|
64
64
|
export * from "./Window";
|
|
65
|
-
export * from "./ModelsInput";
|
|
66
|
-
export * from "./ModelConfig";
|
|
67
65
|
export * from "./FaceModelConfig";
|
|
68
66
|
export * from "./LanguageConfig";
|
|
69
|
-
export * from "./
|
|
70
|
-
export * from "./
|
|
67
|
+
export * from "./ModelConfig";
|
|
68
|
+
export * from "./ModelsInput";
|
|
71
69
|
export * from "./ModelsSuccessBurstPredictionsItem";
|
|
72
|
-
export * from "./
|
|
70
|
+
export * from "./BurstResponse";
|
|
73
71
|
export * from "./ModelsSuccessFacePredictionsItem";
|
|
74
|
-
export * from "./
|
|
72
|
+
export * from "./FaceResponse";
|
|
75
73
|
export * from "./ModelsSuccessFacemeshPredictionsItem";
|
|
76
|
-
export * from "./
|
|
74
|
+
export * from "./FacemeshResponse";
|
|
77
75
|
export * from "./ModelsSuccessLanguagePredictionsItem";
|
|
78
|
-
export * from "./
|
|
76
|
+
export * from "./LanguageResponse";
|
|
79
77
|
export * from "./ModelsSuccessProsodyPredictionsItem";
|
|
78
|
+
export * from "./ProsodyResponse";
|
|
79
|
+
export * from "./ModelResponse";
|
|
80
80
|
export * from "./ModelsError";
|
|
81
81
|
export * from "./ModelsWarning";
|
|
82
|
-
export * from "./EmotionEmbedding";
|
|
83
82
|
export * from "./EmotionEmbeddingItem";
|
|
83
|
+
export * from "./EmotionEmbedding";
|
|
84
84
|
export * from "./TimeRange";
|
|
85
85
|
export * from "./TextPosition";
|
|
86
|
-
export * from "./Sentiment";
|
|
87
86
|
export * from "./SentimentItem";
|
|
88
|
-
export * from "./
|
|
87
|
+
export * from "./Sentiment";
|
|
89
88
|
export * from "./ToxicityItem";
|
|
89
|
+
export * from "./Toxicity";
|
|
@@ -78,28 +78,28 @@ __exportStar(require("./TranscriptionMetadata"), exports);
|
|
|
78
78
|
__exportStar(require("./Url"), exports);
|
|
79
79
|
__exportStar(require("./When"), exports);
|
|
80
80
|
__exportStar(require("./Window"), exports);
|
|
81
|
-
__exportStar(require("./ModelsInput"), exports);
|
|
82
|
-
__exportStar(require("./ModelConfig"), exports);
|
|
83
81
|
__exportStar(require("./FaceModelConfig"), exports);
|
|
84
82
|
__exportStar(require("./LanguageConfig"), exports);
|
|
85
|
-
__exportStar(require("./
|
|
86
|
-
__exportStar(require("./
|
|
83
|
+
__exportStar(require("./ModelConfig"), exports);
|
|
84
|
+
__exportStar(require("./ModelsInput"), exports);
|
|
87
85
|
__exportStar(require("./ModelsSuccessBurstPredictionsItem"), exports);
|
|
88
|
-
__exportStar(require("./
|
|
86
|
+
__exportStar(require("./BurstResponse"), exports);
|
|
89
87
|
__exportStar(require("./ModelsSuccessFacePredictionsItem"), exports);
|
|
90
|
-
__exportStar(require("./
|
|
88
|
+
__exportStar(require("./FaceResponse"), exports);
|
|
91
89
|
__exportStar(require("./ModelsSuccessFacemeshPredictionsItem"), exports);
|
|
92
|
-
__exportStar(require("./
|
|
90
|
+
__exportStar(require("./FacemeshResponse"), exports);
|
|
93
91
|
__exportStar(require("./ModelsSuccessLanguagePredictionsItem"), exports);
|
|
94
|
-
__exportStar(require("./
|
|
92
|
+
__exportStar(require("./LanguageResponse"), exports);
|
|
95
93
|
__exportStar(require("./ModelsSuccessProsodyPredictionsItem"), exports);
|
|
94
|
+
__exportStar(require("./ProsodyResponse"), exports);
|
|
95
|
+
__exportStar(require("./ModelResponse"), exports);
|
|
96
96
|
__exportStar(require("./ModelsError"), exports);
|
|
97
97
|
__exportStar(require("./ModelsWarning"), exports);
|
|
98
|
-
__exportStar(require("./EmotionEmbedding"), exports);
|
|
99
98
|
__exportStar(require("./EmotionEmbeddingItem"), exports);
|
|
99
|
+
__exportStar(require("./EmotionEmbedding"), exports);
|
|
100
100
|
__exportStar(require("./TimeRange"), exports);
|
|
101
101
|
__exportStar(require("./TextPosition"), exports);
|
|
102
|
-
__exportStar(require("./Sentiment"), exports);
|
|
103
102
|
__exportStar(require("./SentimentItem"), exports);
|
|
104
|
-
__exportStar(require("./
|
|
103
|
+
__exportStar(require("./Sentiment"), exports);
|
|
105
104
|
__exportStar(require("./ToxicityItem"), exports);
|
|
105
|
+
__exportStar(require("./Toxicity"), exports);
|