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
|
@@ -398,4 +398,13 @@ describe('convo.transcript', function () {
|
|
|
398
398
|
assert.equal(err.transcript.steps.length, 5)
|
|
399
399
|
}
|
|
400
400
|
})
|
|
401
|
+
it('should calculate assertion count', async function () {
|
|
402
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2steps.convo.txt')
|
|
403
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
404
|
+
assert.equal(this.compiler.GetAssertionCount(this.compiler.convos[0]), 2)
|
|
405
|
+
|
|
406
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'asserters.convo.txt')
|
|
407
|
+
assert.equal(this.compiler.convos.length, 2)
|
|
408
|
+
assert.equal(this.compiler.GetAssertionCount(this.compiler.convos[1]), 1)
|
|
409
|
+
})
|
|
401
410
|
})
|
|
@@ -61,16 +61,12 @@ describe('scripting.asserters.intentConfidenceAsserter', function () {
|
|
|
61
61
|
[false, 80, 85, false]
|
|
62
62
|
]
|
|
63
63
|
|
|
64
|
-
cases
|
|
65
|
-
const useWithGlobal = cse[0]
|
|
66
|
-
const expected = cse[1]
|
|
67
|
-
const found = cse[2]
|
|
68
|
-
const negative = cse[3]
|
|
64
|
+
for (const [useWithGlobal, expected, found, negative] of cases) {
|
|
69
65
|
const message = `${negative ? 'negative' : 'positive'} case for intent confidence asserter ${useWithGlobal ? 'with global args' : 'without global args'}, exp: ${expected}, found: ${found}`
|
|
70
66
|
it(message,
|
|
71
67
|
async function () {
|
|
72
|
-
return _assert(
|
|
68
|
+
return _assert(useWithGlobal, expected, found, negative)
|
|
73
69
|
}
|
|
74
70
|
)
|
|
75
|
-
}
|
|
71
|
+
}
|
|
76
72
|
})
|
|
@@ -293,6 +293,48 @@ describe('scripting.scriptingProvider', function () {
|
|
|
293
293
|
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt1-L2')
|
|
294
294
|
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
295
295
|
})
|
|
296
|
+
it('should build convos for utterance using iterator', async function () {
|
|
297
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
298
|
+
await scriptingProvider.Build()
|
|
299
|
+
scriptingProvider.AddUtterances({
|
|
300
|
+
name: 'utt1',
|
|
301
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
302
|
+
})
|
|
303
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
304
|
+
header: {
|
|
305
|
+
name: 'test convo'
|
|
306
|
+
},
|
|
307
|
+
conversation: [
|
|
308
|
+
{
|
|
309
|
+
sender: 'me',
|
|
310
|
+
messageText: 'utt1'
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}))
|
|
314
|
+
|
|
315
|
+
scriptingProvider.ExpandConvosIterable()
|
|
316
|
+
const expected = [
|
|
317
|
+
{
|
|
318
|
+
header: { name: 'test convo/utt1-L1' },
|
|
319
|
+
conversation: [{ messageText: 'TEXT1' }]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
header: { name: 'test convo/utt1-L2' },
|
|
323
|
+
conversation: [{ messageText: 'TEXT2' }]
|
|
324
|
+
}
|
|
325
|
+
]
|
|
326
|
+
let i = 0
|
|
327
|
+
for (const c of scriptingProvider.convosIterable) {
|
|
328
|
+
const exp = expected[i++]
|
|
329
|
+
assert.equal(c.header.name, exp.header.name)
|
|
330
|
+
assert.equal(c.conversation.length, exp.conversation.length)
|
|
331
|
+
assert.deepEqual(c.conversation.map(s => s.messageText), exp.conversation.map(s => s.messageText))
|
|
332
|
+
}
|
|
333
|
+
assert.equal(i, 2)
|
|
334
|
+
// scriptingProvider.convosIterable.forEach((iteratedConvo, index) => {
|
|
335
|
+
// assert.deepEqual(iteratedConvo, expected[index])
|
|
336
|
+
// })
|
|
337
|
+
})
|
|
296
338
|
it('should build convos for utterance with parameters', async function () {
|
|
297
339
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
298
340
|
await scriptingProvider.Build()
|
|
@@ -350,10 +392,12 @@ describe('scripting.scriptingProvider', function () {
|
|
|
350
392
|
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
351
393
|
})
|
|
352
394
|
describe('should build convos for SCRIPTING_UTTEXPANSION_NAMING_MODE', function () {
|
|
353
|
-
const utterances =
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
395
|
+
const utterances = [
|
|
396
|
+
{
|
|
397
|
+
name: 'uttText',
|
|
398
|
+
utterances: ['TEXT1 01234567890123456789', 'TEXT2 01234567890123456789']
|
|
399
|
+
}
|
|
400
|
+
]
|
|
357
401
|
const convoUtterances = {
|
|
358
402
|
header: {
|
|
359
403
|
name: 'test convo'
|
|
@@ -397,7 +441,38 @@ describe('scripting.scriptingProvider', function () {
|
|
|
397
441
|
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1-TEXT1 0123456...')
|
|
398
442
|
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2-TEXT2 0123456...')
|
|
399
443
|
})
|
|
444
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance len=1', async function () {
|
|
445
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
446
|
+
{},
|
|
447
|
+
DefaultCapabilities,
|
|
448
|
+
{
|
|
449
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
450
|
+
}
|
|
451
|
+
))
|
|
452
|
+
await scriptingProvider.Build()
|
|
453
|
+
scriptingProvider.AddUtterances([
|
|
454
|
+
{
|
|
455
|
+
name: 'uttText1',
|
|
456
|
+
utterances: ['TEXT1 01234567890123456789']
|
|
457
|
+
}
|
|
458
|
+
])
|
|
459
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
460
|
+
header: {
|
|
461
|
+
name: 'test convo'
|
|
462
|
+
},
|
|
463
|
+
conversation: [
|
|
464
|
+
{
|
|
465
|
+
sender: 'me',
|
|
466
|
+
messageText: 'uttText1'
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
}))
|
|
400
470
|
|
|
471
|
+
scriptingProvider.ExpandConvos()
|
|
472
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
473
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
474
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo')
|
|
475
|
+
})
|
|
401
476
|
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance, turn length off', async function () {
|
|
402
477
|
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
403
478
|
{},
|
|
@@ -475,6 +550,42 @@ describe('scripting.scriptingProvider', function () {
|
|
|
475
550
|
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-L2-test2 0123456...')
|
|
476
551
|
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-L3-test3.jpg')
|
|
477
552
|
})
|
|
553
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance userinputs len=1', async function () {
|
|
554
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
555
|
+
{},
|
|
556
|
+
DefaultCapabilities,
|
|
557
|
+
{
|
|
558
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
559
|
+
}
|
|
560
|
+
))
|
|
561
|
+
await scriptingProvider.Build()
|
|
562
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
563
|
+
header: {
|
|
564
|
+
name: 'test convo'
|
|
565
|
+
},
|
|
566
|
+
sourceTag: {},
|
|
567
|
+
conversation: [
|
|
568
|
+
{
|
|
569
|
+
sender: 'me',
|
|
570
|
+
userInputs: [
|
|
571
|
+
{
|
|
572
|
+
name: 'BUTTON',
|
|
573
|
+
args: ['button1']
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: 'MEDIA',
|
|
577
|
+
args: ['test1.jpg']
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
}
|
|
581
|
+
]
|
|
582
|
+
}))
|
|
583
|
+
|
|
584
|
+
scriptingProvider.ExpandConvos()
|
|
585
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
586
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
587
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo')
|
|
588
|
+
})
|
|
478
589
|
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance userinputs and utterances', async function () {
|
|
479
590
|
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
480
591
|
{},
|
|
@@ -518,6 +629,47 @@ describe('scripting.scriptingProvider', function () {
|
|
|
518
629
|
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/uttText-L2-TEXT2 0123456...')
|
|
519
630
|
})
|
|
520
631
|
})
|
|
632
|
+
describe('should have be possible to generate / store convos partially', function () {
|
|
633
|
+
const _createConvos = async () => {
|
|
634
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
635
|
+
await scriptingProvider.Build()
|
|
636
|
+
scriptingProvider.AddUtterances({
|
|
637
|
+
name: 'utt1',
|
|
638
|
+
utterances: ['TEXT1', 'TEXT2', 'TEXT3', 'TEXT4', 'TEXT5']
|
|
639
|
+
})
|
|
640
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
641
|
+
header: {
|
|
642
|
+
name: 'test convo'
|
|
643
|
+
},
|
|
644
|
+
conversation: [
|
|
645
|
+
{
|
|
646
|
+
sender: 'me',
|
|
647
|
+
messageText: 'utt1'
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
sender: 'bot',
|
|
651
|
+
messageText: 'some text'
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
sender: 'me',
|
|
655
|
+
messageText: 'utt1'
|
|
656
|
+
}
|
|
657
|
+
]
|
|
658
|
+
}))
|
|
659
|
+
return scriptingProvider
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
it('should build convos with nulls (to detect convo count)', async function () {
|
|
663
|
+
const scriptingProvider = await _createConvos()
|
|
664
|
+
scriptingProvider.ExpandConvos({ justHeader: true })
|
|
665
|
+
assert.equal(scriptingProvider.convos.length, 25)
|
|
666
|
+
for (let i = 0; i < 25; i++) {
|
|
667
|
+
const keys = Object.keys(scriptingProvider.convos[i])
|
|
668
|
+
assert.equal(keys.length, 1)
|
|
669
|
+
assert.equal(keys[0], 'header')
|
|
670
|
+
}
|
|
671
|
+
})
|
|
672
|
+
})
|
|
521
673
|
})
|
|
522
674
|
|
|
523
675
|
describe('ExpandUtterancesToConvos', function () {
|
|
@@ -70,15 +70,15 @@ describe('scripting.utteranceexpansion.associateByIndex', function () {
|
|
|
70
70
|
scriptingProvider.ExpandConvos()
|
|
71
71
|
|
|
72
72
|
assert.equal(scriptingProvider.convos.length, 5)
|
|
73
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/
|
|
73
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_GOODBYE-L1')
|
|
74
74
|
assert.deepEqual(scriptingProvider.convos[0].conversation.length, 6)
|
|
75
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/
|
|
75
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_GOODBYE-L2')
|
|
76
76
|
assert.deepEqual(scriptingProvider.convos[1].conversation.length, 6)
|
|
77
|
-
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/
|
|
77
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L3')
|
|
78
78
|
assert.deepEqual(scriptingProvider.convos[2].conversation.length, 6)
|
|
79
|
-
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/
|
|
79
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L4')
|
|
80
80
|
assert.deepEqual(scriptingProvider.convos[3].conversation.length, 6)
|
|
81
|
-
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/
|
|
81
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L5')
|
|
82
82
|
assert.deepEqual(scriptingProvider.convos[4].conversation.length, 6)
|
|
83
83
|
})
|
|
84
84
|
it('should associate media by index', async function () {
|
|
@@ -140,15 +140,15 @@ describe('scripting.utteranceexpansion.associateByIndex', function () {
|
|
|
140
140
|
scriptingProvider.ExpandConvos()
|
|
141
141
|
|
|
142
142
|
assert.equal(scriptingProvider.convos.length, 5)
|
|
143
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-
|
|
143
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-step0voice0.wav/MEDIA-step2voice0.wav')
|
|
144
144
|
assert.deepEqual(scriptingProvider.convos[0].conversation.length, 6)
|
|
145
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-
|
|
145
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-step0voice1.wav/MEDIA-step2voice1.wav')
|
|
146
146
|
assert.deepEqual(scriptingProvider.convos[1].conversation.length, 6)
|
|
147
|
-
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-
|
|
147
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-step0voice2.wav/MEDIA-step2voice2.wav')
|
|
148
148
|
assert.deepEqual(scriptingProvider.convos[2].conversation.length, 6)
|
|
149
|
-
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/MEDIA-
|
|
149
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/MEDIA-step0voice2.wav/MEDIA-step2voice4.wav')
|
|
150
150
|
assert.deepEqual(scriptingProvider.convos[3].conversation.length, 6)
|
|
151
|
-
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/MEDIA-
|
|
151
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/MEDIA-step0voice2.wav/MEDIA-step2voice5.wav')
|
|
152
152
|
assert.deepEqual(scriptingProvider.convos[4].conversation.length, 6)
|
|
153
153
|
})
|
|
154
154
|
it('should associate utterance and media by index', async function () {
|
|
@@ -245,15 +245,15 @@ describe('scripting.utteranceexpansion.associateByIndex', function () {
|
|
|
245
245
|
scriptingProvider.ExpandConvos()
|
|
246
246
|
|
|
247
247
|
assert.equal(scriptingProvider.convos.length, 5)
|
|
248
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/
|
|
248
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_GOODBYE-L1/MEDIA-step0voice0.wav/MEDIA-step2voice0.wav')
|
|
249
249
|
assert.deepEqual(scriptingProvider.convos[0].conversation.length, 12)
|
|
250
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/
|
|
250
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_GOODBYE-L2/MEDIA-step0voice1.wav/MEDIA-step2voice1.wav')
|
|
251
251
|
assert.deepEqual(scriptingProvider.convos[1].conversation.length, 12)
|
|
252
|
-
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/
|
|
252
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L3/MEDIA-step0voice2.wav/MEDIA-step2voice2.wav')
|
|
253
253
|
assert.deepEqual(scriptingProvider.convos[2].conversation.length, 12)
|
|
254
|
-
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/
|
|
254
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L4/MEDIA-step0voice2.wav/MEDIA-step2voice4.wav')
|
|
255
255
|
assert.deepEqual(scriptingProvider.convos[3].conversation.length, 12)
|
|
256
|
-
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/
|
|
256
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L5/MEDIA-step0voice2.wav/MEDIA-step2voice5.wav')
|
|
257
257
|
assert.deepEqual(scriptingProvider.convos[4].conversation.length, 12)
|
|
258
258
|
})
|
|
259
259
|
})
|