-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* for javascript_nodejs
- Loading branch information
Showing
4 changed files
with
41 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 20 additions & 32 deletions
52
samples/javascript_nodejs/49.qnamaker-all-features/dialogs/qnamakerBaseDialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Copyright (c) Microsoft Corporation. | ||
// 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.'; | ||
const { QnAMakerDialog } = require('botbuilder-ai'); | ||
const { MessageFactory } = require('botbuilder'); | ||
|
||
/// QnA Maker dialog. | ||
const QNAMAKER_BASE_DIALOG = 'qnamaker-base-dailog'; | ||
const QNAMAKER_BASE_DIALOG = 'qnamaker-base-dialog'; | ||
|
||
class QnAMakerBaseDialog extends QnAMakerDialog { | ||
/** | ||
* Core logic of QnA Maker dialog. | ||
* @param {QnAMaker} qnaService A QnAMaker service object. | ||
* @param {string} knowledgeBaseId A QnAMaker service object. | ||
* @param {string} endpointKey A QnAMaker service object. | ||
* @param {string} endpointHostName A QnAMaker service object. | ||
* @param {string} defaultAnswer 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); | ||
constructor( | ||
knowledgeBaseId, | ||
endpointKey, | ||
endpointHostName, | ||
defaultAnswer, | ||
) { | ||
let noAnswer; | ||
if (typeof defaultAnswer === 'string') { | ||
noAnswer = MessageFactory.text(defaultAnswer); | ||
} | ||
|
||
super(knowledgeBaseId, endpointKey, endpointHostName, noAnswer); | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
samples/javascript_nodejs/49.qnamaker-all-features/utils/qnaCardBuilder.js
This file was deleted.
Oops, something went wrong.