How to use @azure/cognitiveservices-luis-authoring - 5 common examples

To help you get started, we’ve selected a few @azure/cognitiveservices-luis-authoring examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure-Samples / cognitive-services-quickstart-code / javascript / LUIS / node-sdk-authoring-prediction / luis_authoring_quickstart.js View on Github external
// 
const msRest = require("@azure/ms-rest-js");
const LUIS = require("@azure/cognitiveservices-luis-authoring");
// 

// 
const key = 'REPLACE-WITH-YOUR-ASSIGNED-AUTHORING-KEY';

const endpoint = "https://REPLACE-WITH-RESOURCE-NAME.cognitiveservices.azure.com/"
// 

// 
const luisAuthoringCredentials = new msRest.ApiKeyCredentials({
  inHeader: { "Ocp-Apim-Subscription-Key": key }
});
const luisAuthoringClient = new LUIS.LUISAuthoringClient(
  luisAuthoringCredentials,
  endpoint
);
// 

// 
const delayTimer = async timeInMs => {
  return await new Promise(resolve => {
    setTimeout(resolve, timeInMs);
  });
};
// 

// 
const create_app = async () => {
  const create_app_payload = {
github Azure-Samples / cognitive-services-quickstart-code / javascript / LUIS / sdk-3x / index.js View on Github external
// 

    // 
    const authoringEndpoint = `https://${authoringResourceName}.cognitiveservices.azure.com/`;
    const predictionEndpoint = `https://${predictionResourceName}.cognitiveservices.azure.com/`;

    const appName = "Contoso Pizza Company";
    const versionId = "0.1";
    const intentName = "OrderPizzaIntent";
    // 

    // 
    const luisAuthoringCredentials = new msRest.ApiKeyCredentials({
        inHeader: { "Ocp-Apim-Subscription-Key": authoringKey }
    });
    const client = new LUIS_Authoring.LUISAuthoringClient(
        luisAuthoringCredentials,
        authoringEndpoint
    );
    // 

    // Create app
    const appId = await createApp(client, appName, versionId);

    // 
    await client.model.addIntent(
        appId,
        versionId,
        { name: intentName }
    );
    // 
github Azure-Samples / cognitive-services-quickstart-code / javascript / LUIS / luis_authoring_quickstart.js View on Github external
throw new Error(
    "Set/export your LUIS subscription key as an environment variable."
  );
}

const endpoint = process.env["LUIS_AUTHORING_ENDPOINT"];
if (!endpoint) {
  throw new Error("Set/export your LUIS endpoint as an environment variable.");
}
// 

// 
const luisAuthoringCredentials = new msRest.ApiKeyCredentials({
  inHeader: { "Ocp-Apim-Subscription-Key": key }
});
const luisAuthoringClient = new LUIS.LUISAuthoringClient(
  luisAuthoringCredentials,
  endpoint
);
// 

// 
const delayTimer = async timeInMs => {
  return await new Promise(resolve => {
    setTimeout(resolve, timeInMs);
  });
};
// 

// 
const create_app = async () => {
  const create_app_payload = {
github Azure-Samples / cognitive-services-quickstart-code / javascript / LUIS / luis_quickstart.js View on Github external
*
 * If the environment variable is created after the application is launched in a console or with Visual
 * Studio, the shell (or Visual Studio) needs to be closed and reloaded for changes to take effect.
 */
const key = process.env['LUIS_AUTHORING_KEY'];
if (!key) {
    throw new Error('Set/export your LUIS subscription key as an environment variable.');
}

const endpoint = process.env['LUIS_AUTHORING_ENDPOINT'];
if (!endpoint) {
    throw new Error('Set/export your LUIS endpoint as an environment variable.');
}

const creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': key } });
const client = new LUIS.LUISAuthoringClient(creds, endpoint);

function create_app() {
    var d = new Date(Date.now());
    var name = "Contoso " + (d.getMonth() + 1) + "-" + d.getDate() + "-" + d.getFullYear() + " " +
        d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
    var description = "Flight booking app built with Azure SDK for Java.";
    var version = "0.1";
    var locale = "en-us";
    var create_app_payload = {
        name: name,
        description: description,
        initialVersionId: version,
        culture: locale
    };
    return client.apps.add(create_app_payload).then((result) => {
        console.log("Created LUIS app with ID " + result.body);
github Azure-Samples / cognitive-services-quickstart-code / javascript / LUIS / prediction / quickstart.js View on Github external
const authoring_endpoint = process.env[authoring_endpoint_var];

const runtime_key_var = 'LUIS_RUNTIME_KEY';
if (!process.env[runtime_key_var]) {
    throw new Error('please set/export the following environment variable: ' + runtime_key_var);
}
const runtime_key = process.env[runtime_key_var];

const runtime_endpoint_var = 'LUIS_RUNTIME_ENDPOINT';
if (!process.env[runtime_endpoint_var]) {
    throw new Error('please set/export the following environment variable: ' + runtime_endpoint_var);
}
const runtime_endpoint = process.env[runtime_endpoint_var];

const authoring_creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': authoring_key } });
const authoring_client = new authoring.LUISAuthoringClient(authoring_creds, authoring_endpoint);

const runtime_creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': runtime_key } });
const runtime_client = new runtime.LUISRuntimeClient(runtime_creds, runtime_endpoint);

function create_app() {
    var create_app_payload = {
        domainName: "HomeAutomation",
        culture: "en-us"
    };
    return authoring_client.apps.addCustomPrebuiltDomain(create_app_payload).then((result) => {
        console.log("Created LUIS app with ID " + result.body)
        let app_info = { 
            id : result.body, 
            version : "0.1" 
        }
        return app_info

@azure/cognitiveservices-luis-authoring

LUISAuthoringClient Library with typescript type definitions for node.js and browser.

MIT
Latest version published 4 years ago

Package Health Score

60 / 100
Full package analysis

Popular @azure/cognitiveservices-luis-authoring functions