Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
812a1ab
Fix downloader
taicchoumsft Mar 16, 2021
80b7c6f
Pass Orch setting data to builder
taicchoumsft Mar 17, 2021
38442bd
Merge branch 'main' into tachou/orchSelectModel
taicchoumsft Mar 18, 2021
21e2ec9
don't set path as default
taicchoumsft Mar 18, 2021
b18cfd4
Merge branch 'main' into tachou/orchSelectModel
taicchoumsft Mar 26, 2021
6ec3cd5
Minor rename to download API
taicchoumsft Mar 29, 2021
9d32522
Merge branch 'main' into tachou/orchSelectModel
taicchoumsft Mar 29, 2021
4c6ad26
Merge branch 'main' into tachou/orchSelectModel
taicchoumsft Mar 29, 2021
7f60377
Merge branch 'main' into tachou/orchSelectModel
taicchoumsft Mar 30, 2021
60529f6
Merge branch 'main' into tachou/orchSelectModel
taicchoumsft Mar 30, 2021
f88e709
Cleanup download code
taicchoumsft Apr 1, 2021
5dbc9ea
Remove the block by sending response first
taicchoumsft Apr 1, 2021
2db79fd
Save modelpath and use new models in builder (though not path)
taicchoumsft Apr 1, 2021
038cae9
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 1, 2021
5335fa8
Remove path for this PR
taicchoumsft Apr 1, 2021
a88f3e9
Fix worker error handling
taicchoumsft Apr 1, 2021
93ef2f9
Fix handling of orchcontroller errors
taicchoumsft Apr 2, 2021
e5d0098
Fix linter errors
taicchoumsft Apr 2, 2021
9d313cf
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 2, 2021
8e07a51
add a note on JSON.Parse throw
taicchoumsft Apr 2, 2021
04f4bed
Merge branch 'tachou/orchSelectModelV2' of https://github.com/microso…
taicchoumsft Apr 2, 2021
de46a1a
Fix uts
taicchoumsft Apr 2, 2021
855d480
Fix more UTs
taicchoumsft Apr 2, 2021
2762d9c
Fix more UTs
taicchoumsft Apr 2, 2021
d891def
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 3, 2021
477ea7b
extract worker change
taicchoumsft Apr 3, 2021
a2663aa
Strip out downloader changes
taicchoumsft Apr 4, 2021
93b1076
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 4, 2021
20ed2c7
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 5, 2021
12314e9
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 5, 2021
ecbb5d9
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 5, 2021
e76deb3
Merge branch 'main' into tachou/orchSelectModelV2
boydc2014 Apr 5, 2021
8f8b407
Merge branch 'main' into tachou/orchSelectModelV2
taicchoumsft Apr 6, 2021
95f95cc
Merge branch 'main' into tachou/orchSelectModelV2
boydc2014 Apr 6, 2021
11b00db
Merge branch 'main' into tachou/orchSelectModelV2
boydc2014 Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable react-hooks/rules-of-hooks */

import { useRecoilCallback, CallbackInterface } from 'recoil';
import { ILuisConfig, IQnAConfig } from '@bfc/shared';
import { ILuisConfig, IQnAConfig, IOrchestratorConfig } from '@bfc/shared';

