Skip to content

Commit

Permalink
fix(core.gbapp): NLP key bug fixed after MSFT change of NLP service.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 28, 2020
1 parent 76d175d commit b901d6b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/azuredeployer.gbapp/services/AzureDeployerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
location: string,
nlpAppId: string,
clEntityId: string,
nlpAuthoringKey: string,
nlpKey: string,
data: any,
) {

Expand All @@ -703,7 +703,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/apps/${nlpAppId}/versions/0.1/closedlists/${clEntityId}`;
req.headers.set('Content-Type', 'application/json');
req.headers.set('accept-language', '*');
req.headers.set('Ocp-Apim-Subscription-Key', nlpAuthoringKey);
req.headers.set('Ocp-Apim-Subscription-Key', nlpKey);
req.body = JSON.stringify(data);
const httpClient = new ServiceClient();

Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class GBDeployer implements IGBDeployer {
instance.cloudLocation,
instance.nlpAppId,
listName,
instance.nlpAuthoringKey,
instance.nlpKey,
listData
);
if (res.status !== 200) throw res.bodyAsText;
Expand Down
25 changes: 23 additions & 2 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class GBMinService {
id,
`Agora falando com ${activeMin.instance.title}...`
);

let startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`);
if (startDialog) {
Expand Down Expand Up @@ -782,8 +782,21 @@ export class GBMinService {

// Spells check the input text before translating.

text = await min.conversationalService.spellCheck(min, text);
const keepText: string = min.core.getParam<string>(
min.instance,
'Keep Text',
null
);

if (keepText) {
const list = keepText.split(';');
let i = 0;
await CollectionUtil.asyncForEach(list, item => {
i++;
text = text.replace(new RegExp(item.trim(), 'gi'), `KEEPTEXT${i}`);
});
}
text = await min.conversationalService.spellCheck(min, text);
// Detects user typed language and updates their locale profile if applies.

let locale = min.core.getParam<string>(
Expand Down Expand Up @@ -823,6 +836,14 @@ export class GBMinService {
);

text = await min.conversationalService.translate(min, text, contentLocale);
if (keepText) {
const list = keepText.split(';');
let i = 0;
await CollectionUtil.asyncForEach(list, item => {
i++;
text = text.replace(`KEEPTEXT${i}`, item.trim());
});
}
GBLog.info(`Translated text (processMessageActivity): ${text}.`);
context.activity.text = text;
context.activity.originalText = originalText;
Expand Down

0 comments on commit b901d6b

Please sign in to comment.