diff --git a/libraries/botbuilder-ai/src/qnaMaker.ts b/libraries/botbuilder-ai/src/qnaMaker.ts index abc9b9a7d8..30cc966fd8 100644 --- a/libraries/botbuilder-ai/src/qnaMaker.ts +++ b/libraries/botbuilder-ai/src/qnaMaker.ts @@ -19,6 +19,7 @@ import { GenerateAnswerUtils } from './qnamaker-utils/generateAnswerUtils'; import { ActiveLearningUtils } from './qnamaker-utils/activeLearningUtils'; import { TrainUtils } from './qnamaker-utils/trainUtils'; import { QnAMakerResults } from './qnamaker-interfaces/qnamakerResults'; +import { RankerTypes } from './qnamaker-interfaces/rankerTypes'; export const QNAMAKER_TRACE_TYPE = 'https://www.qnamaker.ai/schemas/trace'; export const QNAMAKER_TRACE_NAME = 'QnAMaker'; @@ -86,7 +87,8 @@ export class QnAMaker implements QnAMakerTelemetryClient { top = 1, strictFilters = [] as QnAMakerMetadata[], metadataBoost = [] as QnAMakerMetadata[], - timeout = 100000 + timeout = 100000, + rankerType = RankerTypes.default } = options; this._options = { @@ -94,7 +96,8 @@ export class QnAMaker implements QnAMakerTelemetryClient { top, strictFilters, metadataBoost, - timeout + timeout, + rankerType } as QnAMakerOptions; this.generateAnswerUtils = new GenerateAnswerUtils(this._options, this.endpoint); diff --git a/libraries/botbuilder-ai/tests/TestData/QnAMaker/should_call_qnamaker_with_rankerType_questionOnly.json b/libraries/botbuilder-ai/tests/TestData/QnAMaker/should_call_qnamaker_with_rankerType_questionOnly.json index c3df1eb40e..830e43d2c7 100644 --- a/libraries/botbuilder-ai/tests/TestData/QnAMaker/should_call_qnamaker_with_rankerType_questionOnly.json +++ b/libraries/botbuilder-ai/tests/TestData/QnAMaker/should_call_qnamaker_with_rankerType_questionOnly.json @@ -1,35 +1,13 @@ { - "activeLearningEnabled": false, - "answers": [ - { - "questions": [ - "Q1" - ], - "answer": "A1", - "score": 80, - "id": 15, - "source": "Editorial", - "metadata": [ - { - "name": "topic", - "value": "value" - } - ] - }, - { - "questions": [ - "Q2" - ], - "answer": "A2", - "score": 78, - "id": 16, - "source": "Editorial", - "metadata": [ - { - "name": "topic", - "value": "value" - } - ] - } - ] - } \ No newline at end of file + "activeLearningEnabled": false, + "answers": [ + { + "questions": [], + "answer": "No good match found in KB.", + "score": 0.0, + "id": -1, + "source": null, + "metadata": [] + } + ] +} \ No newline at end of file diff --git a/libraries/botbuilder-ai/tests/qnaMaker.test.js b/libraries/botbuilder-ai/tests/qnaMaker.test.js index fd9728abab..f25ac9b4f0 100644 --- a/libraries/botbuilder-ai/tests/qnaMaker.test.js +++ b/libraries/botbuilder-ai/tests/qnaMaker.test.js @@ -266,11 +266,11 @@ describe('QnAMaker', function () { it('should call qnamaker with rankerType questionOnly', async function() { const qna = new QnAMaker(endpoint); const turnContext = new TestContext({ text: "Q11" }); - const options = { top: 1, context: null, rankerType: "questionOnly" }; + const options = { top: 1, context: null, rankerType: "QuestionOnly" }; const qnaResults = await qna.getAnswers(turnContext, options); - assert.strictEqual(qnaResults.length, 2, 'no answers should be returned'); + assert.strictEqual(qnaResults.length, 0, 'no answers should be returned'); }); it('should return answer with timeout option specified', async function() {