botium-core 1.13.4 → 1.13.5
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/botium-cjs.js +242 -82
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +242 -82
- package/dist/botium-es.js.map +1 -1
- package/package.json +19 -19
- package/src/scripting/CompilerXlsx.js +1 -0
- package/src/scripting/ScriptingMemory.js +41 -2
- package/src/scripting/ScriptingProvider.js +150 -52
- package/src/scripting/helper.js +2 -0
- package/src/scripting/logichook/userinput/MediaInput.js +2 -1
- package/test/compiler/compilercsv.spec.js +9 -2
- package/test/compiler/convos/csv/utterances_variable_row_len.csv +1 -1
- package/test/convo/fillAndApplyScriptingMemory.spec.js +64 -4
- package/test/convo/transcript.spec.js +9 -0
- package/test/scripting/asserters/intentConfidenceAsserter.spec.js +3 -7
- package/test/scripting/scriptingProvider.spec.js +156 -4
- package/test/scripting/utteranceexpansion/associateByIndex.spec.js +15 -15
package/dist/botium-cjs.js
CHANGED
|
@@ -81,7 +81,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
81
81
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
82
82
|
|
|
83
83
|
var name = "botium-core";
|
|
84
|
-
var version$1 = "1.13.
|
|
84
|
+
var version$1 = "1.13.5";
|
|
85
85
|
var description = "The Selenium for Chatbots";
|
|
86
86
|
var main = "index.js";
|
|
87
87
|
var module$1 = "dist/botium-es.js";
|
|
@@ -113,7 +113,7 @@ var bugs = {
|
|
|
113
113
|
};
|
|
114
114
|
var homepage = "https://www.botium.ai";
|
|
115
115
|
var dependencies = {
|
|
116
|
-
"@babel/runtime": "^7.
|
|
116
|
+
"@babel/runtime": "^7.19.0",
|
|
117
117
|
async: "^3.2.4",
|
|
118
118
|
"body-parser": "^1.20.0",
|
|
119
119
|
boolean: "^3.2.0",
|
|
@@ -123,7 +123,7 @@ var dependencies = {
|
|
|
123
123
|
esprima: "^4.0.1",
|
|
124
124
|
express: "^4.18.1",
|
|
125
125
|
globby: "11.0.4",
|
|
126
|
-
ioredis: "^5.
|
|
126
|
+
ioredis: "^5.2.3",
|
|
127
127
|
"is-class": "^0.0.9",
|
|
128
128
|
"is-json": "^2.0.1",
|
|
129
129
|
jsonpath: "^1.1.1",
|
|
@@ -140,13 +140,13 @@ var dependencies = {
|
|
|
140
140
|
rimraf: "^3.0.2",
|
|
141
141
|
"sanitize-filename": "^1.6.3",
|
|
142
142
|
slugify: "^1.6.5",
|
|
143
|
-
"socket.io": "^4.5.
|
|
144
|
-
"socket.io-client": "^4.5.
|
|
143
|
+
"socket.io": "^4.5.2",
|
|
144
|
+
"socket.io-client": "^4.5.2",
|
|
145
145
|
"socketio-auth": "^0.1.1",
|
|
146
|
-
"swagger-jsdoc": "^6.2.
|
|
147
|
-
"swagger-ui-express": "^4.
|
|
148
|
-
uuid: "^
|
|
149
|
-
vm2: "^3.9.
|
|
146
|
+
"swagger-jsdoc": "^6.2.5",
|
|
147
|
+
"swagger-ui-express": "^4.5.0",
|
|
148
|
+
uuid: "^9.0.0",
|
|
149
|
+
vm2: "^3.9.11",
|
|
150
150
|
"word-error-rate": "0.0.7",
|
|
151
151
|
"write-yaml": "^1.0.0",
|
|
152
152
|
xlsx: "^0.18.5",
|
|
@@ -154,27 +154,27 @@ var dependencies = {
|
|
|
154
154
|
yaml: "^2.1.1"
|
|
155
155
|
};
|
|
156
156
|
var devDependencies = {
|
|
157
|
-
"@babel/core": "^7.
|
|
158
|
-
"@babel/node": "^7.
|
|
159
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
160
|
-
"@babel/preset-env": "^7.
|
|
157
|
+
"@babel/core": "^7.19.3",
|
|
158
|
+
"@babel/node": "^7.19.1",
|
|
159
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
160
|
+
"@babel/preset-env": "^7.19.3",
|
|
161
161
|
chai: "^4.3.6",
|
|
162
162
|
"chai-as-promised": "^7.1.1",
|
|
163
163
|
"cross-env": "^7.0.3",
|
|
164
|
-
eslint: "^8.
|
|
164
|
+
eslint: "^8.24.0",
|
|
165
165
|
"eslint-config-standard": "^17.0.0",
|
|
166
166
|
"eslint-plugin-import": "^2.26.0",
|
|
167
167
|
"eslint-plugin-mocha": "^10.1.0",
|
|
168
|
-
"eslint-plugin-n": "^15.
|
|
169
|
-
"eslint-plugin-promise": "^6.0.
|
|
168
|
+
"eslint-plugin-n": "^15.3.0",
|
|
169
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
170
170
|
"eslint-plugin-standard": "^4.1.0",
|
|
171
171
|
"license-checker": "^25.0.1",
|
|
172
172
|
"license-compatibility-checker": "^0.3.5",
|
|
173
173
|
mocha: "^10.0.0",
|
|
174
|
-
nock: "^13.2.
|
|
175
|
-
"npm-check-updates": "^
|
|
174
|
+
nock: "^13.2.9",
|
|
175
|
+
"npm-check-updates": "^16.3.4",
|
|
176
176
|
nyc: "^15.1.0",
|
|
177
|
-
rollup: "^2.
|
|
177
|
+
rollup: "^2.79.1",
|
|
178
178
|
"rollup-plugin-babel": "^4.4.0",
|
|
179
179
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
180
180
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -2315,6 +2315,8 @@ const convoStepToLines$2 = step => {
|
|
|
2315
2315
|
lines.push('MEDIA ' + step.media[0].mediaUri);
|
|
2316
2316
|
} else if (step.messageText) {
|
|
2317
2317
|
lines.push(step.messageText);
|
|
2318
|
+
} else if (step.sourceData) {
|
|
2319
|
+
lines.push(JSON.stringify(step.sourceData, null, 2));
|
|
2318
2320
|
}
|
|
2319
2321
|
|
|
2320
2322
|
step.userInputs && step.userInputs.forEach(userInput => {
|
|
@@ -2507,6 +2509,34 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2507
2509
|
$timestamp: () => {
|
|
2508
2510
|
return Date.now();
|
|
2509
2511
|
},
|
|
2512
|
+
$tomorrow: pattern => {
|
|
2513
|
+
if (pattern) {
|
|
2514
|
+
return moment__default["default"]().add(1, 'day').format(pattern);
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
return moment__default["default"]().add(1, 'day').toDate().toLocaleDateString();
|
|
2518
|
+
},
|
|
2519
|
+
$yesterday: pattern => {
|
|
2520
|
+
if (pattern) {
|
|
2521
|
+
return moment__default["default"]().subtract(1, 'day').format(pattern);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
return moment__default["default"]().subtract(1, 'day').toDate().toLocaleDateString();
|
|
2525
|
+
},
|
|
2526
|
+
$date_add: (amount, unit, pattern) => {
|
|
2527
|
+
if (pattern) {
|
|
2528
|
+
return moment__default["default"]().add(amount, unit).format(pattern);
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
return moment__default["default"]().add(amount, unit).toDate().toLocaleDateString();
|
|
2532
|
+
},
|
|
2533
|
+
$date_subtract: (amount, unit, pattern) => {
|
|
2534
|
+
if (pattern) {
|
|
2535
|
+
return moment__default["default"]().subtract(amount, unit).format(pattern);
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
return moment__default["default"]().subtract(amount, unit).toDate().toLocaleDateString();
|
|
2539
|
+
},
|
|
2510
2540
|
$year: () => {
|
|
2511
2541
|
return new Date().getFullYear();
|
|
2512
2542
|
},
|
|
@@ -2598,7 +2628,8 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2598
2628
|
require: false,
|
|
2599
2629
|
env: caps[Capabilities.SECURITY_ALLOW_UNSAFE] ? process.env : {},
|
|
2600
2630
|
sandbox: {
|
|
2601
|
-
caps
|
|
2631
|
+
caps,
|
|
2632
|
+
moment: moment__default["default"]
|
|
2602
2633
|
}
|
|
2603
2634
|
});
|
|
2604
2635
|
return vm.run(`module.exports = (${code})`);
|
|
@@ -2676,7 +2707,22 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
|
|
|
2676
2707
|
for (const match of matches) {
|
|
2677
2708
|
if (match.indexOf('(') > 0) {
|
|
2678
2709
|
const arg = match.substring(match.indexOf('(') + 1, match.lastIndexOf(')')).replace(/\\\)/g, ')');
|
|
2679
|
-
|
|
2710
|
+
let args = [arg];
|
|
2711
|
+
|
|
2712
|
+
if (SCRIPTING_FUNCTIONS$1[key].numberOfArguments > 1) {
|
|
2713
|
+
args = arg.split(',');
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
args = args.map(arg => {
|
|
2717
|
+
arg = arg.trim();
|
|
2718
|
+
|
|
2719
|
+
if (arg.startsWith('"') && arg.endsWith('"')) {
|
|
2720
|
+
return arg.substring(1, arg.length - 1);
|
|
2721
|
+
} else {
|
|
2722
|
+
return arg;
|
|
2723
|
+
}
|
|
2724
|
+
});
|
|
2725
|
+
str = str.replace(match, SCRIPTING_FUNCTIONS$1[key].handler(caps, ...args, mockMsg));
|
|
2680
2726
|
} else {
|
|
2681
2727
|
str = str.replace(match, SCRIPTING_FUNCTIONS$1[key].handler(caps));
|
|
2682
2728
|
}
|
|
@@ -4875,7 +4921,8 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4875
4921
|
convoResults.forEach(convo => {
|
|
4876
4922
|
if (!convo.header.name) {
|
|
4877
4923
|
convo.header.name = `${convo.header.sheetname}-${this.colnames[convo.header.colindex]}${formatRowIndex(convo.header.rowindex)}`;
|
|
4878
|
-
}
|
|
4924
|
+
} // it is not used anymore?
|
|
4925
|
+
|
|
4879
4926
|
|
|
4880
4927
|
convo.header.sort = convo.header.name;
|
|
4881
4928
|
scriptResults.push(convo);
|
|
@@ -7050,30 +7097,77 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7050
7097
|
this._sortConvos();
|
|
7051
7098
|
}
|
|
7052
7099
|
|
|
7053
|
-
ExpandConvos() {
|
|
7100
|
+
ExpandConvos(options = {}) {
|
|
7101
|
+
options = Object.assign({
|
|
7102
|
+
// use skip and keep, or justHeader
|
|
7103
|
+
justHeader: false,
|
|
7104
|
+
// drop unwanted convos
|
|
7105
|
+
convoFilter: null
|
|
7106
|
+
}, options);
|
|
7107
|
+
const context = {
|
|
7108
|
+
count: 0
|
|
7109
|
+
};
|
|
7054
7110
|
const expandedConvos = [];
|
|
7055
7111
|
debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
|
|
7056
7112
|
this.convos.forEach(convo => {
|
|
7057
7113
|
convo.expandPartialConvos();
|
|
7058
7114
|
|
|
7059
|
-
this._expandConvo(
|
|
7115
|
+
for (const expanded of this._expandConvo(convo, options, context)) {
|
|
7116
|
+
expanded.header.assertionCount = this.GetAssertionCount(expanded);
|
|
7117
|
+
|
|
7118
|
+
if (options.justHeader) {
|
|
7119
|
+
const ConvoWithOnlyHeader = {
|
|
7120
|
+
header: {
|
|
7121
|
+
name: expanded.header.name,
|
|
7122
|
+
assertionCount: expanded.header.assertionCount
|
|
7123
|
+
}
|
|
7124
|
+
};
|
|
7125
|
+
expandedConvos.push(ConvoWithOnlyHeader);
|
|
7126
|
+
} else {
|
|
7127
|
+
expandedConvos.push(expanded);
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7060
7130
|
});
|
|
7061
7131
|
this.convos = expandedConvos;
|
|
7062
7132
|
|
|
7063
|
-
|
|
7133
|
+
if (!options.justHeader) {
|
|
7134
|
+
this._sortConvos();
|
|
7135
|
+
} else {
|
|
7136
|
+
this._updateConvos();
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
|
|
7140
|
+
ExpandConvosIterable(options = {}) {
|
|
7141
|
+
options = Object.assign({
|
|
7142
|
+
// drop unwanted convos
|
|
7143
|
+
convoFilter: null
|
|
7144
|
+
}, options);
|
|
7145
|
+
debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`); // creating a nested generator, calling the other.
|
|
7146
|
+
// We hope this.convos does not changes while this iterator is used
|
|
7147
|
+
|
|
7148
|
+
const _convosIterable = function* (options) {
|
|
7149
|
+
const context = {
|
|
7150
|
+
count: 0
|
|
7151
|
+
};
|
|
7152
|
+
|
|
7153
|
+
for (const convo of this.convos) {
|
|
7154
|
+
convo.expandPartialConvos();
|
|
7155
|
+
yield* this._expandConvo(convo, options, context);
|
|
7156
|
+
}
|
|
7157
|
+
}.bind(this);
|
|
7158
|
+
|
|
7159
|
+
this.convosIterable = _convosIterable(options);
|
|
7064
7160
|
}
|
|
7065
7161
|
/**
|
|
7066
|
-
*
|
|
7067
|
-
* @param expandedConvos
|
|
7162
|
+
* This is a generator function with yield
|
|
7068
7163
|
* @param currentConvo
|
|
7069
7164
|
* @param convoStepIndex
|
|
7070
7165
|
* @param convoStepsStack list of ConvoSteps
|
|
7071
|
-
* @param context {width: }
|
|
7072
7166
|
* @private
|
|
7073
7167
|
*/
|
|
7074
7168
|
|
|
7075
7169
|
|
|
7076
|
-
_expandConvo(
|
|
7170
|
+
*_expandConvo(currentConvo, options, context, convoStepIndex = 0, convoStepsStack = []) {
|
|
7077
7171
|
const utterancePostfix = (lineTag, uttOrUserInput) => {
|
|
7078
7172
|
const naming = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE] || Defaults$1.capabilities[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE];
|
|
7079
7173
|
|
|
@@ -7099,8 +7193,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7099
7193
|
if (currentStep.sender === 'bot' || currentStep.sender === 'begin' || currentStep.sender === 'end') {
|
|
7100
7194
|
const currentStepsStack = convoStepsStack.slice();
|
|
7101
7195
|
currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
|
|
7102
|
-
|
|
7103
|
-
this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
|
|
7196
|
+
yield* this._expandConvo(currentConvo, options, context, convoStepIndex + 1, currentStepsStack);
|
|
7104
7197
|
} else if (currentStep.sender === 'me') {
|
|
7105
7198
|
let useUnexpanded = true;
|
|
7106
7199
|
|
|
@@ -7122,16 +7215,15 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7122
7215
|
if (this.utterances[uttName]) {
|
|
7123
7216
|
const allutterances = this.utterances[uttName].utterances;
|
|
7124
7217
|
|
|
7125
|
-
const processSampleUtterances = (sampleutterances, myContext)
|
|
7126
|
-
sampleutterances.
|
|
7127
|
-
processSampleUtterance(
|
|
7218
|
+
const processSampleUtterances = function* (sampleutterances, myContext) {
|
|
7219
|
+
for (let index = 0; index < sampleutterances.length; index++) {
|
|
7220
|
+
yield* processSampleUtterance(sampleutterances[index], sampleutterances.length, index, Object.assign({
|
|
7128
7221
|
indexExpansionModeIndex: index
|
|
7129
7222
|
}, myContext || context));
|
|
7130
|
-
}
|
|
7223
|
+
}
|
|
7131
7224
|
};
|
|
7132
7225
|
|
|
7133
|
-
const processSampleUtterance = (sampleutterance, length, index, myContext)
|
|
7134
|
-
const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
|
|
7226
|
+
const processSampleUtterance = function* (sampleutterance, length, index, myContext) {
|
|
7135
7227
|
const currentStepsStack = convoStepsStack.slice();
|
|
7136
7228
|
|
|
7137
7229
|
if (uttArgs) {
|
|
@@ -7144,19 +7236,24 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7144
7236
|
|
|
7145
7237
|
const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
|
|
7146
7238
|
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7239
|
+
if (length > 1) {
|
|
7240
|
+
const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
|
|
7241
|
+
Object.assign(currentConvoLabeled.header, {
|
|
7242
|
+
name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, sampleutterance)}`
|
|
7243
|
+
});
|
|
7244
|
+
}
|
|
7245
|
+
|
|
7150
7246
|
if (!currentConvoLabeled.sourceTag) currentConvoLabeled.sourceTag = {};
|
|
7151
7247
|
if (!currentConvoLabeled.sourceTag.origConvoName) currentConvoLabeled.sourceTag.origConvoName = currentConvo.header.name;
|
|
7248
|
+
yield* this._expandConvo(currentConvoLabeled, options, myContext || context, convoStepIndex + 1, currentStepsStack);
|
|
7249
|
+
}.bind(this);
|
|
7152
7250
|
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
|
|
7251
|
+
if (allutterances.length === 1) {
|
|
7252
|
+
yield* processSampleUtterances([allutterances[0]], context);
|
|
7253
|
+
} else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
|
|
7157
7254
|
if (lodash__default["default"].isNil(context.indexExpansionModeWidth)) {
|
|
7158
7255
|
// executed for the first found utterance
|
|
7159
|
-
processSampleUtterances(allutterances, Object.assign({}, context, {
|
|
7256
|
+
yield* processSampleUtterances(allutterances, Object.assign({}, context, {
|
|
7160
7257
|
indexExpansionModeWidth: allutterances.length
|
|
7161
7258
|
}));
|
|
7162
7259
|
} else {
|
|
@@ -7174,7 +7271,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7174
7271
|
const myContext = Object.assign({}, context, {
|
|
7175
7272
|
indexExpansionModeWidth: Math.max(allutterances.length, context.indexExpansionModeWidth)
|
|
7176
7273
|
});
|
|
7177
|
-
processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
|
|
7274
|
+
yield* processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
|
|
7178
7275
|
|
|
7179
7276
|
if (allutterances.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
|
|
7180
7277
|
debug$9(`While expanding convos by index found in utterance "${uttName}" more examples (${allutterances.length}) as expected (${context.indexExpansionModeWidth})`);
|
|
@@ -7185,20 +7282,20 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7185
7282
|
indexExpansionModeWidth: allutterances.length,
|
|
7186
7283
|
indexExpansionModeIndex: i
|
|
7187
7284
|
});
|
|
7188
|
-
processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
|
|
7285
|
+
yield* processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
|
|
7189
7286
|
}
|
|
7190
7287
|
}
|
|
7191
7288
|
}
|
|
7192
7289
|
} else {
|
|
7193
7290
|
if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
|
|
7194
|
-
processSampleUtterances([allutterances[0]]);
|
|
7291
|
+
yield* processSampleUtterances([allutterances[0]], context);
|
|
7195
7292
|
} else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
|
|
7196
|
-
processSampleUtterances(allutterances.map(x => ({
|
|
7293
|
+
yield* processSampleUtterances(allutterances.map(x => ({
|
|
7197
7294
|
x,
|
|
7198
7295
|
r: Math.random()
|
|
7199
|
-
})).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]));
|
|
7296
|
+
})).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]), context);
|
|
7200
7297
|
} else {
|
|
7201
|
-
processSampleUtterances(allutterances);
|
|
7298
|
+
yield* processSampleUtterances(allutterances, context);
|
|
7202
7299
|
}
|
|
7203
7300
|
}
|
|
7204
7301
|
|
|
@@ -7207,7 +7304,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7207
7304
|
}
|
|
7208
7305
|
|
|
7209
7306
|
if (currentStep.userInputs && currentStep.userInputs.length > 0) {
|
|
7210
|
-
currentStep.userInputs.
|
|
7307
|
+
for (let uiIndex = 0; uiIndex < currentStep.userInputs.length; uiIndex++) {
|
|
7308
|
+
const ui = currentStep.userInputs[uiIndex];
|
|
7211
7309
|
const userInput = this.userInputs[ui.name];
|
|
7212
7310
|
|
|
7213
7311
|
if (userInput && userInput.expandConvo) {
|
|
@@ -7219,16 +7317,15 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7219
7317
|
|
|
7220
7318
|
if (expandedUserInputs && expandedUserInputs.length > 0) {
|
|
7221
7319
|
// let sampleinputs = expandedUserInputs
|
|
7222
|
-
const processSampleInputs = (sampleinputs, myContext, uiIndex)
|
|
7223
|
-
sampleinputs.
|
|
7224
|
-
processSampleInput(
|
|
7320
|
+
const processSampleInputs = function* (sampleinputs, myContext, uiIndex) {
|
|
7321
|
+
for (let index = 0; index < sampleinputs.length; index++) {
|
|
7322
|
+
yield* processSampleInput(sampleinputs[index], sampleinputs.length, index, Object.assign({
|
|
7225
7323
|
indexExpansionModeIndex: index
|
|
7226
7324
|
}, myContext || context), uiIndex);
|
|
7227
|
-
}
|
|
7325
|
+
}
|
|
7228
7326
|
};
|
|
7229
7327
|
|
|
7230
|
-
const processSampleInput = (sampleinput, length, index, myContext, uiIndex)
|
|
7231
|
-
const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
|
|
7328
|
+
const processSampleInput = function* (sampleinput, length, index, myContext, uiIndex) {
|
|
7232
7329
|
const currentStepsStack = convoStepsStack.slice();
|
|
7233
7330
|
|
|
7234
7331
|
const currentStepMod = lodash__default["default"].cloneDeep(currentStep);
|
|
@@ -7238,16 +7335,27 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7238
7335
|
|
|
7239
7336
|
const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
|
|
7240
7337
|
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7338
|
+
if (length > 1) {
|
|
7339
|
+
if (sampleinput.convoPostfix) {
|
|
7340
|
+
Object.assign(currentConvoLabeled.header, {
|
|
7341
|
+
name: `${currentConvo.header.name}/${ui.name}-${sampleinput.convoPostfix}`
|
|
7342
|
+
});
|
|
7343
|
+
} else {
|
|
7344
|
+
const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
|
|
7345
|
+
Object.assign(currentConvoLabeled.header, {
|
|
7346
|
+
name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
|
|
7347
|
+
});
|
|
7348
|
+
}
|
|
7349
|
+
}
|
|
7244
7350
|
|
|
7245
|
-
this._expandConvo(
|
|
7246
|
-
};
|
|
7351
|
+
yield* this._expandConvo(currentConvoLabeled, options, myContext || context, convoStepIndex + 1, currentStepsStack);
|
|
7352
|
+
}.bind(this);
|
|
7247
7353
|
|
|
7248
|
-
if (
|
|
7354
|
+
if (expandedUserInputs.length === 1) {
|
|
7355
|
+
yield* processSampleInputs([expandedUserInputs[0]], context, uiIndex);
|
|
7356
|
+
} else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
|
|
7249
7357
|
if (lodash__default["default"].isNil(context.indexExpansionModeWidth)) {
|
|
7250
|
-
processSampleInputs(expandedUserInputs, Object.assign({}, context, {
|
|
7358
|
+
yield* processSampleInputs(expandedUserInputs, Object.assign({}, context, {
|
|
7251
7359
|
indexExpansionModeWidth: expandedUserInputs.length
|
|
7252
7360
|
}), uiIndex);
|
|
7253
7361
|
} else {
|
|
@@ -7265,7 +7373,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7265
7373
|
const myContext = Object.assign({}, context, {
|
|
7266
7374
|
indexExpansionModeWidth: Math.max(expandedUserInputs.length, context.indexExpansionModeWidth)
|
|
7267
7375
|
});
|
|
7268
|
-
processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
|
|
7376
|
+
yield* processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
|
|
7269
7377
|
|
|
7270
7378
|
if (expandedUserInputs.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
|
|
7271
7379
|
debug$9(`While expanding convos by index found user input "${ui.name}, ${ui.args}" more examples (${expandedUserInputs.length}) as expected (${context.indexExpansionModeWidth})`);
|
|
@@ -7275,55 +7383,72 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7275
7383
|
indexExpansionModeWidth: expandedUserInputs.length,
|
|
7276
7384
|
indexExpansionModeIndex: i
|
|
7277
7385
|
});
|
|
7278
|
-
processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
|
|
7386
|
+
yield* processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
|
|
7279
7387
|
}
|
|
7280
7388
|
}
|
|
7281
7389
|
}
|
|
7282
7390
|
} else {
|
|
7283
7391
|
if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
|
|
7284
|
-
processSampleInputs([expandedUserInputs[0]], context, uiIndex);
|
|
7392
|
+
yield* processSampleInputs([expandedUserInputs[0]], context, uiIndex);
|
|
7285
7393
|
} else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
|
|
7286
|
-
processSampleInputs(expandedUserInputs.map(x => ({
|
|
7394
|
+
yield* processSampleInputs(expandedUserInputs.map(x => ({
|
|
7287
7395
|
x,
|
|
7288
7396
|
r: Math.random()
|
|
7289
7397
|
})).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]), context, uiIndex);
|
|
7290
7398
|
} else {
|
|
7291
|
-
processSampleInputs(expandedUserInputs, context, uiIndex);
|
|
7399
|
+
yield* processSampleInputs(expandedUserInputs, context, uiIndex);
|
|
7292
7400
|
}
|
|
7293
7401
|
}
|
|
7294
7402
|
|
|
7295
7403
|
useUnexpanded = false;
|
|
7296
7404
|
}
|
|
7297
7405
|
}
|
|
7298
|
-
}
|
|
7406
|
+
}
|
|
7299
7407
|
}
|
|
7300
7408
|
|
|
7301
7409
|
if (useUnexpanded) {
|
|
7302
7410
|
const currentStepsStack = convoStepsStack.slice();
|
|
7303
7411
|
currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
|
|
7304
|
-
|
|
7305
|
-
this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
|
|
7412
|
+
yield* this._expandConvo(currentConvo, options, context, convoStepIndex + 1, currentStepsStack);
|
|
7306
7413
|
}
|
|
7307
7414
|
}
|
|
7308
7415
|
} else {
|
|
7309
|
-
|
|
7416
|
+
const expanded = Object.assign(lodash__default["default"].cloneDeep(currentConvo), {
|
|
7310
7417
|
conversation: lodash__default["default"].cloneDeep(convoStepsStack)
|
|
7311
|
-
})
|
|
7418
|
+
});
|
|
7419
|
+
|
|
7420
|
+
if (!options.convoFilter || options.convoFilter(expanded)) {
|
|
7421
|
+
context.count++;
|
|
7422
|
+
const logPerEntry = context.count < 10 ? 1 : context.count < 100 ? 10 : context.count < 1000 ? 100 : context.count < 10000 ? 1000 : 10000;
|
|
7423
|
+
|
|
7424
|
+
if (context.count % logPerEntry === 0) {
|
|
7425
|
+
debug$9(`Convo #${context.count} expanded (${expanded.header.name})`);
|
|
7426
|
+
}
|
|
7427
|
+
|
|
7428
|
+
yield expanded;
|
|
7429
|
+
}
|
|
7312
7430
|
}
|
|
7313
7431
|
}
|
|
7314
7432
|
|
|
7315
7433
|
_sortConvos() {
|
|
7316
7434
|
this.convos = lodash__default["default"].sortBy(this.convos, [convo => convo.header.sort || convo.header.name]);
|
|
7435
|
+
|
|
7436
|
+
this._updateConvos();
|
|
7437
|
+
}
|
|
7438
|
+
|
|
7439
|
+
_updateConvos() {
|
|
7317
7440
|
let i = 0;
|
|
7318
7441
|
this.convos.forEach(convo => {
|
|
7319
|
-
convo
|
|
7442
|
+
if (convo) {
|
|
7443
|
+
convo.header.order = ++i;
|
|
7320
7444
|
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7445
|
+
if (!convo.header.projectname) {
|
|
7446
|
+
convo.header.projectname = this.caps[Capabilities.PROJECTNAME];
|
|
7447
|
+
}
|
|
7324
7448
|
|
|
7325
|
-
|
|
7326
|
-
|
|
7449
|
+
if (!convo.header.testsessionname) {
|
|
7450
|
+
convo.header.testsessionname = this.caps[Capabilities.TESTSESSIONNAME];
|
|
7451
|
+
}
|
|
7327
7452
|
}
|
|
7328
7453
|
});
|
|
7329
7454
|
}
|
|
@@ -7335,7 +7460,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7335
7460
|
this.convos.push(convos);
|
|
7336
7461
|
}
|
|
7337
7462
|
|
|
7338
|
-
this.
|
|
7463
|
+
if (this.convos.filter(c => lodash__default["default"].isNil(c))) {
|
|
7464
|
+
this._updateConvos();
|
|
7465
|
+
} else {
|
|
7466
|
+
this._sortConvos();
|
|
7467
|
+
}
|
|
7339
7468
|
}
|
|
7340
7469
|
|
|
7341
7470
|
AddUtterances(utterances) {
|
|
@@ -7611,6 +7740,37 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7611
7740
|
return ['digraph {', ...nodes, ...lines, '}'].join('\r\n');
|
|
7612
7741
|
}
|
|
7613
7742
|
|
|
7743
|
+
GetAssertionCount(convo) {
|
|
7744
|
+
if (!convo) {
|
|
7745
|
+
return 0;
|
|
7746
|
+
}
|
|
7747
|
+
|
|
7748
|
+
let counter = 0;
|
|
7749
|
+
|
|
7750
|
+
for (const step of convo.conversation) {
|
|
7751
|
+
if (step.sender === 'bot') {
|
|
7752
|
+
let stepCounter = step.asserters ? step.asserters.length : 0;
|
|
7753
|
+
|
|
7754
|
+
if (step.messageText) {
|
|
7755
|
+
stepCounter++;
|
|
7756
|
+
}
|
|
7757
|
+
|
|
7758
|
+
stepCounter = stepCounter === 0 ? 1 : stepCounter;
|
|
7759
|
+
counter += stepCounter;
|
|
7760
|
+
}
|
|
7761
|
+
}
|
|
7762
|
+
|
|
7763
|
+
if (convo.convoBegin && convo.convoBegin.asserters) {
|
|
7764
|
+
counter += convo.convoBegin.asserters.length;
|
|
7765
|
+
}
|
|
7766
|
+
|
|
7767
|
+
if (convo.convoEnd && convo.convoEnd.asserters) {
|
|
7768
|
+
counter += convo.convoEnd.asserters.length;
|
|
7769
|
+
}
|
|
7770
|
+
|
|
7771
|
+
return counter === 0 ? 1 : counter;
|
|
7772
|
+
}
|
|
7773
|
+
|
|
7614
7774
|
};
|
|
7615
7775
|
|
|
7616
7776
|
var BaseRepo_1 = class BaseRepo {
|