@microsoft/bf-lu
Advanced tools
Comparing version 4.10.0-dev.20200716.d3cbcf0 to 4.10.0-dev.20200717.fbe453f
@@ -423,3 +423,3 @@ "use strict"; | ||
let utterancesContent = subDedupedUtterances.join(NEWLINE + '- '); | ||
let utterancesToQuestion = `${NEWLINE}${crossTrainingComments}${NEWLINE}# ? ${utterancesContent}${NEWLINE}${NEWLINE}**Filters:**${NEWLINE}- dialogName=${fileName}${NEWLINE}${NEWLINE}\`\`\`${NEWLINE}intent=DeferToRecognizer_LUIS_${fileName}${NEWLINE}\`\`\``; | ||
let utterancesToQuestion = `${NEWLINE}${crossTrainingComments}${NEWLINE}> !# @qna.pair.source = crosstrained${NEWLINE}${NEWLINE}# ? ${utterancesContent}${NEWLINE}${NEWLINE}**Filters:**${NEWLINE}- dialogName=${fileName}${NEWLINE}${NEWLINE}\`\`\`${NEWLINE}intent=DeferToRecognizer_LUIS_${fileName}${NEWLINE}\`\`\``; | ||
trainedQnaResource = new SectionOperator(trainedQnaResource).addSection(utterancesToQuestion); | ||
@@ -426,0 +426,0 @@ } |
@@ -80,3 +80,3 @@ "use strict"; | ||
// find by question match | ||
qnaId = qnaList.find(x => x.questions.includes(prompt.qnaId) || x.questions.includes(prompt.qnaId.replace(/-/g, ' ').trim())); | ||
qnaId = qnaList.find(x => x.source.trim() !== 'crosstrained' && (x.questions.includes(prompt.qnaId) || x.questions.includes(prompt.qnaId.replace(/-/g, ' ').trim()))); | ||
} | ||
@@ -83,0 +83,0 @@ if (qnaId === undefined) { |
@@ -24,3 +24,2 @@ "use strict"; | ||
const KB = require('./../qna/qnamaker/kb'); | ||
const NEWLINE = require('os').EOL; | ||
const recognizerType = require('./../utils/enums/recognizertypes'); | ||
@@ -32,2 +31,3 @@ class Builder { | ||
async loadContents(files, botName, suffix, region, culture, schema) { | ||
var _a; | ||
let multiRecognizer; | ||
@@ -37,2 +37,3 @@ let settings; | ||
let qnaContents = new Map(); | ||
let qnaObjects = new Map(); | ||
for (const file of files) { | ||
@@ -47,19 +48,3 @@ let fileCulture; | ||
} | ||
let fileContent = ''; | ||
let result; | ||
const qnaFiles = await fileHelper.getLuObjects(undefined, file, true, fileExtEnum.QnAFile); | ||
try { | ||
result = await qnaBuilderVerbose.build(qnaFiles, true); | ||
// construct qna content without file and url references | ||
fileContent = result.parseToQnAContent(); | ||
} | ||
catch (err) { | ||
if (err.source) { | ||
err.text = `Invalid QnA file ${err.source}: ${err.text}`; | ||
} | ||
else { | ||
err.text = `Invalid QnA file ${file}: ${err.text}`; | ||
} | ||
throw (new exception(retCode.errorCode.INVALID_INPUT_FILE, err.text)); | ||
} | ||
this.handler(`${file} loaded\n`); | ||
@@ -88,3 +73,3 @@ const fileFolder = path.dirname(file); | ||
} | ||
const content = new Content(fileContent, new qnaOptions(botName, true, fileCulture, file)); | ||
const content = new Content('', new qnaOptions(botName, true, fileCulture, file)); | ||
if (!recognizers.has(content.name)) { | ||
@@ -103,10 +88,10 @@ const dialogFile = path.join(fileFolder, `${content.name}.dialog`); | ||
qnaContents.set(content.name, content); | ||
qnaObjects.set(content.name, qnaFiles); | ||
} | ||
else { | ||
// merge contents of qna files with same name | ||
let existingContent = qnaContents.get(content.name); | ||
existingContent.content = `${existingContent.content}${NEWLINE}${NEWLINE}${content.content}`; | ||
qnaContents.set(content.name, existingContent); | ||
(_a = qnaObjects.get(content.name)) === null || _a === void 0 ? void 0 : _a.push(...qnaFiles); | ||
} | ||
} | ||
await this.resolveMergedQnAContentIds(qnaContents, qnaObjects); | ||
return { qnaContents: [...qnaContents.values()], recognizers, multiRecognizer, settings }; | ||
@@ -433,3 +418,23 @@ } | ||
} | ||
async resolveMergedQnAContentIds(contents, objects) { | ||
for (const [name, content] of contents) { | ||
let qnaObjects = objects.get(name); | ||
try { | ||
let result = await qnaBuilderVerbose.build(qnaObjects, true); | ||
let mergedContent = result.parseToQnAContent(); | ||
content.content = mergedContent; | ||
contents.set(name, content); | ||
} | ||
catch (err) { | ||
if (err.source) { | ||
err.text = `Invalid QnA file ${err.source}: ${err.text}`; | ||
} | ||
else { | ||
err.text = `Invalid QnA file ${content.path}: ${err.text}`; | ||
} | ||
throw (new exception(retCode.errorCode.INVALID_INPUT_FILE, err.text)); | ||
} | ||
} | ||
} | ||
} | ||
exports.Builder = Builder; |
{ | ||
"name": "@microsoft/bf-lu", | ||
"version": "4.10.0-dev.20200716.d3cbcf0", | ||
"version": "4.10.0-dev.20200717.fbe453f", | ||
"author": "Microsoft", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/microsoft/botframework-cli/issues", |
814673
18225