forked from devcode1981/BotFramework-Composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bf-orchestrator lib integration (microsoft#4384)
* Add bf-orchestrator dependency * Basic API and FT * Add test to ignore list for now * Fix linter issues * Update orchestrator-core to pick up Linux fixes * Fixes after latest merge * Attempt to run orchestrator tests on CI * Disable test again local model is available * Try to bring glic into alpine-linux * Revert "Try to bring glic into alpine-linux" This reverts commit ff119aa. * Try switching to buster for Orchestrator * lockdown orchestrator version due to API change * Add libgomp dep for orchestrator Co-authored-by: Dong Lei <[email protected]>
- Loading branch information
1 parent
54d6f7a
commit 006a589
Showing
9 changed files
with
530 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Composer/packages/server/src/models/bot/__mocks__/mockLUInput.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"name": "emptybot-1.dialog", | ||
"content": "{\n \"$kind\": \"Microsoft.AdaptiveDialog\",\n \"$designer\": {\n \"name\": \"AddItem\",\n \"id\": \"225905\"\n },\n \"autoEndDialog\": true,\n \"defaultResultProperty\": \"dialog.result\",\n \"triggers\": [\n {\n \"$kind\": \"Microsoft.OnBeginDialog\",\n \"$designer\": {\n \"name\": \"BeginDialog\",\n \"id\": \"479346\"\n },\n \"actions\": [\n {\n \"$kind\": \"Microsoft.SetProperties\",\n \"$designer\": {\n \"id\": \"811190\",\n \"name\": \"Set properties\"\n },\n \"assignments\": [\n {\n \"property\": \"dialog.itemTitle\",\n \"value\": \"=coalesce(@itemTitle, $itemTitle)\"\n },\n {\n \"property\": \"dialog.listType\",\n \"value\": \"=coalesce(@listType, $listType)\"\n }\n ]\n },\n {\n \"$kind\": \"Microsoft.TextInput\",\n \"$designer\": {\n \"id\": \"282825\",\n \"name\": \"AskForTitle\"\n },\n \"prompt\": \"${TextInput_Prompt_282825()}\",\n \"maxTurnCount\": \"3\",\n \"property\": \"dialog.itemTitle\",\n \"value\": \"=coalesce(@itemTitle, $itemTitle)\",\n \"allowInterruptions\": \"!@itemTitle && #_Interruption.Score >= 0.9\"\n },\n {\n \"$kind\": \"Microsoft.ChoiceInput\",\n \"$designer\": {\n \"id\": \"878594\",\n \"name\": \"AskForListType\"\n },\n \"prompt\": \"${TextInput_Prompt_878594()}\",\n \"maxTurnCount\": \"3\",\n \"property\": \"dialog.listType\",\n \"value\": \"=@listType\",\n \"allowInterruptions\": \"!@listType\",\n \"outputFormat\": \"value\",\n \"choices\": [\n {\n \"value\": \"todo\",\n \"synonyms\": [\n \"to do\"\n ]\n },\n {\n \"value\": \"grocery\",\n \"synonyms\": [\n \"groceries\"\n ]\n },\n {\n \"value\": \"shopping\",\n \"synonyms\": [\n \"shoppers\"\n ]\n }\n ],\n \"appendChoices\": \"true\",\n \"defaultLocale\": \"en-us\",\n \"style\": \"Auto\",\n \"choiceOptions\": {\n \"inlineSeparator\": \", \",\n \"inlineOr\": \" or \",\n \"inlineOrMore\": \", or \",\n \"includeNumbers\": true\n },\n \"recognizerOptions\": {\n \"noValue\": false\n }\n },\n {\n \"$kind\": \"Microsoft.EditArray\",\n \"$designer\": {\n \"id\": \"733511\",\n \"name\": \"Edit an Array property\"\n },\n \"changeType\": \"push\",\n \"itemsProperty\": \"user.lists[dialog.listType]\",\n \"value\": \"=$itemTitle\"\n },\n {\n \"$kind\": \"Microsoft.SendActivity\",\n \"$designer\": {\n \"id\": \"139532\",\n \"name\": \"Send a response\"\n },\n \"activity\": \"${SendActivity_139532()}\"\n }\n ]\n }\n ],\n \"generator\": \"additem.lg\",\n \"recognizer\": \"additem.lu\"\n}\n", | ||
"path": "/Users/tester/Desktop/EmptyBot-1/additem.dialog", | ||
"relativePath": "", | ||
"lastModified": "Thu Jul 09 2020 10:19:09 GMT-0700 (Pacific Daylight Time)" | ||
}, | ||
{ | ||
"name": "additem.en-us.lu", | ||
"content": "\n# TextInput_Response_282825\n- Please remind me to {itemTitle=buy milk}\n- Please remember that I need to {itemTitle=buy milk}\n- shoppers", | ||
"path": "/Users/tester/Desktop/EmptyBot-1/dialogs/additem/language-understanding/en-us/additem.en-us.lu", | ||
"relativePath": "dialogs/additem/language-understanding/en-us/additem.en-us.lu", | ||
"lastModified": "Thu Jul 09 2020 10:19:09 GMT-0700 (Pacific Daylight Time)" | ||
} | ||
] |
85 changes: 85 additions & 0 deletions
85
Composer/packages/server/src/models/bot/__tests__/orchestratorBuilder.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import * as path from 'path'; | ||
|
||
import rimraf from 'rimraf'; | ||
import { FileInfo } from '@bfc/shared'; | ||
import { Utility } from '@microsoft/bf-orchestrator'; | ||
|
||
import { IFileStorage } from '../../storage/interface'; | ||
import { Builder } from '../builder'; | ||
import mockLUInput from '../__mocks__/mockLUInput.json'; | ||
|
||
const nlrId = 'pretrained.20200924.microsoft.dte.00.03.en.onnx'; | ||
const nlrPath: string = path.resolve('./orchestrator_ut_model/'); | ||
const downloadModelTimeoutMs = 90000; | ||
|
||
describe('Orchestrator Tests', () => { | ||
beforeAll(async () => { | ||
// disable Orchestrator Lib console logging across the board - interferes with Jest | ||
Utility.toPrintDebuggingLogToConsole = false; | ||
|
||
const progressStatusStub = jest.fn(); | ||
const successStatusStub = jest.fn(); | ||
|
||
const builder = new Builder('', {} as IFileStorage, 'en-us'); | ||
|
||
// download the UT NLR model once before all tests are run - build tests don't work without a valid model | ||
await builder.runOrchestratorNlrGet(nlrPath, nlrId, progressStatusStub, successStatusStub); | ||
|
||
expect(progressStatusStub).toBeCalled(); | ||
expect(successStatusStub).toBeCalledTimes(1); | ||
}, downloadModelTimeoutMs); | ||
|
||
afterAll(async () => { | ||
const callbackStub = jest.fn(); | ||
rimraf(nlrPath, callbackStub); | ||
|
||
expect(callbackStub).toBeCalledWith(); | ||
}); | ||
|
||
it('always lists DTE 3L model for FTs', async () => { | ||
const builder = new Builder('', {} as IFileStorage, 'en-us'); | ||
|
||
const nlrList = await builder.runOrchestratorNlrList(); | ||
expect(Object.getOwnPropertyNames(nlrList.models)).toContain(nlrId); | ||
}); | ||
|
||
it('throws if input empty', () => { | ||
const builder = new Builder('', {} as IFileStorage, 'en-us'); | ||
|
||
expect(builder.runOrchestratorBuild([], nlrPath)).rejects.toThrow(); | ||
}); | ||
|
||
it('throws if NLR path invalid', () => { | ||
const builder = new Builder('', {} as IFileStorage, 'en-us'); | ||
|
||
const data: FileInfo[] = [{ name: 'hello', content: 'test', lastModified: '', path: '', relativePath: '' }]; | ||
expect(builder.runOrchestratorBuild(data, 'invalidPath')).rejects.toThrow(); | ||
}); | ||
|
||
it('produces expected snapshot and recognizer shape', async () => { | ||
const builder = new Builder('', {} as IFileStorage, 'en-us'); | ||
|
||
const buildOutput = await builder.runOrchestratorBuild(mockLUInput, nlrPath); | ||
|
||
expect(buildOutput.outputs.map((o) => o.id)).toContain('additem.en-us.lu'); | ||
|
||
const addItemData = buildOutput.outputs.find((o) => o.id == 'additem.en-us.lu'); | ||
expect(addItemData?.snapshot).toBeTruthy(); | ||
}); | ||
|
||
it('produces expected recognizer shape', async () => { | ||
const builder = new Builder('', {} as IFileStorage, 'en-us'); | ||
const buildOutput = await builder.runOrchestratorBuild(mockLUInput, nlrPath); | ||
|
||
expect(buildOutput.outputs.map((o) => o.id)).toContain('additem.en-us.lu'); | ||
|
||
const addItemData = buildOutput.outputs.find((o) => o.id == 'additem.en-us.lu'); | ||
expect(addItemData?.recognizer).toBeTruthy(); | ||
|
||
expect(addItemData?.recognizer.orchestratorRecognizer).toBeTruthy(); | ||
expect(addItemData?.recognizer.orchestratorRecognizer.$kind).toBe('Microsoft.OrchestratorRecognizer'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.