Skip to content

Commit

Permalink
Merge pull request #766 from Microsoft/daveta-update-luis
Browse files Browse the repository at this point in the history
Update LUIS to new (Azure) nodejs SDK
  • Loading branch information
cleemullins authored Feb 19, 2019
2 parents 4d99d33 + 0cea5c5 commit 5860634
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 16 deletions.
8 changes: 5 additions & 3 deletions libraries/botbuilder-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"dependencies": {
"@azure/cognitiveservices-luis-runtime": "^1.2.0",
"@azure/ms-rest-js": "^1.6.0",
"@microsoft/recognizers-text-date-time": "1.1.2",
"@types/html-entities": "^1.2.16",
"@types/node": "^10.12.18",
"@types/request-promise-native": "^1.0.10",
"azure-cognitiveservices-luis-runtime": "^1.0.0",
"botbuilder": "~4.1.6",
"botbuilder-core": "~4.1.6",
"html-entities": "^1.2.1",
"moment": "^2.20.1",
"ms-rest": "^2.3.6",
Expand All @@ -37,6 +38,7 @@
"devDependencies": {
"@types/mocha": "^2.2.47",
"codelyzer": "^4.1.0",
"fs-extra": "^7.0.1",
"mocha": "^5.2.0",
"nock": "^10.0.1",
"nyc": "^11.4.1",
Expand All @@ -52,6 +54,6 @@
},
"files": [
"/lib",
"/src"
"/src"
]
}
14 changes: 7 additions & 7 deletions libraries/botbuilder-ai/src/luisRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { LUISRuntimeClient as LuisClient, LUISRuntimeModels as LuisModels } from 'azure-cognitiveservices-luis-runtime';
import { RecognizerResult, TurnContext } from 'botbuilder';
import * as msRest from 'ms-rest';
import { LUISRuntimeClient as LuisClient, LUISRuntimeModels as LuisModels } from '@azure/cognitiveservices-luis-runtime';
import { RecognizerResult, TurnContext } from 'botbuilder-core';
import * as msRest from "@azure/ms-rest-js";
import * as os from 'os';
import * as Url from 'url-parse';

Expand Down Expand Up @@ -159,7 +159,7 @@ export class LuisRecognizer {
// Create client
const creds: msRest.TokenCredentials = new msRest.TokenCredentials(this.application.endpointKey);
const baseUri: string = this.application.endpoint || 'https://westus.api.cognitive.microsoft.com';
this.luisClient = new LuisClient(creds, baseUri);
this.luisClient = new LuisClient(baseUri, creds);
}

/**
Expand Down Expand Up @@ -298,8 +298,8 @@ export class LuisRecognizer {
// If the `error` received is a azure-cognitiveservices-luis-runtime error,
// it may have a `response` property and `response.statusCode`.
// If these properties exist, we should populate the error with a correct and informative error message.
if ((error as any).response && (error as any).response.statusCode) {
switch ((error as any).response.statusCode) {
if ((error as any).response && (error as any).response.status) {
switch ((error as any).response.status) {
case 400:
error.message = [
`Response 400: The request's body or parameters are incorrect,`,
Expand All @@ -326,7 +326,7 @@ export class LuisRecognizer {
break;
default:
error.message = [
`Response ${(error as any).response.statusCode}: Unexpected status code received.`,
`Response ${(error as any).response.status}: Unexpected status code received.`,
`Please verify that your LUIS application is properly setup.`
].join(' ');
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai/src/qnaMaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { Activity, TurnContext } from 'botbuilder';
import { Activity, TurnContext } from 'botbuilder-core';
import * as entities from 'html-entities';
import * as os from 'os';
const pjson: any = require('../package.json');
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai/tests/luisRecognizer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const fs = require('fs-extra');
const nock = require('nock');
const { TestAdapter, TurnContext } = require('botbuilder');
const { TestAdapter, TurnContext } = require('botbuilder-core');
const { LuisRecognizer } = require('../');
const luisAppId = '38330cad-f768-4619-96f9-69ea333e594b';

Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-ai/tests/qnaMaker.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');
const { TestAdapter, TurnContext } = require('botbuilder');
const { TestAdapter, TurnContext } = require('botbuilder-core');
const { QnAMaker } = require('../');
const nock = require('nock');
const fs = require('fs');
Expand Down
6 changes: 3 additions & 3 deletions libraries/botbuilder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
},
"files": [
"/lib",
"/src"
]
}
"/src"
]
}
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5860634

Please sign in to comment.