-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathqnamakerBaseDialog.js
47 lines (40 loc) · 1.66 KB
/
qnamakerBaseDialog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const {
QnAMakerDialog
} = require('botbuilder-ai');
const {
ActivityFactory,
MessageFactory
} = require('botbuilder');
// Default parameters
const DefaultThreshold = 0.3;
const DefaultTopN = 3;
const DefaultAnswer = 'No QnAMaker answers found.';
// Card parameters
const DefaultCardTitle = 'Did you mean:';
const DefaultCardNoMatchText = 'None of the above.';
const DefaultCardNoMatchResponse = 'Thanks for the feedback.';
/// QnA Maker dialog.
const QNAMAKER_BASE_DIALOG = 'qnamaker-base-dailog';
class QnAMakerBaseDialog extends QnAMakerDialog {
/**
* Core logic of QnA Maker dialog.
* @param {QnAMaker} qnaService A QnAMaker service object.
*/
constructor(knowledgebaseId, authkey, host, defaultAnswer) {
const defaultAnswerActivity = MessageFactory.text(!!defaultAnswer.trim() ? defaultAnswer : DefaultAnswer);
let filters = [];
super(knowledgebaseId, authkey, host, defaultAnswerActivity, DefaultThreshold, DefaultCardTitle, DefaultCardNoMatchText,
DefaultTopN, ActivityFactory.cardNoMatchResponse, filters, QNAMAKER_BASE_DIALOG);
this.id = QNAMAKER_BASE_DIALOG;
}
}
module.exports.QnAMakerBaseDialog = QnAMakerBaseDialog;
module.exports.QNAMAKER_BASE_DIALOG = QNAMAKER_BASE_DIALOG;
module.exports.DefaultThreshold = DefaultThreshold;
module.exports.DefaultTopN = DefaultTopN;
module.exports.DefaultAnswer = DefaultAnswer;
module.exports.DefaultCardTitle = DefaultCardTitle;
module.exports.DefaultCardNoMatchText = DefaultCardNoMatchText;
module.exports.DefaultCardNoMatchResponse = DefaultCardNoMatchResponse;