import * as luUtil from '../../utils/luUtil';
import * as qnaUtil from '../../utils/qnaUtil';
Expand All @@ -23,7 +23,8 @@ export const builderDispatcher = () => {
(callbackHelpers: CallbackInterface) => async (
projectId: string,
luisConfig: ILuisConfig,
qnaConfig: IQnAConfig
qnaConfig: IQnAConfig,
orchestratorConfig: IOrchestratorConfig
) => {
const { set, snapshot } = callbackHelpers;
const dialogs = await snapshot.getPromise(dialogsWithLuProviderSelectorFamily(projectId));
Expand Down Expand Up @@ -53,6 +54,7 @@ export const builderDispatcher = () => {
await httpClient.post(`/projects/${projectId}/build`, {
luisConfig,
qnaConfig,
orchestratorConfig,
projectId,
luFiles: referredLuFiles.map((file) => ({ id: file.id, isEmpty: file.empty })),
qnaFiles: referredQnaFiles.map((file) => ({ id: file.id, isEmpty: file.empty })),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const buildEssentialsSelector = selectorFamily({
const configuration = {
luis: settings.luis,
qna: settings.qna,
orchestrator: settings.orchestrator,
};
const dialogs = get(dialogsSelectorFamily(projectId));
const luFiles = get(luFilesSelectorFamily(projectId));
Expand Down Expand Up @@ -115,7 +116,7 @@ const botRuntimeAction = (dispatcher: Dispatcher) => {
if (config) {
await dispatcher.downloadLanguageModels(projectId);
dispatcher.setBotStatus(projectId, BotStatus.publishing);
await dispatcher.build(projectId, config.luis, config.qna);
await dispatcher.build(projectId, config.luis, config.qna, config.orchestrator);
}
},
startBot: async (projectId: string, sensitiveSettings) => {
Expand Down
3 changes: 2 additions & 1 deletion Composer/packages/server/src/controllers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,11 @@ async function build(req: Request, res: Response) {
const currentProject = await BotProjectService.getProjectById(projectId, user);
if (currentProject !== undefined) {
try {
const { luisConfig, qnaConfig, luFiles, qnaFiles } = req.body;
const { luisConfig, qnaConfig, orchestratorConfig, luFiles, qnaFiles } = req.body;
const files = await currentProject.buildFiles({
luisConfig,
qnaConfig,
orchestratorConfig,
luResource: luFiles,
qnaResource: qnaFiles,
});
Expand Down
15 changes: 13 additions & 2 deletions Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,13 @@ export class BotProject implements IBotProject {
return createdFiles;
};

public buildFiles = async ({ luisConfig, qnaConfig, luResource = [], qnaResource = [] }: IBuildConfig) => {
public buildFiles = async ({
luisConfig,
qnaConfig,
orchestratorConfig,
luResource = [],
qnaResource = [],
}: IBuildConfig) => {
if (this.settings) {
const luFiles: FileInfo[] = [];
const emptyFiles = {};
Expand All @@ -501,7 +507,12 @@ export class BotProject implements IBotProject {

this.builder.rootDir = this.dir;
this.builder.setBuildConfig(
{ ...luisConfig, subscriptionKey: qnaConfig.subscriptionKey ?? '', qnaRegion: qnaConfig.qnaRegion ?? '' },
{
...luisConfig,
subscriptionKey: qnaConfig.subscriptionKey ?? '',
qnaRegion: qnaConfig.qnaRegion ?? '',
...orchestratorConfig,
},
this.settings.downsampling
);
await this.builder.build(
Expand Down
18 changes: 11 additions & 7 deletions Composer/packages/server/src/models/bot/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,12 @@ export class Builder {
const nlrList = await this.runOrchestratorNlrList();

const modelDatas = [
{ model: nlrList?.defaults?.en_intent, lang: 'en', luFiles: enLuFiles },
{ model: nlrList?.defaults?.multilingual_intent, lang: 'multilang', luFiles: multiLangLuFiles },
{ model: this.config?.model?.en_intent ?? nlrList?.defaults?.en_intent, lang: 'en', luFiles: enLuFiles },
{
model: this.config?.model?.multilingual_intent ?? nlrList?.defaults?.multilingual_intent,
lang: 'multilang',
luFiles: multiLangLuFiles,
},
];

for (const modelData of modelDatas) {
Expand All @@ -187,13 +191,13 @@ export class Builder {
throw new Error('Model not set');
}
const modelPath = Path.resolve(await this.getModelPathAsync(), modelData.model.replace('.onnx', ''));
await this.runOrchestratorNlrGet(modelPath, modelData.model);
if (!(await pathExists(modelPath))) {
throw new Error('Orchestrator Model missing: ' + modelPath);
}
const snapshotData = await this.buildOrchestratorSnapshots(modelPath, modelData.luFiles, emptyFiles);

this.orchestratorSettings.orchestrator.models[modelData.lang] = modelPath;
for (const snap in snapshotData) {
this.orchestratorSettings.orchestrator.snapshots[snap] = snapshotData[snap];
}
this.orchestratorSettings.orchestrator.snapshots = snapshotData;
}
}

Expand All @@ -215,7 +219,7 @@ export class Builder {
luFiles: FileInfo[],
emptyFiles: { [key: string]: boolean }
) => {
if (!luFiles.filter((file) => !emptyFiles[file.name]).length) return;
if (!luFiles.filter((file) => !emptyFiles[file.name]).length) return {};
// build snapshots from LU files
return await orchestratorBuilder.build(this.botDir, luFiles, modelPath, this.generatedFolderPath);
};
Expand Down
3 changes: 2 additions & 1 deletion Composer/packages/server/src/models/bot/interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { BaseSchema, ILuisConfig, IQnAConfig } from '@bfc/shared';
import { BaseSchema, ILuisConfig, IQnAConfig, IOrchestratorConfig } from '@bfc/shared';

export type Resource = { id: string; isEmpty: boolean };

Expand All @@ -13,6 +13,7 @@ export interface LocationRef {
export interface IBuildConfig {
luisConfig: ILuisConfig;
qnaConfig: IQnAConfig;
orchestratorConfig?: IOrchestratorConfig;
luResource: Resource[];
qnaResource: Resource[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,29 @@ export async function orchestratorBuilder(
): Promise<IOrchestratorBuildOutput> {
const orchestratorLabelResolvers = cache.get(projectId);

//if user has changed language model settings, invalidate cached embeddings for that dialog
const keysToInvalidate: string[] = [];

for (const [key, labelResolver] of orchestratorLabelResolvers.entries()) {
//JSON.parse can throw - this is expected to be caught in the process message handler below.
const modelName: string | undefined = JSON.parse(LabelResolver.getConfigJson(labelResolver))?.Name;

if (modelName && modelName !== Path.basename(modelPath) + '.onnx') {
keysToInvalidate.push(key);
}
}

for (const key of keysToInvalidate) {
orchestratorLabelResolvers.delete(key);
}

const luObjects = files
.filter((fi) => fi.name.endsWith('.lu') && fi.content)
.map((fi) => ({
id: fi.name,
content: fi.content,
}));

const result = await Orchestrator.buildAsync(
modelPath,
luObjects,
Expand Down
3 changes: 2 additions & 1 deletion Composer/packages/types/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { JSONSchema7 } from 'json-schema';

import type { IBotProject } from './server';
import type { UserIdentity } from './user';
import type { ILuisConfig, IQnAConfig } from './settings';
import type { ILuisConfig, IOrchestratorConfig, IQnAConfig } from './settings';
import { AuthParameters } from './auth';

export type PublishResult = {
Expand Down Expand Up @@ -133,6 +133,7 @@ export type PublishPlugin<Config = any> = {
export type IPublishConfig = {
luis: ILuisConfig;
qna: IQnAConfig;
orchestrator?: IOrchestratorConfig;
};

export type PublishTarget = {
Expand Down
12 changes: 9 additions & 3 deletions Composer/packages/types/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type DialogSetting = {
MicrosoftAppId?: string;
MicrosoftAppPassword?: string;
luis: ILuisConfig;
orchestrator?: IOrchestratorConfig;
luFeatures: ILUFeaturesConfig;
qna: IQnAConfig;
publishTargets?: PublishTarget[];
Expand Down Expand Up @@ -99,11 +100,16 @@ export type IQnAConfig = {
hostname?: string;
};

export type IConfig = ILuisConfig & {
subscriptionKey: string;
qnaRegion: string | 'westus';
export type IOrchestratorConfig = {
model?: Record<'en_intent' | 'multilingual_intent', string>;
};

export type IConfig = ILuisConfig &
IOrchestratorConfig & {
subscriptionKey: string;
qnaRegion: string | 'westus';
};

export type LgOptions = {
customFunctions: string[];
};