diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md b/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md index 745872081dad..c4793bb2fb44 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md @@ -15,7 +15,7 @@ npm install @azure/cognitiveservices-luis-runtime ### How to use -#### nodejs - Authentication, client creation and resolve prediction as an example written in TypeScript. +#### nodejs - Authentication, client creation and getVersionPrediction prediction as an example written in TypeScript. ##### Install @azure/ms-rest-nodeauth @@ -33,15 +33,33 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; msRestNodeAuth.interactiveLogin().then((creds) => { const client = new LUISRuntimeClient(creds, subscriptionId); - const appId = "testappId"; - const query = "testquery"; - const timezoneOffset = 1.01; + const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; + const versionId = "testversionId"; + const predictionRequest: LUISRuntimeModels.PredictionRequest = { + query: "testquery", + options: { + datetimeReference: new Date().toISOString(), + overridePredictions: true + }, + externalEntities: [{ + entityName: "testentityName", + startIndex: 1, + entityLength: 1, + resolution: {} + }], + dynamicLists: [{ + listEntityName: "testlistEntityName", + requestLists: [{ + name: "testname", + canonicalForm: "testcanonicalForm", + synonyms: ["testsynonyms"] + }] + }] + }; const verbose = true; - const staging = true; - const spellCheck = true; - const bingSpellCheckSubscriptionKey = "testbingSpellCheckSubscriptionKey"; + const showAllIntents = true; const log = true; - client.prediction.resolve(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log).then((result) => { + client.prediction.getVersionPrediction(appId, versionId, predictionRequest, verbose, showAllIntents, log).then((result) => { console.log("The result is:"); console.log(result); }); @@ -50,7 +68,7 @@ msRestNodeAuth.interactiveLogin().then((creds) => { }); ``` -#### browser - Authentication, client creation and resolve prediction as an example written in JavaScript. +#### browser - Authentication, client creation and getVersionPrediction prediction as an example written in JavaScript. ##### Install @azure/ms-rest-browserauth @@ -83,15 +101,33 @@ 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 query = "testquery"; - const timezoneOffset = 1.01; + const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; + const versionId = "testversionId"; + const predictionRequest = { + query: "testquery", + options: { + datetimeReference: new Date().toISOString(), + overridePredictions: true + }, + externalEntities: [{ + entityName: "testentityName", + startIndex: 1, + entityLength: 1, + resolution: {} + }], + dynamicLists: [{ + listEntityName: "testlistEntityName", + requestLists: [{ + name: "testname", + canonicalForm: "testcanonicalForm", + synonyms: ["testsynonyms"] + }] + }] + }; const verbose = true; - const staging = true; - const spellCheck = true; - const bingSpellCheckSubscriptionKey = "testbingSpellCheckSubscriptionKey"; + const showAllIntents = true; const log = true; - client.prediction.resolve(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log).then((result) => { + client.prediction.getVersionPrediction(appId, versionId, predictionRequest, verbose, showAllIntents, log).then((result) => { console.log("The result is:"); console.log(result); }).catch((err) => { @@ -108,6 +144,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/sdk/cognitiveservices/cognitiveservices-luis-runtime/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts new file mode 100644 index 000000000000..ba1f69e2dd07 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/lUISRuntimeClient.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as operations from "./operations"; +import { LUISRuntimeClientContext } from "./lUISRuntimeClientContext"; + +class LUISRuntimeClient extends LUISRuntimeClientContext { + // Operation groups + prediction: operations.PredictionOperations; + + /** + * 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(endpoint: string, credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { + super(endpoint, credentials, options); + this.prediction = new operations.PredictionOperations(this); + } +} + +// Operation Specifications + +export { + LUISRuntimeClient, + LUISRuntimeClientContext, + Models as LUISRuntimeModels, + Mappers as LUISRuntimeMappers +}; +export * from "./operations"; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts new file mode 100644 index 000000000000..fa047d17b901 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/lUISRuntimeClientContext.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +import * as msRest from "@azure/ms-rest-js"; + +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(endpoint: string, credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { + if (endpoint === null || endpoint === undefined) { + throw new Error('\'endpoint\' cannot be null.'); + } + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) { + options = {}; + } + if(!options.userAgent) { + const defaultUserAgent = msRest.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.baseUri = "{Endpoint}"; + this.requestContentType = "application/json; charset=utf-8"; + this.endpoint = endpoint; + this.credentials = credentials; + + } +} diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/index.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/index.ts new file mode 100644 index 000000000000..17b316689a74 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/index.ts @@ -0,0 +1,332 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +import * as msRest from "@azure/ms-rest-js"; + + +/** + * @interface + * An interface representing PredictionRequestOptions. + * The custom options for the prediction request. + * + */ +export interface PredictionRequestOptions { + /** + * @member {Date} [datetimeReference] The reference DateTime used for + * predicting datetime entities. + */ + datetimeReference?: Date; + /** + * @member {boolean} [overridePredictions] Whether to make the external + * entities resolution override the predictions if an overlap occurs. + */ + overridePredictions?: boolean; +} + +/** + * @interface + * An interface representing ExternalEntity. + * Defines a user perdicted entity that extends an already existing one. + * + */ +export interface ExternalEntity { + /** + * @member {string} entityName The name of the entity to extend. + */ + entityName: string; + /** + * @member {number} startIndex The start character index of the predicted + * entity. + */ + startIndex: number; + /** + * @member {number} entityLength The length of the predicted entity. + */ + entityLength: number; + /** + * @member {any} [resolution] A user supplied custom resolution to return as + * the entity's prediction. + */ + resolution?: any; +} + +/** + * @interface + * An interface representing RequestList. + * Defines a sub-list to append to an existing list entity. + * + */ +export interface RequestList { + /** + * @member {string} [name] The name of the sub-list. + */ + name?: string; + /** + * @member {string} canonicalForm The canonical form of the sub-list. + */ + canonicalForm: string; + /** + * @member {string[]} [synonyms] The synonyms of the canonical form. + */ + synonyms?: string[]; +} + +/** + * @interface + * An interface representing DynamicList. + * Defines an extension for a list entity. + * + */ +export interface DynamicList { + /** + * @member {string} listEntityName The name of the list entity to extend. + */ + listEntityName: string; + /** + * @member {RequestList[]} requestLists The lists to append on the extended + * list entity. + */ + requestLists: RequestList[]; +} + +/** + * @interface + * An interface representing PredictionRequest. + * Represents the prediction request parameters. + * + */ +export interface PredictionRequest { + /** + * @member {string} query The query to predict + */ + query: string; + /** + * @member {PredictionRequestOptions} [options] The custom options defined + * for this request. + */ + options?: PredictionRequestOptions; + /** + * @member {ExternalEntity[]} [externalEntities] The externally predicted + * entities for this request + */ + externalEntities?: ExternalEntity[]; + /** + * @member {DynamicList[]} [dynamicLists] The dynamically created list + * entities for this request + */ + dynamicLists?: DynamicList[]; +} + +/** + * @interface + * An interface representing Intent. + * Represents an intent prediction. + * + */ +export interface Intent { + /** + * @member {number} [score] The score of the fired intent. + */ + score?: number; + /** + * @member {Prediction} [childApp] The prediction of the dispatched + * application. + */ + childApp?: Prediction; +} + +/** + * @interface + * An interface representing Sentiment. + * The result of the sentiment analaysis. + * + */ +export interface Sentiment { + /** + * @member {number} score The sentiment score of the query. + */ + score: number; + /** + * @member {string} [label] The label of the sentiment analysis result. + */ + label?: string; +} + +/** + * @interface + * An interface representing Prediction. + * Represents the prediction of a query. + * + */ +export interface Prediction { + /** + * @member {string} normalizedQuery The query after pre-processing and + * normalization. + */ + normalizedQuery: string; + /** + * @member {string} [alteredQuery] The query after spell checking. Only set + * if spell check was enabled and a spelling mistake was found. + */ + alteredQuery?: string; + /** + * @member {string} topIntent The name of the top scoring intent. + */ + topIntent: string; + /** + * @member {{ [propertyName: string]: Intent }} intents A dictionary + * representing the intents that fired. + */ + intents: { [propertyName: string]: Intent }; + /** + * @member {{ [propertyName: string]: any }} entities The dictionary + * representing the entities that fired. + */ + entities: { [propertyName: string]: any }; + /** + * @member {Sentiment} [sentiment] The result of the sentiment analysis. + */ + sentiment?: Sentiment; +} + +/** + * @interface + * An interface representing PredictionResponse. + * Represents the prediction response. + * + */ +export interface PredictionResponse { + /** + * @member {string} query The query used in the prediction. + */ + query: string; + /** + * @member {Prediction} prediction The prediction of the requested query. + */ + prediction: Prediction; +} + +/** + * @interface + * An interface representing ErrorBody. + * Represents the definition of the error that occurred. + * + */ +export interface ErrorBody { + /** + * @member {string} code The error code. + */ + code: string; + /** + * @member {string} message The error message. + */ + message: string; +} + +/** + * @interface + * An interface representing ErrorModel. + * Represents the error that occurred. + * + */ +export interface ErrorModel { + /** + * @member {ErrorBody} error + */ + error: ErrorBody; +} + +/** + * @interface + * An interface representing PredictionGetVersionPredictionOptionalParams. + * Optional Parameters. + * + * @extends RequestOptionsBase + */ +export interface PredictionGetVersionPredictionOptionalParams extends msRest.RequestOptionsBase { + /** + * @member {boolean} [verbose] Indicates whether to get extra metadata for + * the entities predictions or not. + */ + verbose?: boolean; + /** + * @member {boolean} [showAllIntents] Indicates whether to return all the + * intents in the response or just the top intent. + */ + showAllIntents?: boolean; + /** + * @member {boolean} [log] Indicates whether to log the endpoint query or + * not. + */ + log?: boolean; +} + +/** + * @interface + * An interface representing PredictionGetSlotPredictionOptionalParams. + * Optional Parameters. + * + * @extends RequestOptionsBase + */ +export interface PredictionGetSlotPredictionOptionalParams extends msRest.RequestOptionsBase { + /** + * @member {boolean} [verbose] Indicates whether to get extra metadata for + * the entities predictions or not. + */ + verbose?: boolean; + /** + * @member {boolean} [showAllIntents] Indicates whether to return all the + * intents in the response or just the top intent. + */ + showAllIntents?: boolean; + /** + * @member {boolean} [log] Indicates whether to log the endpoint query or + * not. + */ + log?: boolean; +} + +/** + * Contains response data for the getVersionPrediction operation. + */ +export type PredictionGetVersionPredictionResponse = PredictionResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: PredictionResponse; + }; +}; + +/** + * Contains response data for the getSlotPrediction operation. + */ +export type PredictionGetSlotPredictionResponse = PredictionResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: PredictionResponse; + }; +}; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/mappers.ts new file mode 100644 index 000000000000..661deed6d2d1 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/mappers.ts @@ -0,0 +1,358 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +import * as msRest from "@azure/ms-rest-js"; + + +export const PredictionRequestOptions: msRest.CompositeMapper = { + serializedName: "PredictionRequestOptions", + type: { + name: "Composite", + className: "PredictionRequestOptions", + modelProperties: { + datetimeReference: { + serializedName: "datetimeReference", + type: { + name: "DateTime" + } + }, + overridePredictions: { + serializedName: "overridePredictions", + type: { + name: "Boolean" + } + } + } + } +}; + +export const ExternalEntity: msRest.CompositeMapper = { + serializedName: "ExternalEntity", + type: { + name: "Composite", + className: "ExternalEntity", + modelProperties: { + entityName: { + required: true, + serializedName: "entityName", + type: { + name: "String" + } + }, + startIndex: { + required: true, + serializedName: "startIndex", + type: { + name: "Number" + } + }, + entityLength: { + required: true, + serializedName: "entityLength", + type: { + name: "Number" + } + }, + resolution: { + serializedName: "resolution", + type: { + name: "Object" + } + } + } + } +}; + +export const RequestList: msRest.CompositeMapper = { + serializedName: "RequestList", + type: { + name: "Composite", + className: "RequestList", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + canonicalForm: { + required: true, + serializedName: "canonicalForm", + type: { + name: "String" + } + }, + synonyms: { + serializedName: "synonyms", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const DynamicList: msRest.CompositeMapper = { + serializedName: "DynamicList", + type: { + name: "Composite", + className: "DynamicList", + modelProperties: { + listEntityName: { + required: true, + serializedName: "listEntityName", + type: { + name: "String" + } + }, + requestLists: { + required: true, + serializedName: "requestLists", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "RequestList" + } + } + } + } + } + } +}; + +export const PredictionRequest: msRest.CompositeMapper = { + serializedName: "PredictionRequest", + type: { + name: "Composite", + className: "PredictionRequest", + modelProperties: { + query: { + required: true, + serializedName: "query", + type: { + name: "String" + } + }, + options: { + serializedName: "options", + type: { + name: "Composite", + className: "PredictionRequestOptions" + } + }, + externalEntities: { + serializedName: "externalEntities", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ExternalEntity" + } + } + } + }, + dynamicLists: { + serializedName: "dynamicLists", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DynamicList" + } + } + } + } + } + } +}; + +export const Intent: msRest.CompositeMapper = { + serializedName: "Intent", + type: { + name: "Composite", + className: "Intent", + modelProperties: { + score: { + serializedName: "score", + type: { + name: "Number" + } + }, + childApp: { + serializedName: "childApp", + type: { + name: "Composite", + className: "Prediction" + } + } + } + } +}; + +export const Sentiment: msRest.CompositeMapper = { + serializedName: "Sentiment", + type: { + name: "Composite", + className: "Sentiment", + modelProperties: { + score: { + required: true, + serializedName: "score", + type: { + name: "Number" + } + }, + label: { + serializedName: "label", + type: { + name: "String" + } + } + } + } +}; + +export const Prediction: msRest.CompositeMapper = { + serializedName: "Prediction", + type: { + name: "Composite", + className: "Prediction", + modelProperties: { + normalizedQuery: { + required: true, + serializedName: "normalizedQuery", + type: { + name: "String" + } + }, + alteredQuery: { + serializedName: "alteredQuery", + type: { + name: "String" + } + }, + topIntent: { + required: true, + serializedName: "topIntent", + type: { + name: "String" + } + }, + intents: { + required: true, + serializedName: "intents", + type: { + name: "Dictionary", + value: { + type: { + name: "Composite", + className: "Intent" + } + } + } + }, + entities: { + required: true, + serializedName: "entities", + type: { + name: "Dictionary", + value: { + type: { + name: "Object" + } + } + } + }, + sentiment: { + serializedName: "sentiment", + type: { + name: "Composite", + className: "Sentiment" + } + } + } + } +}; + +export const PredictionResponse: msRest.CompositeMapper = { + serializedName: "PredictionResponse", + type: { + name: "Composite", + className: "PredictionResponse", + modelProperties: { + query: { + required: true, + serializedName: "query", + type: { + name: "String" + } + }, + prediction: { + required: true, + serializedName: "prediction", + type: { + name: "Composite", + className: "Prediction" + } + } + } + } +}; + +export const ErrorBody: msRest.CompositeMapper = { + serializedName: "ErrorBody", + type: { + name: "Composite", + className: "ErrorBody", + modelProperties: { + code: { + required: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + required: true, + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const ErrorModel: msRest.CompositeMapper = { + serializedName: "Error", + type: { + name: "Composite", + className: "ErrorModel", + modelProperties: { + error: { + required: true, + serializedName: "error", + type: { + name: "Composite", + className: "ErrorBody" + } + } + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/parameters.ts new file mode 100644 index 000000000000..09e658cfa885 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/parameters.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +import * as msRest from "@azure/ms-rest-js"; + +export const appId: msRest.OperationURLParameter = { + parameterPath: "appId", + mapper: { + required: true, + serializedName: "appId", + type: { + name: "Uuid" + } + } +}; +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", + "log" + ], + mapper: { + serializedName: "log", + type: { + name: "Boolean" + } + } +}; +export const showAllIntents: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "showAllIntents" + ], + mapper: { + serializedName: "show-all-intents", + type: { + name: "Boolean" + } + } +}; +export const slotName: msRest.OperationURLParameter = { + parameterPath: "slotName", + mapper: { + required: true, + serializedName: "slotName", + type: { + name: "String" + } + } +}; +export const verbose: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "verbose" + ], + mapper: { + serializedName: "verbose", + type: { + name: "Boolean" + } + } +}; +export const versionId: msRest.OperationURLParameter = { + parameterPath: "versionId", + mapper: { + required: true, + serializedName: "versionId", + type: { + name: "String" + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/predictionOperationsMappers.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/predictionOperationsMappers.ts new file mode 100644 index 000000000000..3a789505eed2 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/models/predictionOperationsMappers.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +export { + PredictionRequest, + PredictionRequestOptions, + ExternalEntity, + DynamicList, + RequestList, + PredictionResponse, + Prediction, + Intent, + Sentiment, + ErrorModel, + ErrorBody +} from "../models/mappers"; + diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/operations/index.ts new file mode 100644 index 000000000000..1dfce0e5c9ae --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/operations/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +export * from "./predictionOperations"; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/operations/predictionOperations.ts b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/operations/predictionOperations.ts new file mode 100644 index 000000000000..e5fb6ae6699a --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/lib/operations/predictionOperations.ts @@ -0,0 +1,164 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * 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. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/predictionOperationsMappers"; +import * as Parameters from "../models/parameters"; +import { LUISRuntimeClientContext } from "../lUISRuntimeClientContext"; + +/** Class representing a PredictionOperations. */ +export class PredictionOperations { + private readonly client: LUISRuntimeClientContext; + + /** + * Create a PredictionOperations. + * @param {LUISRuntimeClientContext} client Reference to the service client. + */ + constructor(client: LUISRuntimeClientContext) { + this.client = client; + } + + /** + * Gets the predictions for an application version. + * @param appId The application ID. + * @param versionId The application version ID. + * @param predictionRequest The prediction request parameters. + * @param [options] The optional parameters + * @returns Promise + */ + getVersionPrediction(appId: string, versionId: string, predictionRequest: Models.PredictionRequest, options?: Models.PredictionGetVersionPredictionOptionalParams): Promise; + /** + * @param appId The application ID. + * @param versionId The application version ID. + * @param predictionRequest The prediction request parameters. + * @param callback The callback + */ + getVersionPrediction(appId: string, versionId: string, predictionRequest: Models.PredictionRequest, callback: msRest.ServiceCallback): void; + /** + * @param appId The application ID. + * @param versionId The application version ID. + * @param predictionRequest The prediction request parameters. + * @param options The optional parameters + * @param callback The callback + */ + getVersionPrediction(appId: string, versionId: string, predictionRequest: Models.PredictionRequest, options: Models.PredictionGetVersionPredictionOptionalParams, callback: msRest.ServiceCallback): void; + getVersionPrediction(appId: string, versionId: string, predictionRequest: Models.PredictionRequest, options?: Models.PredictionGetVersionPredictionOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + appId, + versionId, + predictionRequest, + options + }, + getVersionPredictionOperationSpec, + callback) as Promise; + } + + /** + * Gets the predictions for an application slot. + * @param appId The application ID. + * @param slotName The application slot name. + * @param predictionRequest The prediction request parameters. + * @param [options] The optional parameters + * @returns Promise + */ + getSlotPrediction(appId: string, slotName: string, predictionRequest: Models.PredictionRequest, options?: Models.PredictionGetSlotPredictionOptionalParams): Promise; + /** + * @param appId The application ID. + * @param slotName The application slot name. + * @param predictionRequest The prediction request parameters. + * @param callback The callback + */ + getSlotPrediction(appId: string, slotName: string, predictionRequest: Models.PredictionRequest, callback: msRest.ServiceCallback): void; + /** + * @param appId The application ID. + * @param slotName The application slot name. + * @param predictionRequest The prediction request parameters. + * @param options The optional parameters + * @param callback The callback + */ + getSlotPrediction(appId: string, slotName: string, predictionRequest: Models.PredictionRequest, options: Models.PredictionGetSlotPredictionOptionalParams, callback: msRest.ServiceCallback): void; + getSlotPrediction(appId: string, slotName: string, predictionRequest: Models.PredictionRequest, options?: Models.PredictionGetSlotPredictionOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + appId, + slotName, + predictionRequest, + options + }, + getSlotPredictionOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getVersionPredictionOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "apps/{appId}/versions/{versionId}/predict", + urlParameters: [ + Parameters.endpoint, + Parameters.appId, + Parameters.versionId + ], + queryParameters: [ + Parameters.verbose, + Parameters.showAllIntents, + Parameters.log + ], + requestBody: { + parameterPath: "predictionRequest", + mapper: { + ...Mappers.PredictionRequest, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PredictionResponse + }, + default: { + bodyMapper: Mappers.ErrorModel + } + }, + serializer +}; + +const getSlotPredictionOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "apps/{appId}/slots/{slotName}/predict", + urlParameters: [ + Parameters.endpoint, + Parameters.appId, + Parameters.slotName + ], + queryParameters: [ + Parameters.verbose, + Parameters.showAllIntents, + Parameters.log + ], + requestBody: { + parameterPath: "predictionRequest", + mapper: { + ...Mappers.PredictionRequest, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PredictionResponse + }, + default: { + bodyMapper: Mappers.ErrorModel + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json b/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json index b0056960d3f8..044ac42ec7e5 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-runtime/package.json +++ b/sdk/cognitiveservices/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": [ @@ -25,7 +25,7 @@ "rollup-plugin-sourcemaps": "^0.4.2", "uglify-js": "^3.4.9" }, - "homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-luis-runtime", + "homepage": "https://github.com/azure/azure-sdk-for-js", "repository": { "type": "git", "url": "https://github.com/azure/azure-sdk-for-js.git" @@ -42,8 +42,7 @@ "esm/**/*.js.map", "esm/**/*.d.ts", "esm/**/*.d.ts.map", - "src/**/*.ts", - "README.md", + "lib/**/*.ts", "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 } diff --git a/sdk/cognitiveservices/cognitiveservices-luis-runtime/tsconfig.json b/sdk/cognitiveservices/cognitiveservices-luis-runtime/tsconfig.json index 87bbf5b5fa49..51ea90961ce5 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-runtime/tsconfig.json +++ b/sdk/cognitiveservices/cognitiveservices-luis-runtime/tsconfig.json @@ -14,6 +14,6 @@ "outDir": "./esm", "importHelpers": true }, - "include": ["./src/**/*.ts"], + "include": ["./lib/**/*.ts"], "exclude": ["node_modules"] }