2.1.1 • Published 7 years ago

cognitive-luis-client v2.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Installation

npm install --save cognitive-luis-client

Usage

TypeScript

import { LuisClient } from 'cognitive-luis-client';

// Use with default region (westus)
const client = new LuisClient('appId', 'key');

client.recognize('utterance', (err: Error, result: LuisResult) => {
  if (err) throw err;
  console.log(result.intents, result.entities);
});
// Use with custom region
const client = new LuisClient('appId', 'key', 'region');

JavaScript

const clc = require('cognitive-luis-client');
 
const client = new clc.LuisClient('appId', 'key');
client.recognize('utterance', (err, result) => {
  if (err) throw err;
  console.log(result.intents, result.entities);
});

Test Suite

Use MockLuisService to mock a response for any code that relies on LuisClient without making an actual API call.

import { MockLuisService, LuisClient } from 'cognitive-luis-client';
 
// Use with default region
new MockLuisService('fake-app-id')
  .recognize(200, 'my test utterance', {intents:[{intent:'foo', score:1}], entities:[]});

const client = new LuisClient('fake-app-id', 'any fake key');
client.recognize('my test utterance', (err: Error, result: LuisResult) => {
  if (err) throw err;
  expect(result.intents[0].intent).toBe('foo');
  expect(result.intents[0].score).toBe(1);
});
// Use with custom region
new MockLuisService('fake-app-id', 'region')
  .recognize(200, 'my test utterance', {/* result */});

const client = new LuisClient('fake-app-id', 'any fake key', 'region');
2.1.1

7 years ago

2.0.12

7 years ago

2.0.11

7 years ago

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago