Skip to content

Commit

Permalink
Generated from 45eacf818eeb994fb2f61265c0c1a23bfce98782 (#2566)
Browse files Browse the repository at this point in the history
Update the default tag for LUIS Runtime
  • Loading branch information
AutorestCI authored Apr 29, 2019
1 parent 450db21 commit dbc81ed
Show file tree
Hide file tree
Showing 11 changed files with 1,129 additions and 26 deletions.
71 changes: 52 additions & 19 deletions sdk/cognitiveservices/cognitiveservices-luis-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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);
});
Expand All @@ -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

Expand Down Expand Up @@ -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) => {
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -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;

}
}
Loading

0 comments on commit dbc81ed

Please sign in to comment.