Skip to content

Commit

Permalink
fix: Qna pairs are being duplicated in the Qna knowledge base (micros…
Browse files Browse the repository at this point in the history
…oft#5253)

Co-authored-by: Dong Lei <donglei@microsoft.com>
  • Loading branch information
lei9444 and boydc2014 authored Dec 9, 2020
1 parent 519f145 commit 1dc482e
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Composer/packages/server/src/models/bot/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,22 @@ export class Builder {
culture: config.fallbackLocal,
});

if (qnaContents) {
const subscriptionKeyEndpoint = `https://${config.qnaRegion}.api.cognitive.microsoft.com/qnamaker/v4.0`;

const buildResult = await this.qnaBuilder.build(qnaContents, config.subscriptionKey, config.botName, {
endpoint: subscriptionKeyEndpoint,
suffix: config.suffix,
});

await this.qnaBuilder.writeDialogAssets(buildResult, {
force: true,
out: this.generatedFolderPath,
});
}
//we need to filter the source qna file out.
const filteredQnaContents = qnaContents?.filter((content) => !content.id.endsWith('.source'));

if (!filteredQnaContents || filteredQnaContents.length === 0) return;

const subscriptionKeyEndpoint = `https://${config.qnaRegion}.api.cognitive.microsoft.com/qnamaker/v4.0`;

const buildResult = await this.qnaBuilder.build(filteredQnaContents, config.subscriptionKey, config.botName, {
endpoint: subscriptionKeyEndpoint,
suffix: config.suffix,
});

await this.qnaBuilder.writeDialogAssets(buildResult, {
force: true,
out: this.generatedFolderPath,
});
}

//delete files in generated folder
Expand Down

0 comments on commit 1dc482e

Please sign in to comment.