Skip to content

Commit

Permalink
fix: add authoring endpoint for luis setting. (#3364)
Browse files Browse the repository at this point in the history
* add authoring endpoint for luis setting

* add authoring endpoint for deploy

* add endpoint to azure publish schema

* add endpoint for azure function

* update the order

* update the order

* add enpoint and authoring endpoint to provision arm template

Co-authored-by: Qi Kang <qika@microsoft.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
  • Loading branch information
3 people authored Jun 11, 2020
1 parent 2c3d01d commit 9e1913e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
10 changes: 9 additions & 1 deletion Composer/packages/lib/bot-deploy/src/botProjectDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export class BotProjectDeploy {
environment: string,
language: string,
luisEndpoint: string,
luisAuthoringEndpoint: string,
luisEndpointKey: string,
luisAuthoringKey?: string,
luisAuthoringRegion?: string,
Expand Down Expand Up @@ -415,11 +416,15 @@ export class BotProjectDeploy {
luisEndpoint = `https://${luisAuthoringRegion}.api.cognitive.microsoft.com`;
}

if (!luisAuthoringEndpoint) {
luisAuthoringEndpoint = luisEndpoint;
}

const buildResult = await builder.build(
loadResult.luContents,
loadResult.recognizers,
luisAuthoringKey,
luisEndpoint,
luisAuthoringEndpoint,
name,
environment,
language,
Expand Down Expand Up @@ -540,13 +545,15 @@ export class BotProjectDeploy {

let luisEndpointKey = '';
let luisEndpoint = '';
let luisAuthoringEndpoint = '';

if (luisSettings) {
// if luisAuthoringKey is not set, use the one from the luis settings
luisAuthoringKey = luisAuthoringKey || luisSettings.authoringKey;
luisAuthoringRegion = luisAuthoringRegion || luisSettings.region;
luisEndpointKey = luisSettings.endpointKey;
luisEndpoint = luisSettings.endpoint;
luisAuthoringEndpoint = luisSettings.authoringEndpoint;
}

if (!language) {
Expand All @@ -558,6 +565,7 @@ export class BotProjectDeploy {
environment,
language,
luisEndpoint,
luisAuthoringEndpoint,
luisEndpointKey,
luisAuthoringKey,
luisAuthoringRegion,
Expand Down
8 changes: 4 additions & 4 deletions Composer/packages/server/src/models/bot/luPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ export class LuPublisher {
}
const loadResult = await this._loadLuConatents(config.models);
loadResult.luContents = await this._downSizeUtterances(loadResult.luContents);
let endpoint = config.endpoint;
if (!endpoint) {
endpoint = `https://${config.region}.api.cognitive.microsoft.com`;
let authoringEndpoint = config.authoringEndpoint;
if (!authoringEndpoint) {
authoringEndpoint = `https://${config.region}.api.cognitive.microsoft.com`;
}
const buildResult = await this.builder.build(
loadResult.luContents,
loadResult.recognizers,
config.authoringKey,
endpoint,
authoringEndpoint,
config.botName,
config.suffix,
config.fallbackLocal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export class DefaultSettingManager extends FileSettingManager {
luis: {
name: '',
authoringKey: '',
endpoint: '',
authoringEndpoint: '',
endpointKey: '',
endpoint: '',
authoringRegion: 'westus',
defaultLanguage: 'en-us',
environment: 'composer',
Expand Down Expand Up @@ -67,6 +68,10 @@ export class DefaultSettingManager extends FileSettingManager {
if (!result.luis.endpoint && result.luis.endpoint !== '') {
result.luis.endpoint = this.createDefaultSettings().luis.endpoint;
}
//add luis authoring endpoint for old bot
if (!result.luis.authoringEndpoint && result.luis.authoringEndpoint !== '') {
result.luis.authoringEndpoint = this.createDefaultSettings().luis.authoringEndpoint;
}
return result;
}

Expand Down
10 changes: 9 additions & 1 deletion Composer/plugins/azureFunctionsPublish/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const schema: JSONSchema7 = {
luis: {
type: 'object',
properties: {
endpoint: {
type: 'string',
},
authoringEndpoint: {
type: 'string',
},
endpointKey: {
type: 'string',
},
Expand Down Expand Up @@ -118,8 +124,10 @@ const schema: JSONSchema7 = {
container: '<container>',
},
luis: {
endpointKey: '<endpoint key>',
authoringKey: '<authoring key>',
authoringEndpoint: '<luis authoring endpoint>',
endpointKey: '<endpoint key>',
endpoint: '<luis prediction endpoint>',
region: 'westus',
},
MicrosoftAppId: '<app id from Bot Framework registration>',
Expand Down
10 changes: 9 additions & 1 deletion Composer/plugins/azurePublish/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const schema: JSONSchema7 = {
luis: {
type: 'object',
properties: {
endpoint: {
type: 'string',
},
authoringEndpoint: {
type: 'string',
},
endpointKey: {
type: 'string',
},
Expand Down Expand Up @@ -118,8 +124,10 @@ const schema: JSONSchema7 = {
container: '<container>',
},
luis: {
endpointKey: '<endpoint key>',
authoringKey: '<authoring key>',
authoringEndpoint: '<luis authoring endpoint>',
endpointKey: '<endpoint key>',
endpoint: '<luis prediction endpoint>',
region: 'westus',
},
MicrosoftAppId: '<app id from Bot Framework registration>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@
"value": {
"endpointKey": "[if(parameters('shouldCreateLuisResource'), listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1, '')]",
"authoringKey": "[if(parameters('shouldCreateAuthoringResource'), listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('LuisAuthoringAccountName')),'2017-04-18').key1, parameters('luisAuthoringKey'))]",
"region": "[parameters('luisServiceLocation')]"
"region": "[parameters('luisServiceLocation')]",
"endpoint": "[if(parameters('shouldCreateLuisResource'), reference(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName'))).endpoint, '')]",
"authoringEndpoint": "[if(parameters('shouldCreateAuthoringResource'), reference(resourceId('Microsoft.CognitiveServices/accounts', variables('LuisAuthoringAccountName'))).endpoint, '')]"
}
}
}
Expand Down

0 comments on commit 9e1913e

Please sign in to comment.