botium-core 1.13.3 → 1.13.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/botium-cjs.js +74 -26
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +74 -26
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/Capabilities.js +2 -0
- package/src/Defaults.js +4 -0
- package/src/mocks/BotiumMockScripting.js +1 -0
- package/src/scripting/ScriptingProvider.js +56 -32
- package/test/scripting/scriptingProvider.spec.js +57 -0
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.4";
|
|
85
85
|
var description = "The Selenium for Chatbots";
|
|
86
86
|
var main = "index.js";
|
|
87
87
|
var module$1 = "dist/botium-es.js";
|
|
@@ -351,6 +351,8 @@ var Capabilities = {
|
|
|
351
351
|
SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
|
|
352
352
|
SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 'SCRIPTING_UTTEXPANSION_RANDOM_COUNT',
|
|
353
353
|
SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSION',
|
|
354
|
+
SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS',
|
|
355
|
+
SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS',
|
|
354
356
|
SCRIPTING_UTTEXPANSION_USENAMEASINTENT: 'SCRIPTING_UTTEXPANSION_USENAMEASINTENT',
|
|
355
357
|
// justLineTag, utterance
|
|
356
358
|
SCRIPTING_UTTEXPANSION_NAMING_MODE: 'SCRIPTING_UTTEXPANSION_NAMING_MODE',
|
|
@@ -504,6 +506,8 @@ Capabilities.SCRIPTING_MATCHING_MODE_ARGS;
|
|
|
504
506
|
Capabilities.SCRIPTING_UTTEXPANSION_MODE;
|
|
505
507
|
Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT;
|
|
506
508
|
Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION;
|
|
509
|
+
Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS;
|
|
510
|
+
Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS;
|
|
507
511
|
Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT;
|
|
508
512
|
Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
|
|
509
513
|
Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
|
|
@@ -588,6 +592,10 @@ var Defaults$1 = {
|
|
|
588
592
|
[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]: 1,
|
|
589
593
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
|
|
590
594
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
|
|
595
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION]: null,
|
|
596
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS]: [],
|
|
597
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS]: [],
|
|
598
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT]: false,
|
|
591
599
|
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
|
|
592
600
|
[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
|
|
593
601
|
[Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
|
|
@@ -1725,6 +1733,7 @@ class BotiumMockAsserter$1 {
|
|
|
1725
1733
|
constructor(fromJson = {}) {
|
|
1726
1734
|
this.name = fromJson.name;
|
|
1727
1735
|
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1736
|
+
this.not = fromJson.not;
|
|
1728
1737
|
}
|
|
1729
1738
|
|
|
1730
1739
|
}
|
|
@@ -6932,6 +6941,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6932
6941
|
|
|
6933
6942
|
ExpandUtterancesToConvos({
|
|
6934
6943
|
useNameAsIntent,
|
|
6944
|
+
incomprehensionIntents,
|
|
6945
|
+
incomprehensionUtts,
|
|
6935
6946
|
incomprehensionUtt
|
|
6936
6947
|
} = {}) {
|
|
6937
6948
|
const expandedConvos = [];
|
|
@@ -6940,26 +6951,81 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6940
6951
|
useNameAsIntent = !!this.caps[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT];
|
|
6941
6952
|
}
|
|
6942
6953
|
|
|
6954
|
+
if (lodash__default["default"].isUndefined(incomprehensionIntents)) {
|
|
6955
|
+
incomprehensionIntents = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS];
|
|
6956
|
+
}
|
|
6957
|
+
|
|
6958
|
+
if (lodash__default["default"].isUndefined(incomprehensionUtts)) {
|
|
6959
|
+
incomprehensionUtts = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS];
|
|
6960
|
+
}
|
|
6961
|
+
|
|
6943
6962
|
if (lodash__default["default"].isUndefined(incomprehensionUtt)) {
|
|
6944
6963
|
incomprehensionUtt = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION];
|
|
6945
6964
|
}
|
|
6946
6965
|
|
|
6947
|
-
if (
|
|
6948
|
-
throw new Error(
|
|
6966
|
+
if (incomprehensionUtt && (!incomprehensionUtts || incomprehensionUtts.length === 0) && !this.utterances[incomprehensionUtt]) {
|
|
6967
|
+
throw new Error(`ExpandUtterancesToConvos - incomprehension utterance '${incomprehensionUtt}' undefined (and no user examples given)`);
|
|
6949
6968
|
}
|
|
6950
6969
|
|
|
6951
|
-
if (
|
|
6952
|
-
|
|
6970
|
+
if (incomprehensionUtts && incomprehensionUtts.length > 0) {
|
|
6971
|
+
if (!incomprehensionUtt) {
|
|
6972
|
+
incomprehensionUtt = 'UTT_INCOMPREHENSION';
|
|
6973
|
+
}
|
|
6974
|
+
|
|
6975
|
+
if (this.utterances[incomprehensionUtt]) {
|
|
6976
|
+
this.utterances[incomprehensionUtt].utterances.push(...incomprehensionUtts);
|
|
6977
|
+
} else {
|
|
6978
|
+
this.utterances[incomprehensionUtt] = {
|
|
6979
|
+
name: incomprehensionUtt,
|
|
6980
|
+
utterances: [...incomprehensionUtts]
|
|
6981
|
+
};
|
|
6982
|
+
}
|
|
6953
6983
|
}
|
|
6954
6984
|
|
|
6955
6985
|
if (useNameAsIntent) {
|
|
6956
6986
|
debug$9('ExpandUtterancesToConvos - Using utterance name as NLU intent');
|
|
6957
|
-
}
|
|
6958
|
-
|
|
6987
|
+
}
|
|
6988
|
+
|
|
6989
|
+
if (incomprehensionIntents && incomprehensionIntents.length > 0) {
|
|
6990
|
+
debug$9(`ExpandUtterancesToConvos - Using ${incomprehensionIntents.length} incomprehension NLU intent(s)`);
|
|
6991
|
+
}
|
|
6992
|
+
|
|
6993
|
+
if (incomprehensionUtt) {
|
|
6994
|
+
debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}, ${this.utterances[incomprehensionUtt].utterances.length} user example(s)`);
|
|
6959
6995
|
}
|
|
6960
6996
|
|
|
6961
6997
|
lodash__default["default"].keys(this.utterances).filter(u => u !== incomprehensionUtt).forEach(uttName => {
|
|
6962
6998
|
const utt = this.utterances[uttName];
|
|
6999
|
+
const responseStep = {
|
|
7000
|
+
sender: 'bot',
|
|
7001
|
+
messageText: '',
|
|
7002
|
+
asserters: [],
|
|
7003
|
+
stepTag: 'Step 2 - check bot response',
|
|
7004
|
+
not: false
|
|
7005
|
+
};
|
|
7006
|
+
|
|
7007
|
+
if (useNameAsIntent) {
|
|
7008
|
+
responseStep.asserters.push({
|
|
7009
|
+
name: 'INTENT',
|
|
7010
|
+
args: [utt.name]
|
|
7011
|
+
});
|
|
7012
|
+
}
|
|
7013
|
+
|
|
7014
|
+
if (incomprehensionIntents && incomprehensionIntents.length > 0) {
|
|
7015
|
+
incomprehensionIntents.forEach(ii => {
|
|
7016
|
+
responseStep.asserters.push({
|
|
7017
|
+
name: 'INTENT',
|
|
7018
|
+
args: [ii],
|
|
7019
|
+
not: true
|
|
7020
|
+
});
|
|
7021
|
+
});
|
|
7022
|
+
}
|
|
7023
|
+
|
|
7024
|
+
if (incomprehensionUtt) {
|
|
7025
|
+
responseStep.messageText = incomprehensionUtt;
|
|
7026
|
+
responseStep.not = true;
|
|
7027
|
+
}
|
|
7028
|
+
|
|
6963
7029
|
expandedConvos.push(new Convo(this._buildScriptContext(), {
|
|
6964
7030
|
header: {
|
|
6965
7031
|
name: utt.name,
|
|
@@ -6972,25 +7038,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6972
7038
|
}],
|
|
6973
7039
|
messageText: utt.name,
|
|
6974
7040
|
stepTag: 'Step 1 - tell utterance'
|
|
6975
|
-
},
|
|
6976
|
-
sender: 'bot',
|
|
6977
|
-
asserters: [{
|
|
6978
|
-
name: 'INTENT',
|
|
6979
|
-
args: [utt.name]
|
|
6980
|
-
}],
|
|
6981
|
-
stepTag: 'Step 2 - check intent',
|
|
6982
|
-
not: false
|
|
6983
|
-
} : incomprehensionUtt ? {
|
|
6984
|
-
sender: 'bot',
|
|
6985
|
-
messageText: incomprehensionUtt,
|
|
6986
|
-
stepTag: 'Step 2 - check incomprehension',
|
|
6987
|
-
not: true
|
|
6988
|
-
} : {
|
|
6989
|
-
sender: 'bot',
|
|
6990
|
-
messageText: '',
|
|
6991
|
-
stepTag: 'Step 2 - check bot response',
|
|
6992
|
-
not: false
|
|
6993
|
-
}],
|
|
7041
|
+
}, responseStep],
|
|
6994
7042
|
sourceTag: Object.assign({}, utt.sourceTag, {
|
|
6995
7043
|
origUttName: utt.name
|
|
6996
7044
|
})
|