@microsoft/bf-lu
Advanced tools
Comparing version 4.14.0-dev.20210422.eccdf02 to 4.14.0-dev.20210427.c0be653
@@ -21,9 +21,17 @@ "use strict"; | ||
*/ | ||
train: async function (input, intentName, config, verbose, trainingOpt) { | ||
train: async function (input, intentName, config, verbose, trainingOpt, exclude) { | ||
// get excluded foleders | ||
let excludedFolders = undefined; | ||
if (exclude) { | ||
excludedFolders = exclude.split(',').map(e => e.trim()); | ||
} | ||
// Get all related file content. | ||
const luContents = await filehelper.getFilesContent(input, fileExtEnum.LUFile); | ||
const qnaContents = await filehelper.getFilesContent(input, fileExtEnum.QnAFile); | ||
const luContents = await filehelper.getFilesContent(input, fileExtEnum.LUFile, excludedFolders); | ||
const qnaContents = await filehelper.getFilesContent(input, fileExtEnum.QnAFile, excludedFolders); | ||
const configContent = await filehelper.getConfigContent(config); | ||
const defaultLocale = 'en-us'; | ||
let importResolver = async function (id, idsToFind) { | ||
let importedContents = []; | ||
const idWithoutExt = path.basename(id, path.extname(id)); | ||
const locale = /\w\.\w/.test(idWithoutExt) ? idWithoutExt.split('.').pop() : defaultLocale; | ||
for (let idx = 0; idx < idsToFind.length; idx++) { | ||
@@ -42,3 +50,12 @@ let file = idsToFind[idx]; | ||
const updateImportedContents = async function (typedContents, fileExt) { | ||
const found = typedContents.filter(content => content.id === path.basename(fileName, fileExt)); | ||
let found = []; | ||
// import resolver should be capable to find implicit import files with locale, for example '[import](b.lu)' is defined in a.en-us.lu, the resolver should find b.en-us.lu | ||
const foundWithLocale = typedContents.filter(content => content.id === `${path.basename(fileName, fileExt)}.${locale}`); | ||
if (foundWithLocale.length > 0) { | ||
found = foundWithLocale; | ||
} | ||
else { | ||
//if no locale specified file is found, just to check whether there is file without locale matched | ||
found = typedContents.filter(content => content.id === path.basename(fileName, fileExt)); | ||
} | ||
if (found.length > 0) { | ||
@@ -63,3 +80,3 @@ importedContents.push(...found); | ||
else if (fileName.endsWith(fileExtEnum.QnAFile)) { | ||
await updateImportedContents(qnaContents, fileExtEnum.LUFile); | ||
await updateImportedContents(qnaContents, fileExtEnum.QnAFile); | ||
} | ||
@@ -66,0 +83,0 @@ } |
@@ -140,2 +140,3 @@ "use strict"; | ||
async build(luContents, authoringKey, botName, options = {}) { | ||
var _a; | ||
// set luis api call endpoint | ||
@@ -237,3 +238,3 @@ let endpoint = options.endpoint || "https://westus.api.cognitive.microsoft.com"; | ||
catch (error) { | ||
throw (new exception(retCode.errorCode.LUIS_BUILD_FAILED, `Luis build failed: ${error.message}`)); | ||
throw (new exception(retCode.errorCode.LUIS_BUILD_FAILED, `Luis build failed: ${(_a = error.message) !== null && _a !== void 0 ? _a : error.text}`)); | ||
} | ||
@@ -243,3 +244,3 @@ const settingsContent = this.generateDeclarativeAssets(settingsAssets); | ||
} | ||
async writeDialogAssets(contents, options = {}) { | ||
async writeDialogAssets(contents, options = {}, directVersionPublish) { | ||
let force = options.force || false; | ||
@@ -262,3 +263,3 @@ let out = options.out; | ||
} | ||
writeContents.push(this.mergeSettingsContent(outPath, settingsContents)); | ||
writeContents.push(this.mergeSettingsContent(outPath, settingsContents, directVersionPublish)); | ||
} | ||
@@ -408,3 +409,3 @@ for (const content of writeContents) { | ||
} | ||
mergeSettingsContent(settingsPath, contents) { | ||
mergeSettingsContent(settingsPath, contents, directVersionPublish) { | ||
let settings = new settings_1.Settings(settingsPath, {}); | ||
@@ -414,5 +415,7 @@ for (const content of contents) { | ||
for (const appName of Object.keys(luisAppsMap)) { | ||
settings.luis[appName] = { | ||
settings.luis[appName] = directVersionPublish ? { | ||
"appId": luisAppsMap[appName]["appId"], | ||
"version": luisAppsMap[appName]["version"] | ||
} : { | ||
"appId": luisAppsMap[appName]["appId"] | ||
}; | ||
@@ -419,0 +422,0 @@ } |
@@ -160,3 +160,3 @@ "use strict"; | ||
exports.detectLuContent = detectLuContent; | ||
async function getFilesContent(input, extType) { | ||
async function getFilesContent(input, extType, ignoredFolders) { | ||
let fileStat = await fs.stat(input); | ||
@@ -171,3 +171,15 @@ if (fileStat.isFile()) { | ||
} | ||
const paths = await globby([`**/*${extType}`], { cwd: input, dot: true }); | ||
const allPaths = (await globby([`**/*${extType}`], { cwd: input, dot: true })); | ||
let paths = []; | ||
if (ignoredFolders) { | ||
for (const path of allPaths) { | ||
const isIgnored = ignoredFolders.filter(e => path.startsWith(e)).length > 0; | ||
if (!isIgnored) { | ||
paths.push(path); | ||
} | ||
} | ||
} | ||
else { | ||
paths = allPaths; | ||
} | ||
return Promise.all(paths.map(async (item) => { | ||
@@ -174,0 +186,0 @@ const itemPath = path.resolve(path.join(input, item)); |
{ | ||
"name": "@microsoft/bf-lu", | ||
"version": "4.14.0-dev.20210422.eccdf02", | ||
"version": "4.14.0-dev.20210427.c0be653", | ||
"author": "Microsoft", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/microsoft/botframework-cli/issues", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1573828
19806