@botpress/cognitive 0.1.37 → 0.1.39
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/.turbo/turbo-build.log +7 -7
- package/dist/index.cjs +164 -179
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +129 -144
- package/dist/index.mjs.map +2 -2
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cognitive@0.1.
|
|
2
|
+
> @botpress/cognitive@0.1.39 build /home/runner/work/botpress/botpress/packages/cognitive
|
|
3
3
|
> pnpm build:type && pnpm build:neutral && size-limit
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cognitive@0.1.
|
|
6
|
+
> @botpress/cognitive@0.1.39 build:type /home/runner/work/botpress/botpress/packages/cognitive
|
|
7
7
|
> tsup --tsconfig tsconfig.build.json ./src/index.ts --dts-resolve --dts-only --clean
|
|
8
8
|
|
|
9
9
|
CLI Building entry: ./src/index.ts
|
|
10
10
|
CLI Using tsconfig: tsconfig.build.json
|
|
11
11
|
CLI tsup v8.0.2
|
|
12
12
|
DTS Build start
|
|
13
|
-
DTS ⚡️ Build success in
|
|
14
|
-
DTS dist/index.d.ts 623.
|
|
13
|
+
DTS ⚡️ Build success in 8896ms
|
|
14
|
+
DTS dist/index.d.ts 623.42 KB
|
|
15
15
|
|
|
16
|
-
> @botpress/cognitive@0.1.
|
|
16
|
+
> @botpress/cognitive@0.1.39 build:neutral /home/runner/work/botpress/botpress/packages/cognitive
|
|
17
17
|
> ts-node -T ./build.ts --neutral
|
|
18
18
|
|
|
19
19
|
Done
|
|
20
20
|
|
|
21
21
|
[1mdist/index.cjs[22m
|
|
22
22
|
Size limit: [32m[1m50 kB[22m[39m
|
|
23
|
-
Size: [32m[1m8.
|
|
23
|
+
Size: [32m[1m8.52 kB[22m[39m [90mbrotlied[39m
|
|
24
24
|
|
|
25
25
|
[1mdist/index.mjs[22m
|
|
26
26
|
Size limit: [32m[1m50 kB[22m[39m
|
|
27
|
-
Size: [32m[1m8.
|
|
27
|
+
Size: [32m[1m8.39 kB[22m[39m [90mbrotlied[39m
|
|
28
28
|
|
package/dist/index.cjs
CHANGED
|
@@ -31,21 +31,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
|
|
32
32
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/options.js
|
|
33
33
|
var require_options = __commonJS({
|
|
34
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/options.js"(
|
|
34
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/options.js"(exports2) {
|
|
35
35
|
"use strict";
|
|
36
|
-
var __assign =
|
|
36
|
+
var __assign = exports2 && exports2.__assign || function() {
|
|
37
37
|
__assign = Object.assign || function(t) {
|
|
38
38
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
39
|
s = arguments[i];
|
|
40
|
-
for (var p in s)
|
|
41
|
-
|
|
42
|
-
t[p] = s[p];
|
|
40
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
41
|
+
t[p] = s[p];
|
|
43
42
|
}
|
|
44
43
|
return t;
|
|
45
44
|
};
|
|
46
45
|
return __assign.apply(this, arguments);
|
|
47
46
|
};
|
|
48
|
-
Object.defineProperty(
|
|
47
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
49
48
|
var defaultOptions = {
|
|
50
49
|
delayFirstAttempt: false,
|
|
51
50
|
jitter: "none",
|
|
@@ -64,40 +63,40 @@ var require_options = __commonJS({
|
|
|
64
63
|
}
|
|
65
64
|
return sanitized;
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
exports2.getSanitizedOptions = getSanitizedOptions;
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
|
|
71
70
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js
|
|
72
71
|
var require_full_jitter = __commonJS({
|
|
73
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js"(
|
|
72
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js"(exports2) {
|
|
74
73
|
"use strict";
|
|
75
|
-
Object.defineProperty(
|
|
74
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
76
75
|
function fullJitter(delay) {
|
|
77
76
|
var jitteredDelay = Math.random() * delay;
|
|
78
77
|
return Math.round(jitteredDelay);
|
|
79
78
|
}
|
|
80
|
-
|
|
79
|
+
exports2.fullJitter = fullJitter;
|
|
81
80
|
}
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js
|
|
85
84
|
var require_no_jitter = __commonJS({
|
|
86
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js"(
|
|
85
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js"(exports2) {
|
|
87
86
|
"use strict";
|
|
88
|
-
Object.defineProperty(
|
|
87
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
89
88
|
function noJitter(delay) {
|
|
90
89
|
return delay;
|
|
91
90
|
}
|
|
92
|
-
|
|
91
|
+
exports2.noJitter = noJitter;
|
|
93
92
|
}
|
|
94
93
|
});
|
|
95
94
|
|
|
96
95
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/jitter.factory.js
|
|
97
96
|
var require_jitter_factory = __commonJS({
|
|
98
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/jitter.factory.js"(
|
|
97
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/jitter.factory.js"(exports2) {
|
|
99
98
|
"use strict";
|
|
100
|
-
Object.defineProperty(
|
|
99
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101
100
|
var full_jitter_1 = require_full_jitter();
|
|
102
101
|
var no_jitter_1 = require_no_jitter();
|
|
103
102
|
function JitterFactory(options) {
|
|
@@ -109,19 +108,19 @@ var require_jitter_factory = __commonJS({
|
|
|
109
108
|
return no_jitter_1.noJitter;
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
exports2.JitterFactory = JitterFactory;
|
|
113
112
|
}
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.base.js
|
|
117
116
|
var require_delay_base = __commonJS({
|
|
118
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.base.js"(
|
|
117
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.base.js"(exports2) {
|
|
119
118
|
"use strict";
|
|
120
|
-
Object.defineProperty(
|
|
119
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121
120
|
var jitter_factory_1 = require_jitter_factory();
|
|
122
121
|
var Delay = (
|
|
123
122
|
/** @class */
|
|
124
|
-
function() {
|
|
123
|
+
(function() {
|
|
125
124
|
function Delay2(options) {
|
|
126
125
|
this.options = options;
|
|
127
126
|
this.attempt = 0;
|
|
@@ -162,24 +161,22 @@ var require_delay_base = __commonJS({
|
|
|
162
161
|
configurable: true
|
|
163
162
|
});
|
|
164
163
|
return Delay2;
|
|
165
|
-
}()
|
|
164
|
+
})()
|
|
166
165
|
);
|
|
167
|
-
|
|
166
|
+
exports2.Delay = Delay;
|
|
168
167
|
}
|
|
169
168
|
});
|
|
170
169
|
|
|
171
170
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js
|
|
172
171
|
var require_skip_first_delay = __commonJS({
|
|
173
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js"(
|
|
172
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js"(exports2) {
|
|
174
173
|
"use strict";
|
|
175
|
-
var __extends =
|
|
174
|
+
var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
|
|
176
175
|
var extendStatics = function(d, b) {
|
|
177
176
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
178
177
|
d2.__proto__ = b2;
|
|
179
178
|
} || function(d2, b2) {
|
|
180
|
-
for (var p in b2)
|
|
181
|
-
if (b2.hasOwnProperty(p))
|
|
182
|
-
d2[p] = b2[p];
|
|
179
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
183
180
|
};
|
|
184
181
|
return extendStatics(d, b);
|
|
185
182
|
};
|
|
@@ -190,8 +187,8 @@ var require_skip_first_delay = __commonJS({
|
|
|
190
187
|
}
|
|
191
188
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
192
189
|
};
|
|
193
|
-
}();
|
|
194
|
-
var __awaiter =
|
|
190
|
+
})();
|
|
191
|
+
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
195
192
|
function adopt(value) {
|
|
196
193
|
return value instanceof P ? value : new P(function(resolve) {
|
|
197
194
|
resolve(value);
|
|
@@ -218,10 +215,9 @@ var require_skip_first_delay = __commonJS({
|
|
|
218
215
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
219
216
|
});
|
|
220
217
|
};
|
|
221
|
-
var __generator =
|
|
218
|
+
var __generator = exports2 && exports2.__generator || function(thisArg, body) {
|
|
222
219
|
var _ = { label: 0, sent: function() {
|
|
223
|
-
if (t[0] & 1)
|
|
224
|
-
throw t[1];
|
|
220
|
+
if (t[0] & 1) throw t[1];
|
|
225
221
|
return t[1];
|
|
226
222
|
}, trys: [], ops: [] }, f, y, t, g;
|
|
227
223
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
@@ -233,72 +229,66 @@ var require_skip_first_delay = __commonJS({
|
|
|
233
229
|
};
|
|
234
230
|
}
|
|
235
231
|
function step(op) {
|
|
236
|
-
if (f)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
232
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
233
|
+
while (_) try {
|
|
234
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
235
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
236
|
+
switch (op[0]) {
|
|
237
|
+
case 0:
|
|
238
|
+
case 1:
|
|
239
|
+
t = op;
|
|
240
|
+
break;
|
|
241
|
+
case 4:
|
|
242
|
+
_.label++;
|
|
243
|
+
return { value: op[1], done: false };
|
|
244
|
+
case 5:
|
|
245
|
+
_.label++;
|
|
246
|
+
y = op[1];
|
|
247
|
+
op = [0];
|
|
248
|
+
continue;
|
|
249
|
+
case 7:
|
|
250
|
+
op = _.ops.pop();
|
|
251
|
+
_.trys.pop();
|
|
252
|
+
continue;
|
|
253
|
+
default:
|
|
254
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
255
|
+
_ = 0;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
259
|
+
_.label = op[1];
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
263
|
+
_.label = t[1];
|
|
247
264
|
t = op;
|
|
248
265
|
break;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
op = _.ops.pop();
|
|
259
|
-
_.trys.pop();
|
|
260
|
-
continue;
|
|
261
|
-
default:
|
|
262
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
263
|
-
_ = 0;
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
267
|
-
_.label = op[1];
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
271
|
-
_.label = t[1];
|
|
272
|
-
t = op;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
if (t && _.label < t[2]) {
|
|
276
|
-
_.label = t[2];
|
|
277
|
-
_.ops.push(op);
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
if (t[2])
|
|
281
|
-
_.ops.pop();
|
|
282
|
-
_.trys.pop();
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
op = body.call(thisArg, _);
|
|
286
|
-
} catch (e) {
|
|
287
|
-
op = [6, e];
|
|
288
|
-
y = 0;
|
|
289
|
-
} finally {
|
|
290
|
-
f = t = 0;
|
|
266
|
+
}
|
|
267
|
+
if (t && _.label < t[2]) {
|
|
268
|
+
_.label = t[2];
|
|
269
|
+
_.ops.push(op);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
if (t[2]) _.ops.pop();
|
|
273
|
+
_.trys.pop();
|
|
274
|
+
continue;
|
|
291
275
|
}
|
|
292
|
-
|
|
293
|
-
|
|
276
|
+
op = body.call(thisArg, _);
|
|
277
|
+
} catch (e) {
|
|
278
|
+
op = [6, e];
|
|
279
|
+
y = 0;
|
|
280
|
+
} finally {
|
|
281
|
+
f = t = 0;
|
|
282
|
+
}
|
|
283
|
+
if (op[0] & 5) throw op[1];
|
|
294
284
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
295
285
|
}
|
|
296
286
|
};
|
|
297
|
-
Object.defineProperty(
|
|
287
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
298
288
|
var delay_base_1 = require_delay_base();
|
|
299
289
|
var SkipFirstDelay = (
|
|
300
290
|
/** @class */
|
|
301
|
-
function(_super) {
|
|
291
|
+
(function(_super) {
|
|
302
292
|
__extends(SkipFirstDelay2, _super);
|
|
303
293
|
function SkipFirstDelay2() {
|
|
304
294
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -325,24 +315,22 @@ var require_skip_first_delay = __commonJS({
|
|
|
325
315
|
configurable: true
|
|
326
316
|
});
|
|
327
317
|
return SkipFirstDelay2;
|
|
328
|
-
}(delay_base_1.Delay)
|
|
318
|
+
})(delay_base_1.Delay)
|
|
329
319
|
);
|
|
330
|
-
|
|
320
|
+
exports2.SkipFirstDelay = SkipFirstDelay;
|
|
331
321
|
}
|
|
332
322
|
});
|
|
333
323
|
|
|
334
324
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/always/always.delay.js
|
|
335
325
|
var require_always_delay = __commonJS({
|
|
336
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/always/always.delay.js"(
|
|
326
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/always/always.delay.js"(exports2) {
|
|
337
327
|
"use strict";
|
|
338
|
-
var __extends =
|
|
328
|
+
var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
|
|
339
329
|
var extendStatics = function(d, b) {
|
|
340
330
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
341
331
|
d2.__proto__ = b2;
|
|
342
332
|
} || function(d2, b2) {
|
|
343
|
-
for (var p in b2)
|
|
344
|
-
if (b2.hasOwnProperty(p))
|
|
345
|
-
d2[p] = b2[p];
|
|
333
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
346
334
|
};
|
|
347
335
|
return extendStatics(d, b);
|
|
348
336
|
};
|
|
@@ -353,28 +341,28 @@ var require_always_delay = __commonJS({
|
|
|
353
341
|
}
|
|
354
342
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
355
343
|
};
|
|
356
|
-
}();
|
|
357
|
-
Object.defineProperty(
|
|
344
|
+
})();
|
|
345
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
358
346
|
var delay_base_1 = require_delay_base();
|
|
359
347
|
var AlwaysDelay = (
|
|
360
348
|
/** @class */
|
|
361
|
-
function(_super) {
|
|
349
|
+
(function(_super) {
|
|
362
350
|
__extends(AlwaysDelay2, _super);
|
|
363
351
|
function AlwaysDelay2() {
|
|
364
352
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
365
353
|
}
|
|
366
354
|
return AlwaysDelay2;
|
|
367
|
-
}(delay_base_1.Delay)
|
|
355
|
+
})(delay_base_1.Delay)
|
|
368
356
|
);
|
|
369
|
-
|
|
357
|
+
exports2.AlwaysDelay = AlwaysDelay;
|
|
370
358
|
}
|
|
371
359
|
});
|
|
372
360
|
|
|
373
361
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.factory.js
|
|
374
362
|
var require_delay_factory = __commonJS({
|
|
375
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.factory.js"(
|
|
363
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.factory.js"(exports2) {
|
|
376
364
|
"use strict";
|
|
377
|
-
Object.defineProperty(
|
|
365
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
378
366
|
var skip_first_delay_1 = require_skip_first_delay();
|
|
379
367
|
var always_delay_1 = require_always_delay();
|
|
380
368
|
function DelayFactory(options, attempt) {
|
|
@@ -382,7 +370,7 @@ var require_delay_factory = __commonJS({
|
|
|
382
370
|
delay.setAttemptNumber(attempt);
|
|
383
371
|
return delay;
|
|
384
372
|
}
|
|
385
|
-
|
|
373
|
+
exports2.DelayFactory = DelayFactory;
|
|
386
374
|
function initDelayClass(options) {
|
|
387
375
|
if (!options.delayFirstAttempt) {
|
|
388
376
|
return new skip_first_delay_1.SkipFirstDelay(options);
|
|
@@ -394,9 +382,9 @@ var require_delay_factory = __commonJS({
|
|
|
394
382
|
|
|
395
383
|
// ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/backoff.js
|
|
396
384
|
var require_backoff = __commonJS({
|
|
397
|
-
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/backoff.js"(
|
|
385
|
+
"../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/backoff.js"(exports2) {
|
|
398
386
|
"use strict";
|
|
399
|
-
var __awaiter =
|
|
387
|
+
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
400
388
|
function adopt(value) {
|
|
401
389
|
return value instanceof P ? value : new P(function(resolve) {
|
|
402
390
|
resolve(value);
|
|
@@ -423,10 +411,9 @@ var require_backoff = __commonJS({
|
|
|
423
411
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
424
412
|
});
|
|
425
413
|
};
|
|
426
|
-
var __generator =
|
|
414
|
+
var __generator = exports2 && exports2.__generator || function(thisArg, body) {
|
|
427
415
|
var _ = { label: 0, sent: function() {
|
|
428
|
-
if (t[0] & 1)
|
|
429
|
-
throw t[1];
|
|
416
|
+
if (t[0] & 1) throw t[1];
|
|
430
417
|
return t[1];
|
|
431
418
|
}, trys: [], ops: [] }, f, y, t, g;
|
|
432
419
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
@@ -438,68 +425,62 @@ var require_backoff = __commonJS({
|
|
|
438
425
|
};
|
|
439
426
|
}
|
|
440
427
|
function step(op) {
|
|
441
|
-
if (f)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
428
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
429
|
+
while (_) try {
|
|
430
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
431
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
432
|
+
switch (op[0]) {
|
|
433
|
+
case 0:
|
|
434
|
+
case 1:
|
|
435
|
+
t = op;
|
|
436
|
+
break;
|
|
437
|
+
case 4:
|
|
438
|
+
_.label++;
|
|
439
|
+
return { value: op[1], done: false };
|
|
440
|
+
case 5:
|
|
441
|
+
_.label++;
|
|
442
|
+
y = op[1];
|
|
443
|
+
op = [0];
|
|
444
|
+
continue;
|
|
445
|
+
case 7:
|
|
446
|
+
op = _.ops.pop();
|
|
447
|
+
_.trys.pop();
|
|
448
|
+
continue;
|
|
449
|
+
default:
|
|
450
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
451
|
+
_ = 0;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
455
|
+
_.label = op[1];
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
459
|
+
_.label = t[1];
|
|
452
460
|
t = op;
|
|
453
461
|
break;
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
op = _.ops.pop();
|
|
464
|
-
_.trys.pop();
|
|
465
|
-
continue;
|
|
466
|
-
default:
|
|
467
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
468
|
-
_ = 0;
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
472
|
-
_.label = op[1];
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
476
|
-
_.label = t[1];
|
|
477
|
-
t = op;
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
if (t && _.label < t[2]) {
|
|
481
|
-
_.label = t[2];
|
|
482
|
-
_.ops.push(op);
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
if (t[2])
|
|
486
|
-
_.ops.pop();
|
|
487
|
-
_.trys.pop();
|
|
488
|
-
continue;
|
|
489
|
-
}
|
|
490
|
-
op = body.call(thisArg, _);
|
|
491
|
-
} catch (e) {
|
|
492
|
-
op = [6, e];
|
|
493
|
-
y = 0;
|
|
494
|
-
} finally {
|
|
495
|
-
f = t = 0;
|
|
462
|
+
}
|
|
463
|
+
if (t && _.label < t[2]) {
|
|
464
|
+
_.label = t[2];
|
|
465
|
+
_.ops.push(op);
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
if (t[2]) _.ops.pop();
|
|
469
|
+
_.trys.pop();
|
|
470
|
+
continue;
|
|
496
471
|
}
|
|
497
|
-
|
|
498
|
-
|
|
472
|
+
op = body.call(thisArg, _);
|
|
473
|
+
} catch (e) {
|
|
474
|
+
op = [6, e];
|
|
475
|
+
y = 0;
|
|
476
|
+
} finally {
|
|
477
|
+
f = t = 0;
|
|
478
|
+
}
|
|
479
|
+
if (op[0] & 5) throw op[1];
|
|
499
480
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
500
481
|
}
|
|
501
482
|
};
|
|
502
|
-
Object.defineProperty(
|
|
483
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
503
484
|
var options_1 = require_options();
|
|
504
485
|
var delay_factory_1 = require_delay_factory();
|
|
505
486
|
function backOff3(request, options) {
|
|
@@ -520,10 +501,10 @@ var require_backoff = __commonJS({
|
|
|
520
501
|
});
|
|
521
502
|
});
|
|
522
503
|
}
|
|
523
|
-
|
|
504
|
+
exports2.backOff = backOff3;
|
|
524
505
|
var BackOff = (
|
|
525
506
|
/** @class */
|
|
526
|
-
function() {
|
|
507
|
+
(function() {
|
|
527
508
|
function BackOff2(request, options) {
|
|
528
509
|
this.request = request;
|
|
529
510
|
this.options = options;
|
|
@@ -535,8 +516,7 @@ var require_backoff = __commonJS({
|
|
|
535
516
|
return __generator(this, function(_a) {
|
|
536
517
|
switch (_a.label) {
|
|
537
518
|
case 0:
|
|
538
|
-
if (!!this.attemptLimitReached)
|
|
539
|
-
return [3, 7];
|
|
519
|
+
if (!!this.attemptLimitReached) return [3, 7];
|
|
540
520
|
_a.label = 1;
|
|
541
521
|
case 1:
|
|
542
522
|
_a.trys.push([1, 4, , 6]);
|
|
@@ -590,20 +570,20 @@ var require_backoff = __commonJS({
|
|
|
590
570
|
});
|
|
591
571
|
};
|
|
592
572
|
return BackOff2;
|
|
593
|
-
}()
|
|
573
|
+
})()
|
|
594
574
|
);
|
|
595
575
|
}
|
|
596
576
|
});
|
|
597
577
|
|
|
598
578
|
// src/index.ts
|
|
599
|
-
var
|
|
600
|
-
__export(
|
|
579
|
+
var index_exports = {};
|
|
580
|
+
__export(index_exports, {
|
|
601
581
|
Cognitive: () => Cognitive,
|
|
602
582
|
CognitiveBeta: () => CognitiveBeta,
|
|
603
583
|
ModelProvider: () => ModelProvider,
|
|
604
584
|
RemoteModelProvider: () => RemoteModelProvider
|
|
605
585
|
});
|
|
606
|
-
module.exports = __toCommonJS(
|
|
586
|
+
module.exports = __toCommonJS(index_exports);
|
|
607
587
|
|
|
608
588
|
// src/client.ts
|
|
609
589
|
var import_exponential_backoff2 = __toESM(require_backoff());
|
|
@@ -678,6 +658,7 @@ var CognitiveBeta = class {
|
|
|
678
658
|
timeout: props.timeout || 60001,
|
|
679
659
|
token: props.token || "",
|
|
680
660
|
botId: props.botId || "",
|
|
661
|
+
withCredentials: props.withCredentials || false,
|
|
681
662
|
headers: props.headers || {}
|
|
682
663
|
};
|
|
683
664
|
this._axiosClient = import_axios.default.create({
|
|
@@ -686,6 +667,7 @@ var CognitiveBeta = class {
|
|
|
686
667
|
"X-Bot-Id": this._config.botId,
|
|
687
668
|
...this._config.headers
|
|
688
669
|
},
|
|
670
|
+
withCredentials: this._config.withCredentials,
|
|
689
671
|
baseURL: this._config.baseUrl
|
|
690
672
|
});
|
|
691
673
|
}
|
|
@@ -717,8 +699,10 @@ var CognitiveBeta = class {
|
|
|
717
699
|
headers: {
|
|
718
700
|
Authorization: `Bearer ${this._config.token}`,
|
|
719
701
|
"X-Bot-Id": this._config.botId,
|
|
720
|
-
"Content-Type": "application/json"
|
|
702
|
+
"Content-Type": "application/json",
|
|
703
|
+
...this._config.headers
|
|
721
704
|
},
|
|
705
|
+
credentials: this._config.withCredentials ? "include" : "omit",
|
|
722
706
|
body: JSON.stringify({ ...request, stream: true }),
|
|
723
707
|
signal
|
|
724
708
|
});
|
|
@@ -733,7 +717,7 @@ var CognitiveBeta = class {
|
|
|
733
717
|
throw new Error("No response body received for streaming request");
|
|
734
718
|
}
|
|
735
719
|
const reader = body.getReader();
|
|
736
|
-
const iterable = async function* () {
|
|
720
|
+
const iterable = (async function* () {
|
|
737
721
|
for (; ; ) {
|
|
738
722
|
const { value, done } = await reader.read();
|
|
739
723
|
if (done) {
|
|
@@ -743,7 +727,7 @@ var CognitiveBeta = class {
|
|
|
743
727
|
yield value;
|
|
744
728
|
}
|
|
745
729
|
}
|
|
746
|
-
}();
|
|
730
|
+
})();
|
|
747
731
|
for await (const obj of this._ndjson(iterable)) {
|
|
748
732
|
yield obj;
|
|
749
733
|
}
|
|
@@ -938,7 +922,7 @@ var getBestModels = (models, boosts = {}) => models.sort((a, b) => scoreModel(b,
|
|
|
938
922
|
var getFastModels = (models, boosts = {}) => models.sort((a, b) => scoreModel(b, "fast", boosts) - scoreModel(a, "fast", boosts));
|
|
939
923
|
var pickModel = (models, downtimes = []) => {
|
|
940
924
|
const copy = [...models];
|
|
941
|
-
const elasped = (date) => new Date().getTime() - new Date(date).getTime();
|
|
925
|
+
const elasped = (date) => (/* @__PURE__ */ new Date()).getTime() - new Date(date).getTime();
|
|
942
926
|
const DOWNTIME_THRESHOLD = 1e3 * 60 * DOWNTIME_THRESHOLD_MINUTES;
|
|
943
927
|
if (!copy.length) {
|
|
944
928
|
throw new Error("At least one model is required");
|
|
@@ -1052,7 +1036,7 @@ var RemoteModelProvider = class extends ModelProvider {
|
|
|
1052
1036
|
};
|
|
1053
1037
|
|
|
1054
1038
|
// src/client.ts
|
|
1055
|
-
var Cognitive = class {
|
|
1039
|
+
var Cognitive = class _Cognitive {
|
|
1056
1040
|
["$$IS_COGNITIVE"] = true;
|
|
1057
1041
|
static isCognitiveClient(obj) {
|
|
1058
1042
|
return obj?.$$IS_COGNITIVE === true;
|
|
@@ -1083,7 +1067,7 @@ var Cognitive = class {
|
|
|
1083
1067
|
return this._client;
|
|
1084
1068
|
}
|
|
1085
1069
|
clone() {
|
|
1086
|
-
const copy = new
|
|
1070
|
+
const copy = new _Cognitive({
|
|
1087
1071
|
client: this._client.clone(),
|
|
1088
1072
|
provider: this._provider,
|
|
1089
1073
|
timeout: this._timeoutMs,
|
|
@@ -1169,6 +1153,7 @@ var Cognitive = class {
|
|
|
1169
1153
|
}
|
|
1170
1154
|
const betaClient = new CognitiveBeta({
|
|
1171
1155
|
headers: this._client.config.headers,
|
|
1156
|
+
withCredentials: this._client.config.withCredentials,
|
|
1172
1157
|
baseUrl: this._client.config.apiUrl.includes(".cloud") ? "https://cognitive.botpress.cloud" : "https://cognitive.botpress.dev"
|
|
1173
1158
|
});
|
|
1174
1159
|
const response = await betaClient.generateText(input);
|
|
@@ -1252,7 +1237,7 @@ var Cognitive = class {
|
|
|
1252
1237
|
if (action === "fallback") {
|
|
1253
1238
|
this._downtimes.push({
|
|
1254
1239
|
ref: `${integration}:${model}`,
|
|
1255
|
-
startedAt: new Date().toISOString(),
|
|
1240
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1256
1241
|
reason: "Model is down"
|
|
1257
1242
|
});
|
|
1258
1243
|
this._cleanupOldDowntimes();
|