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-es.js
CHANGED
|
@@ -37,7 +37,7 @@ import express from 'express';
|
|
|
37
37
|
import bodyParser from 'body-parser';
|
|
38
38
|
|
|
39
39
|
var name = "botium-core";
|
|
40
|
-
var version$1 = "1.13.
|
|
40
|
+
var version$1 = "1.13.4";
|
|
41
41
|
var description = "The Selenium for Chatbots";
|
|
42
42
|
var main = "index.js";
|
|
43
43
|
var module = "dist/botium-es.js";
|
|
@@ -307,6 +307,8 @@ var Capabilities = {
|
|
|
307
307
|
SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
|
|
308
308
|
SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 'SCRIPTING_UTTEXPANSION_RANDOM_COUNT',
|
|
309
309
|
SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSION',
|
|
310
|
+
SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS',
|
|
311
|
+
SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS',
|
|
310
312
|
SCRIPTING_UTTEXPANSION_USENAMEASINTENT: 'SCRIPTING_UTTEXPANSION_USENAMEASINTENT',
|
|
311
313
|
// justLineTag, utterance
|
|
312
314
|
SCRIPTING_UTTEXPANSION_NAMING_MODE: 'SCRIPTING_UTTEXPANSION_NAMING_MODE',
|
|
@@ -460,6 +462,8 @@ Capabilities.SCRIPTING_MATCHING_MODE_ARGS;
|
|
|
460
462
|
Capabilities.SCRIPTING_UTTEXPANSION_MODE;
|
|
461
463
|
Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT;
|
|
462
464
|
Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION;
|
|
465
|
+
Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS;
|
|
466
|
+
Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS;
|
|
463
467
|
Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT;
|
|
464
468
|
Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
|
|
465
469
|
Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
|
|
@@ -544,6 +548,10 @@ var Defaults$1 = {
|
|
|
544
548
|
[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]: 1,
|
|
545
549
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
|
|
546
550
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
|
|
551
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION]: null,
|
|
552
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS]: [],
|
|
553
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS]: [],
|
|
554
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT]: false,
|
|
547
555
|
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
|
|
548
556
|
[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
|
|
549
557
|
[Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
|
|
@@ -1681,6 +1689,7 @@ class BotiumMockAsserter$1 {
|
|
|
1681
1689
|
constructor(fromJson = {}) {
|
|
1682
1690
|
this.name = fromJson.name;
|
|
1683
1691
|
this.args = lodash.cloneDeep(fromJson.args);
|
|
1692
|
+
this.not = fromJson.not;
|
|
1684
1693
|
}
|
|
1685
1694
|
|
|
1686
1695
|
}
|
|
@@ -6888,6 +6897,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6888
6897
|
|
|
6889
6898
|
ExpandUtterancesToConvos({
|
|
6890
6899
|
useNameAsIntent,
|
|
6900
|
+
incomprehensionIntents,
|
|
6901
|
+
incomprehensionUtts,
|
|
6891
6902
|
incomprehensionUtt
|
|
6892
6903
|
} = {}) {
|
|
6893
6904
|
const expandedConvos = [];
|
|
@@ -6896,26 +6907,81 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6896
6907
|
useNameAsIntent = !!this.caps[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT];
|
|
6897
6908
|
}
|
|
6898
6909
|
|
|
6910
|
+
if (lodash.isUndefined(incomprehensionIntents)) {
|
|
6911
|
+
incomprehensionIntents = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS];
|
|
6912
|
+
}
|
|
6913
|
+
|
|
6914
|
+
if (lodash.isUndefined(incomprehensionUtts)) {
|
|
6915
|
+
incomprehensionUtts = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS];
|
|
6916
|
+
}
|
|
6917
|
+
|
|
6899
6918
|
if (lodash.isUndefined(incomprehensionUtt)) {
|
|
6900
6919
|
incomprehensionUtt = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION];
|
|
6901
6920
|
}
|
|
6902
6921
|
|
|
6903
|
-
if (
|
|
6904
|
-
throw new Error(
|
|
6922
|
+
if (incomprehensionUtt && (!incomprehensionUtts || incomprehensionUtts.length === 0) && !this.utterances[incomprehensionUtt]) {
|
|
6923
|
+
throw new Error(`ExpandUtterancesToConvos - incomprehension utterance '${incomprehensionUtt}' undefined (and no user examples given)`);
|
|
6905
6924
|
}
|
|
6906
6925
|
|
|
6907
|
-
if (
|
|
6908
|
-
|
|
6926
|
+
if (incomprehensionUtts && incomprehensionUtts.length > 0) {
|
|
6927
|
+
if (!incomprehensionUtt) {
|
|
6928
|
+
incomprehensionUtt = 'UTT_INCOMPREHENSION';
|
|
6929
|
+
}
|
|
6930
|
+
|
|
6931
|
+
if (this.utterances[incomprehensionUtt]) {
|
|
6932
|
+
this.utterances[incomprehensionUtt].utterances.push(...incomprehensionUtts);
|
|
6933
|
+
} else {
|
|
6934
|
+
this.utterances[incomprehensionUtt] = {
|
|
6935
|
+
name: incomprehensionUtt,
|
|
6936
|
+
utterances: [...incomprehensionUtts]
|
|
6937
|
+
};
|
|
6938
|
+
}
|
|
6909
6939
|
}
|
|
6910
6940
|
|
|
6911
6941
|
if (useNameAsIntent) {
|
|
6912
6942
|
debug$9('ExpandUtterancesToConvos - Using utterance name as NLU intent');
|
|
6913
|
-
}
|
|
6914
|
-
|
|
6943
|
+
}
|
|
6944
|
+
|
|
6945
|
+
if (incomprehensionIntents && incomprehensionIntents.length > 0) {
|
|
6946
|
+
debug$9(`ExpandUtterancesToConvos - Using ${incomprehensionIntents.length} incomprehension NLU intent(s)`);
|
|
6947
|
+
}
|
|
6948
|
+
|
|
6949
|
+
if (incomprehensionUtt) {
|
|
6950
|
+
debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}, ${this.utterances[incomprehensionUtt].utterances.length} user example(s)`);
|
|
6915
6951
|
}
|
|
6916
6952
|
|
|
6917
6953
|
lodash.keys(this.utterances).filter(u => u !== incomprehensionUtt).forEach(uttName => {
|
|
6918
6954
|
const utt = this.utterances[uttName];
|
|
6955
|
+
const responseStep = {
|
|
6956
|
+
sender: 'bot',
|
|
6957
|
+
messageText: '',
|
|
6958
|
+
asserters: [],
|
|
6959
|
+
stepTag: 'Step 2 - check bot response',
|
|
6960
|
+
not: false
|
|
6961
|
+
};
|
|
6962
|
+
|
|
6963
|
+
if (useNameAsIntent) {
|
|
6964
|
+
responseStep.asserters.push({
|
|
6965
|
+
name: 'INTENT',
|
|
6966
|
+
args: [utt.name]
|
|
6967
|
+
});
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6970
|
+
if (incomprehensionIntents && incomprehensionIntents.length > 0) {
|
|
6971
|
+
incomprehensionIntents.forEach(ii => {
|
|
6972
|
+
responseStep.asserters.push({
|
|
6973
|
+
name: 'INTENT',
|
|
6974
|
+
args: [ii],
|
|
6975
|
+
not: true
|
|
6976
|
+
});
|
|
6977
|
+
});
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6980
|
+
if (incomprehensionUtt) {
|
|
6981
|
+
responseStep.messageText = incomprehensionUtt;
|
|
6982
|
+
responseStep.not = true;
|
|
6983
|
+
}
|
|
6984
|
+
|
|
6919
6985
|
expandedConvos.push(new Convo(this._buildScriptContext(), {
|
|
6920
6986
|
header: {
|
|
6921
6987
|
name: utt.name,
|
|
@@ -6928,25 +6994,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6928
6994
|
}],
|
|
6929
6995
|
messageText: utt.name,
|
|
6930
6996
|
stepTag: 'Step 1 - tell utterance'
|
|
6931
|
-
},
|
|
6932
|
-
sender: 'bot',
|
|
6933
|
-
asserters: [{
|
|
6934
|
-
name: 'INTENT',
|
|
6935
|
-
args: [utt.name]
|
|
6936
|
-
}],
|
|
6937
|
-
stepTag: 'Step 2 - check intent',
|
|
6938
|
-
not: false
|
|
6939
|
-
} : incomprehensionUtt ? {
|
|
6940
|
-
sender: 'bot',
|
|
6941
|
-
messageText: incomprehensionUtt,
|
|
6942
|
-
stepTag: 'Step 2 - check incomprehension',
|
|
6943
|
-
not: true
|
|
6944
|
-
} : {
|
|
6945
|
-
sender: 'bot',
|
|
6946
|
-
messageText: '',
|
|
6947
|
-
stepTag: 'Step 2 - check bot response',
|
|
6948
|
-
not: false
|
|
6949
|
-
}],
|
|
6997
|
+
}, responseStep],
|
|
6950
6998
|
sourceTag: Object.assign({}, utt.sourceTag, {
|
|
6951
6999
|
origUttName: utt.name
|
|
6952
7000
|
})
|