Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR cognitiveservices/data-plane/LUIS/Runtime] Update the default tag for LUIS Runtime #2566

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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