Skip to content

Commit

Permalink
rankerType got from options in QnA constructor (#1953)
Browse files Browse the repository at this point in the history
Co-authored-by: esalcobada <david.alcoba@es.nestle.com>
Co-authored-by: vipeketi <58211229+vipeketi@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 8, 2020
1 parent bd2c4fd commit d54da72
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 38 deletions.
7 changes: 5 additions & 2 deletions libraries/botbuilder-ai/src/qnaMaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -86,15 +87,17 @@ export class QnAMaker implements QnAMakerTelemetryClient {
top = 1,
strictFilters = [] as QnAMakerMetadata[],
metadataBoost = [] as QnAMakerMetadata[],
timeout = 100000
timeout = 100000,
rankerType = RankerTypes.default
} = options;

this._options = {
scoreThreshold,
top,
strictFilters,
metadataBoost,
timeout
timeout,
rankerType
} as QnAMakerOptions;

this.generateAnswerUtils = new GenerateAnswerUtils(this._options, this.endpoint);
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
"activeLearningEnabled": false,
"answers": [
{
"questions": [],
"answer": "No good match found in KB.",
"score": 0.0,
"id": -1,
"source": null,
"metadata": []
}
]
}
4 changes: 2 additions & 2 deletions libraries/botbuilder-ai/tests/qnaMaker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d54da72

Please sign in to comment.