From 0471fcf21e1e95afe30a1a68d7ae1433d90db468 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 19 Mar 2019 17:55:24 +0000 Subject: [PATCH] Generated from faaca6c0dec3efe45b35a48607afa09ed360645a LUIS runtime changes --- .../cognitiveservices-luis-runtime/README.md | 15 +- .../lib/lUISRuntimeClient.ts | 6 +- .../lib/lUISRuntimeClientContext.ts | 19 +-- .../lib/models/index.ts | 136 +++++++++++++----- .../lib/models/mappers.ts | 6 +- .../lib/models/parameters.ts | 57 ++++++-- .../lib/models/predictionMappers.ts | 21 +-- .../lib/operations/prediction.ts | 31 +++- .../package.json | 6 +- 9 files changed, 207 insertions(+), 90 deletions(-) diff --git a/packages/@azure/cognitiveservices-luis-runtime/README.md b/packages/@azure/cognitiveservices-luis-runtime/README.md index 53a4ab635ea2..c9716b319c75 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/README.md +++ b/packages/@azure/cognitiveservices-luis-runtime/README.md @@ -33,7 +33,9 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; msRestNodeAuth.interactiveLogin().then((creds) => { const client = new LUISRuntimeClient(creds, subscriptionId); - const appId = "testappId"; + const azureRegion = "westus"; + const azureCloud = "com"; + const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; const query = "testquery"; const timezoneOffset = 1.01; const verbose = true; @@ -41,7 +43,7 @@ msRestNodeAuth.interactiveLogin().then((creds) => { const spellCheck = true; const bingSpellCheckSubscriptionKey = "testbingSpellCheckSubscriptionKey"; const log = true; - client.prediction.resolve(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log).then((result) => { + client.prediction.resolve(azureRegion, azureCloud, appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log).then((result) => { console.log("The result is:"); console.log(result); }); @@ -83,7 +85,9 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to authManager.login(); } const client = new Azure.CognitiveservicesLuisRuntime.LUISRuntimeClient(res.creds, subscriptionId); - const appId = "testappId"; + const azureRegion = "westus"; + const azureCloud = "com"; + const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; const query = "testquery"; const timezoneOffset = 1.01; const verbose = true; @@ -91,7 +95,7 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to const spellCheck = true; const bingSpellCheckSubscriptionKey = "testbingSpellCheckSubscriptionKey"; const log = true; - client.prediction.resolve(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log).then((result) => { + client.prediction.resolve(azureRegion, azureCloud, appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log).then((result) => { console.log("The result is:"); console.log(result); }).catch((err) => { @@ -108,6 +112,3 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to ## Related projects - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fpackages%2F%40azure%2Fcognitiveservices-luis-runtime%2FREADME.png) diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts index d55de41ebde8..22665eb6871d 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts @@ -20,13 +20,11 @@ class LUISRuntimeClient extends LUISRuntimeClientContext { /** * Initializes a new instance of the LUISRuntimeClient class. - * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://westus.api.cognitive.microsoft.com). * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { - super(credentials, endpoint, options); + constructor(credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { + super(credentials, options); this.prediction = new operations.Prediction(this); } } diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts index b8ca93e8fa8a..44c2b14001dd 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts @@ -14,38 +14,31 @@ const packageName = "@azure/cognitiveservices-luis-runtime"; const packageVersion = "2.0.0"; export class LUISRuntimeClientContext extends msRest.ServiceClient { - endpoint: string; credentials: msRest.ServiceClientCredentials; /** * Initializes a new instance of the LUISRuntimeClientContext class. - * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://westus.api.cognitive.microsoft.com). * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { - if (endpoint == undefined) { - throw new Error("'endpoint' cannot be null."); - } - if (credentials == undefined) { - throw new Error("'credentials' cannot be null."); + constructor(credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); } if (!options) { options = {}; } - - if (!options.userAgent) { + if(!options.userAgent) { const defaultUserAgent = msRest.getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } super(credentials, options); - this.baseUri = "{Endpoint}/luis/v2.0"; + this.baseUri = "http://{AzureRegion}.api.cognitive.microsoft.{AzureCloud}"; this.requestContentType = "application/json; charset=utf-8"; - this.endpoint = endpoint; this.credentials = credentials; + } } diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/models/index.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/models/index.ts index 93de9ea9fd06..2e4b14a27441 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/models/index.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/models/index.ts @@ -1,193 +1,264 @@ /* * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Licensed under the MIT License. See License.txt in the project root for + * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ - import * as msRest from "@azure/ms-rest-js"; + /** + * @interface + * An interface representing IntentModel. * An intent detected from the utterance. + * */ export interface IntentModel { /** - * Name of the intent, as defined in LUIS. + * @member {string} [intent] Name of the intent, as defined in LUIS. */ intent?: string; /** - * Associated prediction score for the intent (float). + * @member {number} [score] Associated prediction score for the intent + * (float). */ score?: number; } /** + * @interface + * An interface representing EntityModel. * An entity extracted from the utterance. + * */ export interface EntityModel { /** - * Name of the entity, as defined in LUIS. + * @member {string} entity Name of the entity, as defined in LUIS. */ entity: string; /** - * Type of the entity, as defined in LUIS. + * @member {string} type Type of the entity, as defined in LUIS. */ type: string; /** - * The position of the first character of the matched entity within the utterance. + * @member {number} startIndex The position of the first character of the + * matched entity within the utterance. */ startIndex: number; /** - * The position of the last character of the matched entity within the utterance. + * @member {number} endIndex The position of the last character of the + * matched entity within the utterance. */ endIndex: number; /** - * Describes unknown properties. The value of an unknown property can be of "any" type. + * @property Describes unknown properties. The value of an unknown property + * can be of "any" type. */ [property: string]: any; } /** + * @interface + * An interface representing CompositeChildModel. * Child entity in a LUIS Composite Entity. + * */ export interface CompositeChildModel { /** - * Type of child entity. + * @member {string} type Type of child entity. */ type: string; /** - * Value extracted by LUIS. + * @member {string} value Value extracted by LUIS. */ value: string; } /** + * @interface + * An interface representing CompositeEntityModel. * LUIS Composite Entity. + * */ export interface CompositeEntityModel { /** - * Type/name of parent entity. + * @member {string} parentType Type/name of parent entity. */ parentType: string; /** - * Value for composite entity extracted by LUIS. + * @member {string} value Value for composite entity extracted by LUIS. */ value: string; /** - * Child entities. + * @member {CompositeChildModel[]} children Child entities. */ children: CompositeChildModel[]; } /** + * @interface + * An interface representing Sentiment. * Sentiment of the input utterance. + * */ export interface Sentiment { /** - * The polarity of the sentiment, can be positive, neutral or negative. + * @member {string} [label] The polarity of the sentiment, can be positive, + * neutral or negative. */ label?: string; /** - * Score of the sentiment, ranges from 0 (most negative) to 1 (most positive). + * @member {number} [score] Score of the sentiment, ranges from 0 (most + * negative) to 1 (most positive). */ score?: number; } /** + * @interface + * An interface representing LuisResult. * Prediction, based on the input query, containing intent(s) and entities. + * */ export interface LuisResult { /** - * The input utterance that was analyzed. + * @member {string} [query] The input utterance that was analyzed. */ query?: string; /** - * The corrected utterance (when spell checking was enabled). + * @member {string} [alteredQuery] The corrected utterance (when spell + * checking was enabled). */ alteredQuery?: string; + /** + * @member {IntentModel} [topScoringIntent] + */ topScoringIntent?: IntentModel; /** - * All the intents (and their score) that were detected from utterance. + * @member {IntentModel[]} [intents] All the intents (and their score) that + * were detected from utterance. */ intents?: IntentModel[]; /** - * The entities extracted from the utterance. + * @member {EntityModel[]} [entities] The entities extracted from the + * utterance. */ entities?: EntityModel[]; /** - * The composite entities extracted from the utterance. + * @member {CompositeEntityModel[]} [compositeEntities] The composite + * entities extracted from the utterance. */ compositeEntities?: CompositeEntityModel[]; + /** + * @member {Sentiment} [sentimentAnalysis] + */ sentimentAnalysis?: Sentiment; + /** + * @member {LuisResult} [connectedServiceResult] + */ connectedServiceResult?: LuisResult; } /** + * @interface * An interface representing EntityWithScore. + * @extends EntityModel */ export interface EntityWithScore extends EntityModel { /** - * Associated prediction score for the intent (float). + * @member {number} score Associated prediction score for the intent (float). */ score: number; } /** + * @interface * An interface representing EntityWithResolution. + * @extends EntityModel */ export interface EntityWithResolution extends EntityModel { /** - * Resolution values for pre-built LUIS entities. + * @member {any} resolution Resolution values for pre-built LUIS entities. */ resolution: any; } /** + * @interface + * An interface representing APIError. * Error information returned by the API + * */ export interface APIError { /** - * HTTP Status code + * @member {string} [statusCode] HTTP Status code */ statusCode?: string; /** - * Cause of the error. + * @member {string} [message] Cause of the error. */ message?: string; } /** + * @interface + * An interface representing PredictionResolveOptionalParams. * Optional Parameters. + * + * @extends RequestOptionsBase */ export interface PredictionResolveOptionalParams extends msRest.RequestOptionsBase { /** - * The timezone offset for the location of the request. + * @member {number} [timezoneOffset] The timezone offset for the location of + * the request. */ timezoneOffset?: number; /** - * If true, return all intents instead of just the top scoring intent. + * @member {boolean} [verbose] If true, return all intents instead of just + * the top scoring intent. */ verbose?: boolean; /** - * Use the staging endpoint slot. + * @member {boolean} [staging] Use the staging endpoint slot. */ staging?: boolean; /** - * Enable spell checking. + * @member {boolean} [spellCheck] Enable spell checking. */ spellCheck?: boolean; /** - * The subscription key to use when enabling bing spell check + * @member {string} [bingSpellCheckSubscriptionKey] The subscription key to + * use when enabling Bing spell check */ bingSpellCheckSubscriptionKey?: string; /** - * Log query (default is true) + * @member {boolean} [log] Log query (default is true) */ log?: boolean; } +/** + * Defines values for AzureRegions. + * Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', + * 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', + * 'brazilsouth', 'virginia' + * @readonly + * @enum {string} + */ +export type AzureRegions = 'westus' | 'westeurope' | 'southeastasia' | 'eastus2' | 'westcentralus' | 'westus2' | 'eastus' | 'southcentralus' | 'northeurope' | 'eastasia' | 'australiaeast' | 'brazilsouth' | 'virginia'; + +/** + * Defines values for AzureClouds. + * Possible values include: 'com', 'us' + * @readonly + * @enum {string} + */ +export type AzureClouds = 'com' | 'us'; + /** * Contains response data for the resolve operation. */ @@ -200,7 +271,6 @@ export type PredictionResolveResponse = LuisResult & { * The response body as text (string format) */ bodyAsText: string; - /** * The response body as parsed JSON or XML */ diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/models/mappers.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/models/mappers.ts index fce7171486fd..adfb6e94ce82 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/models/mappers.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/models/mappers.ts @@ -1,9 +1,11 @@ /* * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Licensed under the MIT License. See License.txt in the project root for + * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ import * as msRest from "@azure/ms-rest-js"; diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/models/parameters.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/models/parameters.ts index 064d94f1d936..7c84561f03f7 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/models/parameters.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/models/parameters.ts @@ -16,10 +16,53 @@ export const appId: msRest.OperationURLParameter = { required: true, serializedName: "appId", type: { - name: "String" + name: "Uuid" } } }; +export const azureCloud: msRest.OperationURLParameter = { + parameterPath: "azureCloud", + mapper: { + required: true, + serializedName: "AzureCloud", + defaultValue: 'com', + type: { + name: "Enum", + allowedValues: [ + "com", + "us" + ] + } + }, + skipEncoding: true +}; +export const azureRegion: msRest.OperationURLParameter = { + parameterPath: "azureRegion", + mapper: { + required: true, + serializedName: "AzureRegion", + defaultValue: 'westus', + type: { + name: "Enum", + allowedValues: [ + "westus", + "westeurope", + "southeastasia", + "eastus2", + "westcentralus", + "westus2", + "eastus", + "southcentralus", + "northeurope", + "eastasia", + "australiaeast", + "brazilsouth", + "virginia" + ] + } + }, + skipEncoding: true +}; export const bingSpellCheckSubscriptionKey: msRest.OperationQueryParameter = { parameterPath: [ "options", @@ -32,18 +75,6 @@ export const bingSpellCheckSubscriptionKey: msRest.OperationQueryParameter = { } } }; -export const endpoint: msRest.OperationURLParameter = { - parameterPath: "endpoint", - mapper: { - required: true, - serializedName: "Endpoint", - defaultValue: '', - type: { - name: "String" - } - }, - skipEncoding: true -}; export const log: msRest.OperationQueryParameter = { parameterPath: [ "options", diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/models/predictionMappers.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/models/predictionMappers.ts index 51a31d9f8896..811d97c4ce62 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/models/predictionMappers.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/models/predictionMappers.ts @@ -1,19 +1,22 @@ /* * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Licensed under the MIT License. See License.txt in the project root for + * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ export { - APIError, - CompositeChildModel, - CompositeEntityModel, + LuisResult, + IntentModel, EntityModel, - EntityWithResolution, + CompositeEntityModel, + CompositeChildModel, + Sentiment, + APIError, EntityWithScore, - IntentModel, - LuisResult, - Sentiment + EntityWithResolution } from "../models/mappers"; + diff --git a/packages/@azure/cognitiveservices-luis-runtime/lib/operations/prediction.ts b/packages/@azure/cognitiveservices-luis-runtime/lib/operations/prediction.ts index 6826d7a0b6b0..cf9ebc28798e 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/lib/operations/prediction.ts +++ b/packages/@azure/cognitiveservices-luis-runtime/lib/operations/prediction.ts @@ -29,28 +29,48 @@ export class Prediction { /** * Gets predictions for a given utterance, in the form of intents and entities. The current maximum * query size is 500 characters. + * @param azureRegion Supported Azure regions for Cognitive Services endpoints. Possible values + * include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', + * 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth', + * 'virginia' + * @param azureCloud Supported Azure Clouds for Cognitive Services endpoints. Possible values + * include: 'com', 'us' * @param appId The LUIS application ID (Guid). * @param query The utterance to predict. * @param [options] The optional parameters * @returns Promise */ - resolve(appId: string, query: string, options?: Models.PredictionResolveOptionalParams): Promise; + resolve(azureRegion: Models.AzureRegions, azureCloud: Models.AzureClouds, appId: string, query: string, options?: Models.PredictionResolveOptionalParams): Promise; /** + * @param azureRegion Supported Azure regions for Cognitive Services endpoints. Possible values + * include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', + * 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth', + * 'virginia' + * @param azureCloud Supported Azure Clouds for Cognitive Services endpoints. Possible values + * include: 'com', 'us' * @param appId The LUIS application ID (Guid). * @param query The utterance to predict. * @param callback The callback */ - resolve(appId: string, query: string, callback: msRest.ServiceCallback): void; + resolve(azureRegion: Models.AzureRegions, azureCloud: Models.AzureClouds, appId: string, query: string, callback: msRest.ServiceCallback): void; /** + * @param azureRegion Supported Azure regions for Cognitive Services endpoints. Possible values + * include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', + * 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth', + * 'virginia' + * @param azureCloud Supported Azure Clouds for Cognitive Services endpoints. Possible values + * include: 'com', 'us' * @param appId The LUIS application ID (Guid). * @param query The utterance to predict. * @param options The optional parameters * @param callback The callback */ - resolve(appId: string, query: string, options: Models.PredictionResolveOptionalParams, callback: msRest.ServiceCallback): void; - resolve(appId: string, query: string, options?: Models.PredictionResolveOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + resolve(azureRegion: Models.AzureRegions, azureCloud: Models.AzureClouds, appId: string, query: string, options: Models.PredictionResolveOptionalParams, callback: msRest.ServiceCallback): void; + resolve(azureRegion: Models.AzureRegions, azureCloud: Models.AzureClouds, appId: string, query: string, options?: Models.PredictionResolveOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { + azureRegion, + azureCloud, appId, query, options @@ -66,7 +86,8 @@ const resolveOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "apps/{appId}", urlParameters: [ - Parameters.endpoint, + Parameters.azureRegion, + Parameters.azureCloud, Parameters.appId ], queryParameters: [ diff --git a/packages/@azure/cognitiveservices-luis-runtime/package.json b/packages/@azure/cognitiveservices-luis-runtime/package.json index 72b0c12318c2..7364fde60a59 100644 --- a/packages/@azure/cognitiveservices-luis-runtime/package.json +++ b/packages/@azure/cognitiveservices-luis-runtime/package.json @@ -4,7 +4,7 @@ "description": "LUISRuntimeClient Library with typescript type definitions for node.js and browser.", "version": "2.0.0", "dependencies": { - "@azure/ms-rest-js": "^1.6.0", + "@azure/ms-rest-js": "^1.2.0", "tslib": "^1.9.3" }, "keywords": [ @@ -43,7 +43,6 @@ "esm/**/*.d.ts", "esm/**/*.d.ts.map", "lib/**/*.ts", - "README.md", "rollup.config.js", "tsconfig.json" ], @@ -52,6 +51,5 @@ "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-luis-runtime.js.map'\" -o ./dist/cognitiveservices-luis-runtime.min.js ./dist/cognitiveservices-luis-runtime.js", "prepack": "npm install && npm run build" }, - "sideEffects": false, - "autoPublish": true + "sideEffects": false }