wingbot 3.46.4 → 3.47.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.46.4",
3
+ "version": "3.47.0",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,6 +35,7 @@ const DEFAULT_TEXT_THRESHOLD = 0.8;
35
35
  * @prop {string} text
36
36
  * @prop {string} action
37
37
  * @prop {string} intent
38
+ * @prop {number} [rowNum]
38
39
  */
39
40
 
40
41
  /**
@@ -562,10 +563,37 @@ class ConversationTester {
562
563
  score: 0, intent: { intent: '-', score: 0 }, aboveConfidence: false, meta: null, action: null
563
564
  }] = actions;
564
565
 
565
- const report = (error = '', ok = false) => ({
566
- ok,
567
- o: `${textCase.text.padEnd(longestText, ' ')}\t${(winner.intent ? winner.intent.score : 0).toFixed(2)}\t${winner.intent ? winner.intent.intent : '-'} | ${error}`
568
- });
566
+ // textCase.rowNum?
567
+
568
+ const report = (error, ok = false) => {
569
+ let o = [
570
+ textCase.text.padEnd(longestText, ' '),
571
+ (winner.intent ? winner.intent.score : 0).toFixed(2),
572
+ winner.intent ? winner.intent.intent : '-'
573
+ ].join('\t');
574
+
575
+ if (ok || !error) {
576
+ if (error) {
577
+ o += ` | ${error}`;
578
+ }
579
+ return { ok, o };
580
+ }
581
+
582
+ let err = error;
583
+
584
+ const prefix = typeof textCase.rowNum === 'number'
585
+ ? ` > FAILED on row ${textCase.rowNum}: `.padEnd(23, ' ')
586
+ : ' > FAILED: ';
587
+
588
+ if (Array.isArray(err)) {
589
+ const pad = ''.padEnd(prefix.length, ' ');
590
+ err = err.join(`\n${pad}`);
591
+ }
592
+
593
+ o += `\n${prefix}${err}`;
594
+
595
+ return { ok, o };
596
+ };
569
597
 
570
598
  if (actions.length === 0) {
571
599
  return report('no NLP result');
@@ -576,25 +604,40 @@ class ConversationTester {
576
604
  }
577
605
 
578
606
  if (textCase.intent && winner.intent.intent !== textCase.intent) {
579
- return report(`expected intent "${textCase.intent}"`);
607
+ return report([
608
+ 'intent mismatch',
609
+ `✓ expected: ${textCase.intent}`,
610
+ `✗ actual: ${winner.intent.intent || '-'}`
611
+ ]);
580
612
  }
581
613
 
582
614
  if (textCase.appId) {
583
-
584
615
  if (!winner.meta || `${winner.meta.targetAppId}` !== `${textCase.appId}`) {
585
- return report(`expected handover to "${textCase.appId}" - actual "${(winner.meta && winner.meta.targetAppId) || `action: ${winner.action || '*'}`}"`);
616
+ return report([
617
+ 'target appId mismatch',
618
+ `✓ expected: ${textCase.appId}`,
619
+ `✗ actual: ${(winner.meta && winner.meta.targetAppId) || `action[ ${winner.action || '*'} ]`}`
620
+ ]);
586
621
  }
587
622
 
588
623
  if (textCase.action && !actionMatches(`${winner.meta.targetAction}`, `${textCase.action}`)) {
589
- return report(`expected action "${textCase.action}" - actual "${winner.meta.targetAction || '-'}"`);
624
+ return report([
625
+ 'target action mismatch',
626
+ `✓ expected: ${textCase.action}`,
627
+ `✗ actual: ${winner.meta.targetAction || '-'}`
628
+ ]);
590
629
  }
591
630
 
592
631
  } else if (textCase.action && !actionMatches(`${winner.action}`, `${textCase.action}`)) {
593
- return report(`expected action "${textCase.action}" - actual "${winner.action || '-'}"`);
632
+ return report([
633
+ 'action mismatch',
634
+ `✓ expected: ${textCase.action}`,
635
+ `✗ actual: ${winner.action || '-'}`
636
+ ]);
594
637
  }
595
638
 
596
639
  if (!textCase.action && !textCase.appId && !textCase.intent) {
597
- return report(`${textCase.action}`, true);
640
+ return report(winner.action, true);
598
641
  }
599
642
 
600
643
  return { ok: true, o: null };