@scout9/app 1.0.0-alpha.0.8.2 → 1.0.0-alpha.0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dev-bc9e04ca.cjs → dev-4ada3a05.cjs} +2 -2
- package/dist/{index-0d4223e3.cjs → index-0b3b25f9.cjs} +6 -6
- package/dist/index.cjs +3 -3
- package/dist/{multipart-parser-0717500b.cjs → multipart-parser-4efbd7b7.cjs} +3 -3
- package/dist/{spirits-5dc52d64.cjs → spirits-eea2300e.cjs} +105 -101
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +2 -2
- package/package.json +1 -1
- package/src/testing-tools/spirits.js +5 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
3
|
+
var spirits = require("./spirits-eea2300e.cjs");
|
|
4
4
|
var require$$0$4 = require('util');
|
|
5
5
|
var require$$0$3 = require('stream');
|
|
6
6
|
var require$$1 = require('path');
|
|
@@ -35337,7 +35337,7 @@ function _loadUserPackageJson() {
|
|
|
35337
35337
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
35338
35338
|
_context2.t0 = JSON;
|
|
35339
35339
|
_context2.next = 10;
|
|
35340
|
-
return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dev-
|
|
35340
|
+
return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dev-4ada3a05.js', document.baseURI).href))), 'utf-8');
|
|
35341
35341
|
case 10:
|
|
35342
35342
|
_context2.t1 = _context2.sent;
|
|
35343
35343
|
pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
4
|
-
var dev = require("./dev-
|
|
3
|
+
var spirits = require("./spirits-eea2300e.cjs");
|
|
4
|
+
var dev = require("./dev-4ada3a05.cjs");
|
|
5
5
|
var macros = require("./macros-f62cceac.cjs");
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
7
|
var require$$2$1 = require('events');
|
|
@@ -29483,7 +29483,7 @@ class Body {
|
|
|
29483
29483
|
}
|
|
29484
29484
|
const {
|
|
29485
29485
|
toFormData
|
|
29486
|
-
} = await Promise.resolve().then(function () { return require("./multipart-parser-
|
|
29486
|
+
} = await Promise.resolve().then(function () { return require("./multipart-parser-4efbd7b7.cjs"); });
|
|
29487
29487
|
return toFormData(this.body, ct);
|
|
29488
29488
|
}
|
|
29489
29489
|
|
|
@@ -41884,7 +41884,7 @@ function _loadUserPackageJson() {
|
|
|
41884
41884
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
41885
41885
|
_context.t0 = JSON;
|
|
41886
41886
|
_context.next = 10;
|
|
41887
|
-
return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-
|
|
41887
|
+
return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-0b3b25f9.js', document.baseURI).href))), 'utf-8');
|
|
41888
41888
|
case 10:
|
|
41889
41889
|
_context.t1 = _context.sent;
|
|
41890
41890
|
pkg = _context.t0.parse.call(_context.t0, _context.t1);
|
|
@@ -43176,7 +43176,7 @@ var ProjectFiles = /*#__PURE__*/function () {
|
|
|
43176
43176
|
return ProjectFiles;
|
|
43177
43177
|
}();
|
|
43178
43178
|
|
|
43179
|
-
var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-
|
|
43179
|
+
var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-0b3b25f9.js', document.baseURI).href)));
|
|
43180
43180
|
var __dirname$1 = path__default["default"].dirname(__filename$1);
|
|
43181
43181
|
function zipDirectory(source, out) {
|
|
43182
43182
|
var archive = archiver$1('tar', {
|
|
@@ -43391,7 +43391,7 @@ function _buildApp() {
|
|
|
43391
43391
|
case 11:
|
|
43392
43392
|
_context4.t0 = JSON;
|
|
43393
43393
|
_context4.next = 14;
|
|
43394
|
-
return fs__default["default"].readFile(new URL(templatePackagePath, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-
|
|
43394
|
+
return fs__default["default"].readFile(new URL(templatePackagePath, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-0b3b25f9.js', document.baseURI).href))), 'utf-8');
|
|
43395
43395
|
case 14:
|
|
43396
43396
|
_context4.t1 = _context4.sent;
|
|
43397
43397
|
packageTemplate = _context4.t0.parse.call(_context4.t0, _context4.t1);
|
package/dist/index.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require("./index-
|
|
6
|
-
var dev = require("./dev-
|
|
7
|
-
require("./spirits-
|
|
5
|
+
var index = require("./index-0b3b25f9.cjs");
|
|
6
|
+
var dev = require("./dev-4ada3a05.cjs");
|
|
7
|
+
require("./spirits-eea2300e.cjs");
|
|
8
8
|
require("./macros-f62cceac.cjs");
|
|
9
9
|
require('fs');
|
|
10
10
|
require('events');
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var index = require("./index-
|
|
6
|
-
require("./spirits-
|
|
7
|
-
require("./dev-
|
|
5
|
+
var index = require("./index-0b3b25f9.cjs");
|
|
6
|
+
require("./spirits-eea2300e.cjs");
|
|
7
|
+
require("./dev-4ada3a05.cjs");
|
|
8
8
|
require('util');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('path');
|
|
@@ -1077,18 +1077,22 @@ var Spirits = {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
|
|
1079
1079
|
// 3. Run the contextualizer
|
|
1080
|
-
|
|
1080
|
+
progress('Running contextualizer', 'info', 'SET_PROCESSING', 'system');
|
|
1081
|
+
_context2.next = 47;
|
|
1081
1082
|
return contextualizer({
|
|
1082
1083
|
conversation: conversation,
|
|
1083
1084
|
messages: messages
|
|
1084
1085
|
});
|
|
1085
|
-
case
|
|
1086
|
+
case 47:
|
|
1086
1087
|
newContextMessages = _context2.sent;
|
|
1087
1088
|
_iterator = _createForOfIteratorHelper(newContextMessages);
|
|
1088
1089
|
try {
|
|
1089
1090
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1090
1091
|
contextMessage = _step.value;
|
|
1091
|
-
|
|
1092
|
+
if (contextMessage.entities.length) {
|
|
1093
|
+
messages.push(contextMessage);
|
|
1094
|
+
progress("Added context", 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1095
|
+
}
|
|
1092
1096
|
}
|
|
1093
1097
|
|
|
1094
1098
|
// 4. Run the workflow
|
|
@@ -1098,7 +1102,7 @@ var Spirits = {
|
|
|
1098
1102
|
_iterator.f();
|
|
1099
1103
|
}
|
|
1100
1104
|
progress('Running workflow', 'info', 'SET_PROCESSING', 'system');
|
|
1101
|
-
_context2.next =
|
|
1105
|
+
_context2.next = 53;
|
|
1102
1106
|
return workflow({
|
|
1103
1107
|
messages: messages,
|
|
1104
1108
|
conversation: conversation,
|
|
@@ -1127,7 +1131,7 @@ var Spirits = {
|
|
|
1127
1131
|
return accumulator;
|
|
1128
1132
|
}, []);
|
|
1129
1133
|
});
|
|
1130
|
-
case
|
|
1134
|
+
case 53:
|
|
1131
1135
|
slots = _context2.sent;
|
|
1132
1136
|
hasNoInstructions = slots.every(function (s) {
|
|
1133
1137
|
return !s.instructions || Array.isArray(s.instructions) && s.instructions.length === 0;
|
|
@@ -1154,20 +1158,20 @@ var Spirits = {
|
|
|
1154
1158
|
resettedIntent = false;
|
|
1155
1159
|
/** @type {Array<string> | undefined} */
|
|
1156
1160
|
_iterator2 = _createForOfIteratorHelper(slots);
|
|
1157
|
-
_context2.prev =
|
|
1161
|
+
_context2.prev = 61;
|
|
1158
1162
|
_iterator2.s();
|
|
1159
|
-
case
|
|
1163
|
+
case 63:
|
|
1160
1164
|
if ((_step2 = _iterator2.n()).done) {
|
|
1161
|
-
_context2.next =
|
|
1165
|
+
_context2.next = 134;
|
|
1162
1166
|
break;
|
|
1163
1167
|
}
|
|
1164
1168
|
_step2$value = _step2.value, forward = _step2$value.forward, forwardNote = _step2$value.forwardNote, instructions = _step2$value.instructions, removeInstructions = _step2$value.removeInstructions, manualMessage = _step2$value.message, scheduled = _step2$value.scheduled, resetIntent = _step2$value.resetIntent, secondsDelay = _step2$value.secondsDelay, contextUpsert = _step2$value.contextUpsert, anticipate = _step2$value.anticipate, slotFollowup = _step2$value.followup, slotEntityContextUpsert = _step2$value.entityContextUpsert, tasks = _step2$value.tasks;
|
|
1165
1169
|
if (!anticipate) {
|
|
1166
|
-
_context2.next =
|
|
1170
|
+
_context2.next = 78;
|
|
1167
1171
|
break;
|
|
1168
1172
|
}
|
|
1169
1173
|
if (!Array.isArray(anticipate)) {
|
|
1170
|
-
_context2.next =
|
|
1174
|
+
_context2.next = 73;
|
|
1171
1175
|
break;
|
|
1172
1176
|
}
|
|
1173
1177
|
// 'literal' anticipation
|
|
@@ -1187,11 +1191,11 @@ var Spirits = {
|
|
|
1187
1191
|
slots: _slots,
|
|
1188
1192
|
map: map
|
|
1189
1193
|
});
|
|
1190
|
-
_context2.next =
|
|
1194
|
+
_context2.next = 78;
|
|
1191
1195
|
break;
|
|
1192
|
-
case
|
|
1196
|
+
case 73:
|
|
1193
1197
|
if (!('yes' in anticipate && 'no' in anticipate && 'did' in anticipate)) {
|
|
1194
|
-
_context2.next =
|
|
1198
|
+
_context2.next = 77;
|
|
1195
1199
|
break;
|
|
1196
1200
|
}
|
|
1197
1201
|
// "did" anticipation
|
|
@@ -1203,11 +1207,11 @@ var Spirits = {
|
|
|
1203
1207
|
},
|
|
1204
1208
|
did: anticipate.did
|
|
1205
1209
|
});
|
|
1206
|
-
_context2.next =
|
|
1210
|
+
_context2.next = 78;
|
|
1207
1211
|
break;
|
|
1208
|
-
case 76:
|
|
1209
|
-
throw new Error("Invalid anticipate payload \"".concat(JSON.stringify(anticipate), "\""));
|
|
1210
1212
|
case 77:
|
|
1213
|
+
throw new Error("Invalid anticipate payload \"".concat(JSON.stringify(anticipate), "\""));
|
|
1214
|
+
case 78:
|
|
1211
1215
|
// tasks from auto/manual ingress to execute
|
|
1212
1216
|
if (!!tasks && Array.isArray(tasks) && !!tasks.length) {
|
|
1213
1217
|
if (!_tasks) _tasks = [];
|
|
@@ -1263,19 +1267,19 @@ var Spirits = {
|
|
|
1263
1267
|
|
|
1264
1268
|
// Insert instructions context
|
|
1265
1269
|
if (!instructions) {
|
|
1266
|
-
_context2.next =
|
|
1270
|
+
_context2.next = 97;
|
|
1267
1271
|
break;
|
|
1268
1272
|
}
|
|
1269
1273
|
if (!(typeof instructions === 'string')) {
|
|
1270
|
-
_context2.next =
|
|
1274
|
+
_context2.next = 87;
|
|
1271
1275
|
break;
|
|
1272
1276
|
}
|
|
1273
1277
|
addInstruction(instructions, previousLockAttempt);
|
|
1274
|
-
_context2.next =
|
|
1278
|
+
_context2.next = 97;
|
|
1275
1279
|
break;
|
|
1276
|
-
case
|
|
1280
|
+
case 87:
|
|
1277
1281
|
if (!Array.isArray(instructions)) {
|
|
1278
|
-
_context2.next =
|
|
1282
|
+
_context2.next = 92;
|
|
1279
1283
|
break;
|
|
1280
1284
|
}
|
|
1281
1285
|
_iterator5 = _createForOfIteratorHelper(instructions);
|
|
@@ -1293,25 +1297,25 @@ var Spirits = {
|
|
|
1293
1297
|
} finally {
|
|
1294
1298
|
_iterator5.f();
|
|
1295
1299
|
}
|
|
1296
|
-
_context2.next =
|
|
1300
|
+
_context2.next = 97;
|
|
1297
1301
|
break;
|
|
1298
|
-
case
|
|
1302
|
+
case 92:
|
|
1299
1303
|
if (!(_typeof(instructions) === 'object' && 'content' in instructions)) {
|
|
1300
|
-
_context2.next =
|
|
1304
|
+
_context2.next = 96;
|
|
1301
1305
|
break;
|
|
1302
1306
|
}
|
|
1303
1307
|
addInstruction(instructions.content, previousLockAttempt, instructions.id);
|
|
1304
|
-
_context2.next =
|
|
1308
|
+
_context2.next = 97;
|
|
1305
1309
|
break;
|
|
1306
|
-
case 95:
|
|
1307
|
-
throw new Error("SpiritsError: instructions must be a string or array or {content: \"<instruction>\"}, got: ".concat(JSON.stringify(instructions)));
|
|
1308
1310
|
case 96:
|
|
1311
|
+
throw new Error("SpiritsError: instructions must be a string or array or {content: \"<instruction>\"}, got: ".concat(JSON.stringify(instructions)));
|
|
1312
|
+
case 97:
|
|
1309
1313
|
if (!removeInstructions) {
|
|
1310
|
-
_context2.next =
|
|
1314
|
+
_context2.next = 114;
|
|
1311
1315
|
break;
|
|
1312
1316
|
}
|
|
1313
1317
|
_iterator6 = _createForOfIteratorHelper(removeInstructions);
|
|
1314
|
-
_context2.prev =
|
|
1318
|
+
_context2.prev = 99;
|
|
1315
1319
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1316
1320
|
var instructionId, index;
|
|
1317
1321
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
@@ -1336,29 +1340,29 @@ var Spirits = {
|
|
|
1336
1340
|
}, _loop);
|
|
1337
1341
|
});
|
|
1338
1342
|
_iterator6.s();
|
|
1339
|
-
case
|
|
1343
|
+
case 102:
|
|
1340
1344
|
if ((_step6 = _iterator6.n()).done) {
|
|
1341
|
-
_context2.next =
|
|
1345
|
+
_context2.next = 106;
|
|
1342
1346
|
break;
|
|
1343
1347
|
}
|
|
1344
|
-
return _context2.delegateYield(_loop(), "t0",
|
|
1345
|
-
case
|
|
1346
|
-
_context2.next =
|
|
1348
|
+
return _context2.delegateYield(_loop(), "t0", 104);
|
|
1349
|
+
case 104:
|
|
1350
|
+
_context2.next = 102;
|
|
1347
1351
|
break;
|
|
1348
|
-
case
|
|
1349
|
-
_context2.next =
|
|
1352
|
+
case 106:
|
|
1353
|
+
_context2.next = 111;
|
|
1350
1354
|
break;
|
|
1351
|
-
case
|
|
1352
|
-
_context2.prev =
|
|
1353
|
-
_context2.t1 = _context2["catch"](
|
|
1355
|
+
case 108:
|
|
1356
|
+
_context2.prev = 108;
|
|
1357
|
+
_context2.t1 = _context2["catch"](99);
|
|
1354
1358
|
_iterator6.e(_context2.t1);
|
|
1355
|
-
case
|
|
1356
|
-
_context2.prev =
|
|
1359
|
+
case 111:
|
|
1360
|
+
_context2.prev = 111;
|
|
1357
1361
|
_iterator6.f();
|
|
1358
|
-
return _context2.finish(
|
|
1359
|
-
case
|
|
1362
|
+
return _context2.finish(111);
|
|
1363
|
+
case 114:
|
|
1360
1364
|
if (!manualMessage) {
|
|
1361
|
-
_context2.next =
|
|
1365
|
+
_context2.next = 130;
|
|
1362
1366
|
break;
|
|
1363
1367
|
}
|
|
1364
1368
|
/** @type {import('@scout9/admin').Message} */
|
|
@@ -1370,25 +1374,25 @@ var Spirits = {
|
|
|
1370
1374
|
time: new Date().toISOString()
|
|
1371
1375
|
};
|
|
1372
1376
|
if (!(_typeof(manualMessage) === 'object')) {
|
|
1373
|
-
_context2.next =
|
|
1377
|
+
_context2.next = 122;
|
|
1374
1378
|
break;
|
|
1375
1379
|
}
|
|
1376
1380
|
Object.assign(manualMessageObj, manualMessage);
|
|
1377
1381
|
manualMessageObj.role = 'agent';
|
|
1378
1382
|
manualMessageObj.time = new Date().toISOString();
|
|
1379
|
-
_context2.next =
|
|
1383
|
+
_context2.next = 127;
|
|
1380
1384
|
break;
|
|
1381
|
-
case
|
|
1385
|
+
case 122:
|
|
1382
1386
|
if (!(typeof manualMessage === 'string')) {
|
|
1383
|
-
_context2.next =
|
|
1387
|
+
_context2.next = 126;
|
|
1384
1388
|
break;
|
|
1385
1389
|
}
|
|
1386
1390
|
manualMessageObj.content = manualMessage;
|
|
1387
|
-
_context2.next =
|
|
1391
|
+
_context2.next = 127;
|
|
1388
1392
|
break;
|
|
1389
|
-
case 125:
|
|
1390
|
-
throw new Error('Manual message must be of type "string" or "DirectMessage"');
|
|
1391
1393
|
case 126:
|
|
1394
|
+
throw new Error('Manual message must be of type "string" or "DirectMessage"');
|
|
1395
|
+
case 127:
|
|
1392
1396
|
if (scheduled) {
|
|
1393
1397
|
manualMessageObj.time = new Date(scheduled * 1000).toISOString();
|
|
1394
1398
|
manualMessageObj.scheduled = manualMessageObj.time;
|
|
@@ -1400,7 +1404,7 @@ var Spirits = {
|
|
|
1400
1404
|
}
|
|
1401
1405
|
messages.push(manualMessageObj);
|
|
1402
1406
|
progress('Added manual message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1403
|
-
case
|
|
1407
|
+
case 130:
|
|
1404
1408
|
if (contextUpsert) {
|
|
1405
1409
|
context = updateContext(context, contextUpsert);
|
|
1406
1410
|
progress('Upserted context', 'info', 'UPDATE_CONTEXT', contextUpsert);
|
|
@@ -1408,21 +1412,21 @@ var Spirits = {
|
|
|
1408
1412
|
if (resetIntent) {
|
|
1409
1413
|
resettedIntent = true;
|
|
1410
1414
|
}
|
|
1411
|
-
case
|
|
1412
|
-
_context2.next =
|
|
1415
|
+
case 132:
|
|
1416
|
+
_context2.next = 63;
|
|
1413
1417
|
break;
|
|
1414
|
-
case
|
|
1415
|
-
_context2.next =
|
|
1418
|
+
case 134:
|
|
1419
|
+
_context2.next = 139;
|
|
1416
1420
|
break;
|
|
1417
|
-
case
|
|
1418
|
-
_context2.prev =
|
|
1419
|
-
_context2.t2 = _context2["catch"](
|
|
1421
|
+
case 136:
|
|
1422
|
+
_context2.prev = 136;
|
|
1423
|
+
_context2.t2 = _context2["catch"](61);
|
|
1420
1424
|
_iterator2.e(_context2.t2);
|
|
1421
|
-
case
|
|
1422
|
-
_context2.prev =
|
|
1425
|
+
case 139:
|
|
1426
|
+
_context2.prev = 139;
|
|
1423
1427
|
_iterator2.f();
|
|
1424
|
-
return _context2.finish(
|
|
1425
|
-
case
|
|
1428
|
+
return _context2.finish(139);
|
|
1429
|
+
case 142:
|
|
1426
1430
|
if (resettedIntent && !_forward) {
|
|
1427
1431
|
conversation.intent = null;
|
|
1428
1432
|
conversation.intentScore = null;
|
|
@@ -1441,14 +1445,14 @@ var Spirits = {
|
|
|
1441
1445
|
// 5. Generate response
|
|
1442
1446
|
// If conversation previously locked, don't generate
|
|
1443
1447
|
if (input.conversation.locked) {
|
|
1444
|
-
_context2.next =
|
|
1448
|
+
_context2.next = 194;
|
|
1445
1449
|
break;
|
|
1446
1450
|
}
|
|
1447
1451
|
if (!((!conversation.locked || !hasNoInstructions) && !!hasNoCustomMessage)) {
|
|
1448
|
-
_context2.next =
|
|
1452
|
+
_context2.next = 160;
|
|
1449
1453
|
break;
|
|
1450
1454
|
}
|
|
1451
|
-
_context2.prev =
|
|
1455
|
+
_context2.prev = 145;
|
|
1452
1456
|
progress('Generating message', 'info', 'SET_PROCESSING', 'system');
|
|
1453
1457
|
|
|
1454
1458
|
/** @type {import('@scout9/admin').GenerateRequestOneOf1} */
|
|
@@ -1462,9 +1466,9 @@ var Spirits = {
|
|
|
1462
1466
|
if (!!_tasks && Array.isArray(_tasks) && !!_tasks.length) {
|
|
1463
1467
|
generatorInput.tasks = _tasks;
|
|
1464
1468
|
}
|
|
1465
|
-
_context2.next =
|
|
1469
|
+
_context2.next = 151;
|
|
1466
1470
|
return generator(generatorInput);
|
|
1467
|
-
case
|
|
1471
|
+
case 151:
|
|
1468
1472
|
generatorPayload = _context2.sent;
|
|
1469
1473
|
if (!generatorPayload.send) {
|
|
1470
1474
|
progress('Generated response', 'failed', undefined, {
|
|
@@ -1538,30 +1542,30 @@ var Spirits = {
|
|
|
1538
1542
|
}
|
|
1539
1543
|
}
|
|
1540
1544
|
}
|
|
1541
|
-
_context2.next =
|
|
1545
|
+
_context2.next = 160;
|
|
1542
1546
|
break;
|
|
1543
|
-
case
|
|
1544
|
-
_context2.prev =
|
|
1545
|
-
_context2.t3 = _context2["catch"](
|
|
1547
|
+
case 155:
|
|
1548
|
+
_context2.prev = 155;
|
|
1549
|
+
_context2.t3 = _context2["catch"](145);
|
|
1546
1550
|
onError(_context2.t3);
|
|
1547
1551
|
console.error("Spirits: Locking conversation, error generating response: ".concat(_context2.t3.message));
|
|
1548
1552
|
conversation = lockConversation(conversation, 'API: ' + _context2.t3.message);
|
|
1549
|
-
case
|
|
1553
|
+
case 160:
|
|
1550
1554
|
if (!(messagesToTransform.length && transformer)) {
|
|
1551
|
-
_context2.next =
|
|
1555
|
+
_context2.next = 193;
|
|
1552
1556
|
break;
|
|
1553
1557
|
}
|
|
1554
|
-
_context2.prev =
|
|
1558
|
+
_context2.prev = 161;
|
|
1555
1559
|
_iterator4 = _createForOfIteratorHelper(messagesToTransform);
|
|
1556
|
-
_context2.prev =
|
|
1560
|
+
_context2.prev = 163;
|
|
1557
1561
|
_iterator4.s();
|
|
1558
|
-
case
|
|
1562
|
+
case 165:
|
|
1559
1563
|
if ((_step4 = _iterator4.n()).done) {
|
|
1560
|
-
_context2.next =
|
|
1564
|
+
_context2.next = 176;
|
|
1561
1565
|
break;
|
|
1562
1566
|
}
|
|
1563
1567
|
_step4.value;
|
|
1564
|
-
_context2.next =
|
|
1568
|
+
_context2.next = 169;
|
|
1565
1569
|
return transformer({
|
|
1566
1570
|
message: messagesToTransform,
|
|
1567
1571
|
persona: persona,
|
|
@@ -1569,7 +1573,7 @@ var Spirits = {
|
|
|
1569
1573
|
messages: messages,
|
|
1570
1574
|
context: context
|
|
1571
1575
|
});
|
|
1572
|
-
case
|
|
1576
|
+
case 169:
|
|
1573
1577
|
transformResponse = _context2.sent;
|
|
1574
1578
|
progress('Generated response', 'success', undefined, undefined);
|
|
1575
1579
|
// Check if already had message
|
|
@@ -1589,37 +1593,37 @@ var Spirits = {
|
|
|
1589
1593
|
});
|
|
1590
1594
|
progress('Added agent message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1591
1595
|
}
|
|
1592
|
-
case
|
|
1593
|
-
_context2.next =
|
|
1596
|
+
case 174:
|
|
1597
|
+
_context2.next = 165;
|
|
1594
1598
|
break;
|
|
1595
|
-
case
|
|
1596
|
-
_context2.next =
|
|
1599
|
+
case 176:
|
|
1600
|
+
_context2.next = 181;
|
|
1597
1601
|
break;
|
|
1598
|
-
case
|
|
1599
|
-
_context2.prev =
|
|
1600
|
-
_context2.t4 = _context2["catch"](
|
|
1602
|
+
case 178:
|
|
1603
|
+
_context2.prev = 178;
|
|
1604
|
+
_context2.t4 = _context2["catch"](163);
|
|
1601
1605
|
_iterator4.e(_context2.t4);
|
|
1602
|
-
case
|
|
1603
|
-
_context2.prev =
|
|
1606
|
+
case 181:
|
|
1607
|
+
_context2.prev = 181;
|
|
1604
1608
|
_iterator4.f();
|
|
1605
|
-
return _context2.finish(
|
|
1606
|
-
case
|
|
1607
|
-
_context2.next =
|
|
1609
|
+
return _context2.finish(181);
|
|
1610
|
+
case 184:
|
|
1611
|
+
_context2.next = 191;
|
|
1608
1612
|
break;
|
|
1609
|
-
case
|
|
1610
|
-
_context2.prev =
|
|
1611
|
-
_context2.t5 = _context2["catch"](
|
|
1613
|
+
case 186:
|
|
1614
|
+
_context2.prev = 186;
|
|
1615
|
+
_context2.t5 = _context2["catch"](161);
|
|
1612
1616
|
console.error("Locking conversation, error transforming response: ".concat(_context2.t5.message));
|
|
1613
1617
|
conversation = lockConversation(conversation, 'API: ' + _context2.t5.message);
|
|
1614
1618
|
onError(_context2.t5);
|
|
1615
|
-
case
|
|
1616
|
-
_context2.next =
|
|
1619
|
+
case 191:
|
|
1620
|
+
_context2.next = 194;
|
|
1617
1621
|
break;
|
|
1618
|
-
case
|
|
1622
|
+
case 193:
|
|
1619
1623
|
if (messagesToTransform.length) {
|
|
1620
1624
|
console.warn("No transformer provided");
|
|
1621
1625
|
}
|
|
1622
|
-
case
|
|
1626
|
+
case 194:
|
|
1623
1627
|
progress('Parsing message', 'info', 'SET_PROCESSING', null);
|
|
1624
1628
|
return _context2.abrupt("return", {
|
|
1625
1629
|
conversation: {
|
|
@@ -1643,11 +1647,11 @@ var Spirits = {
|
|
|
1643
1647
|
followup: followup,
|
|
1644
1648
|
entityContextUpsert: entityContextUpsert
|
|
1645
1649
|
});
|
|
1646
|
-
case
|
|
1650
|
+
case 196:
|
|
1647
1651
|
case "end":
|
|
1648
1652
|
return _context2.stop();
|
|
1649
1653
|
}
|
|
1650
|
-
}, _callee, null, [[
|
|
1654
|
+
}, _callee, null, [[61, 136, 139, 142], [99, 108, 111, 114], [145, 155], [161, 186], [163, 178, 181, 184]]);
|
|
1651
1655
|
}));
|
|
1652
1656
|
function customer(_x) {
|
|
1653
1657
|
return _customer.apply(this, arguments);
|
package/dist/spirits.cjs
CHANGED
package/dist/testing-tools.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dev = require("./dev-
|
|
6
|
-
require("./spirits-
|
|
5
|
+
var dev = require("./dev-4ada3a05.cjs");
|
|
6
|
+
require("./spirits-eea2300e.cjs");
|
|
7
7
|
require('util');
|
|
8
8
|
require('stream');
|
|
9
9
|
require('path');
|
package/package.json
CHANGED
|
@@ -361,9 +361,13 @@ export const Spirits = {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
// 3. Run the contextualizer
|
|
364
|
+
progress('Running contextualizer', 'info', 'SET_PROCESSING', 'system')
|
|
364
365
|
const newContextMessages = await contextualizer({conversation, messages});
|
|
365
366
|
for (const contextMessage of newContextMessages) {
|
|
366
|
-
|
|
367
|
+
if (contextMessage.entities.length) {
|
|
368
|
+
messages.push(contextMessage);
|
|
369
|
+
progress(`Added context`, 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
370
|
+
}
|
|
367
371
|
}
|
|
368
372
|
|
|
369
373
|
// 4. Run the workflow
|