Comparing version 1.2.0 to 1.2.1
@@ -1,1 +0,1 @@ | ||
{"processes":{"2aae3a1e-9816-4436-a334-2cbde4e868f5":{"parent":null,"children":["3a13bc47-fc72-4bfb-b8c1-905673de7d38","46470d9d-c207-4f18-842b-31ac11af81d1"]},"3a13bc47-fc72-4bfb-b8c1-905673de7d38":{"parent":"2aae3a1e-9816-4436-a334-2cbde4e868f5","children":[]},"46470d9d-c207-4f18-842b-31ac11af81d1":{"parent":"2aae3a1e-9816-4436-a334-2cbde4e868f5","children":[]},"808b6186-fe17-4797-a8f5-95ac2bb18c47":{"parent":null,"children":[]}},"files":{"E:\\bot-onpremise\\nlp-hub-v4\\lib\\engines\\luis\\luis.ts":["46470d9d-c207-4f18-842b-31ac11af81d1"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\engines\\engine.ts":["46470d9d-c207-4f18-842b-31ac11af81d1"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\engines\\rasa\\rasa.ts":["46470d9d-c207-4f18-842b-31ac11af81d1"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\index.ts":["46470d9d-c207-4f18-842b-31ac11af81d1"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\engines\\regex\\regex.ts":["46470d9d-c207-4f18-842b-31ac11af81d1"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\engines\\default\\default.ts":["46470d9d-c207-4f18-842b-31ac11af81d1"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\model\\app.ts":["808b6186-fe17-4797-a8f5-95ac2bb18c47"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\model\\luis-response.ts":["808b6186-fe17-4797-a8f5-95ac2bb18c47"],"E:\\bot-onpremise\\nlp-hub-v4\\lib\\model\\rasa-response.ts":["808b6186-fe17-4797-a8f5-95ac2bb18c47"]},"externalIds":{}} | ||
{"processes":{"236075b7-bcba-4063-a5e5-eab14e9b4601":{"parent":"fefb5802-0e3a-488c-b2cb-4cf7f41b2895","children":[]},"3012df70-a3be-4578-b38d-214d471934d9":{"parent":"f7deeed9-881e-4f16-97c2-c80ed9e27c4b","children":["c3fd1e3a-2823-4e53-b8d1-d115923cb409"]},"c3fd1e3a-2823-4e53-b8d1-d115923cb409":{"parent":"3012df70-a3be-4578-b38d-214d471934d9","children":[]},"d30c4030-d864-4cbd-be60-bb2e71f97569":{"parent":null,"children":[]},"f7deeed9-881e-4f16-97c2-c80ed9e27c4b":{"parent":null,"children":["3012df70-a3be-4578-b38d-214d471934d9","fefb5802-0e3a-488c-b2cb-4cf7f41b2895"]},"fefb5802-0e3a-488c-b2cb-4cf7f41b2895":{"parent":"f7deeed9-881e-4f16-97c2-c80ed9e27c4b","children":["236075b7-bcba-4063-a5e5-eab14e9b4601"]}},"files":{"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/engines/luis/luis.ts":["236075b7-bcba-4063-a5e5-eab14e9b4601"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/engines/engine.ts":["236075b7-bcba-4063-a5e5-eab14e9b4601"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/engines/rasa/rasa.ts":["236075b7-bcba-4063-a5e5-eab14e9b4601"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/index.ts":["236075b7-bcba-4063-a5e5-eab14e9b4601"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/engines/regex/regex.ts":["236075b7-bcba-4063-a5e5-eab14e9b4601"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/engines/default/default.ts":["236075b7-bcba-4063-a5e5-eab14e9b4601"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/model/app.ts":["d30c4030-d864-4cbd-be60-bb2e71f97569"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/model/luis-response.ts":["d30c4030-d864-4cbd-be60-bb2e71f97569"],"/Users/lorenzolamas/proyects/nlp-hub-v4/lib/model/rasa-response.ts":["d30c4030-d864-4cbd-be60-bb2e71f97569"]},"externalIds":{}} |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ import { EngineRecognizer } from "../engine"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRecognizerResponse } from "../model/app"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRecognizerParams, IRecognizerResponse } from '../../model/app'; |
@@ -38,4 +38,4 @@ "use strict"; | ||
}; | ||
try { | ||
request(options, (error, response, body) => { | ||
request(options, (error, response, body) => { | ||
try { | ||
if (error) { | ||
@@ -65,7 +65,7 @@ reject(error); | ||
} | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
}); | ||
@@ -72,0 +72,0 @@ }); |
@@ -0,0 +0,0 @@ import { ILuisResponse } from '../../../model/luis-response'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -21,2 +21,3 @@ import { ILuisResponse } from '../../../model/luis-response'; | ||
export declare const APP_ID_CODE_200: string; | ||
export declare const APP_ID_CODE_200_BAD: string; | ||
export declare const APP_ID_CODE_204: string; | ||
@@ -28,5 +29,8 @@ export declare const APP_ID_CODE_400: string; | ||
export declare const APP_ID_CODE_504: string; | ||
export declare const APP_ID_CODE_ERROR: string; | ||
export declare const QUERY_200: string; | ||
export declare const QUERY_200_BAD: string; | ||
export declare const QUERY_204: string; | ||
export declare const QUERY_500: string; | ||
export declare const QUERY_ERROR: string; | ||
export declare const INTENT_200: { | ||
@@ -52,5 +56,9 @@ intent: string; | ||
export declare const LUIS_URI_PARTS_200: LuisUriParts; | ||
export declare const LUIS_URI_PARTS_200_BAD: LuisUriParts; | ||
export declare const LUIS_URI_PARTS_204: LuisUriParts; | ||
export declare const LUIS_URI_PARTS_500: LuisUriParts; | ||
export declare const LUIS_URI_PARTS_ERROR: LuisUriParts; | ||
export declare const LUIS_QUERY_PARAMS_200: LuisQueryParams; | ||
export declare const LUIS_QUERY_PARAMS_200_BAD: LuisQueryParams; | ||
export declare const LUIS_QUERY_PARAMS_ERROR: LuisQueryParams; | ||
export declare const LUIS_QUERY_PARAMS_204: LuisQueryParams; | ||
@@ -70,2 +78,3 @@ export declare const LUIS_QUERY_PARAMS_500: LuisQueryParams; | ||
}; | ||
export declare const LUIS_RESPONSE_ERROR = "some error in request"; | ||
export declare const LUIS_RESPONSE_204: { | ||
@@ -72,0 +81,0 @@ query: string; |
@@ -12,2 +12,3 @@ "use strict"; | ||
exports.APP_ID_CODE_200 = 'APP_ID_200'; | ||
exports.APP_ID_CODE_200_BAD = 'APP_ID_200_BAD'; | ||
exports.APP_ID_CODE_204 = 'APP_ID_204'; | ||
@@ -19,5 +20,8 @@ exports.APP_ID_CODE_400 = 'APP_ID_400'; | ||
exports.APP_ID_CODE_504 = 'APP_ID_504'; | ||
exports.APP_ID_CODE_ERROR = 'APP_ID_ERROR'; | ||
exports.QUERY_200 = 'QUERY_200'; | ||
exports.QUERY_200_BAD = 'QUERY_200_BAD'; | ||
exports.QUERY_204 = 'QUERY_204'; | ||
exports.QUERY_500 = 'QUERY_500'; | ||
exports.QUERY_ERROR = 'QUERY_ERROR'; | ||
exports.INTENT_200 = { | ||
@@ -65,2 +69,6 @@ intent: 'INTENT.200', | ||
}; | ||
exports.LUIS_URI_PARTS_200_BAD = { | ||
host: exports.BASE_PATH, | ||
appId: exports.APP_ID_CODE_200_BAD, | ||
}; | ||
exports.LUIS_URI_PARTS_204 = { | ||
@@ -74,2 +82,6 @@ host: exports.BASE_PATH, | ||
}; | ||
exports.LUIS_URI_PARTS_ERROR = { | ||
host: exports.BASE_PATH, | ||
appId: exports.APP_ID_CODE_ERROR, | ||
}; | ||
exports.LUIS_QUERY_PARAMS_200 = { | ||
@@ -81,2 +93,14 @@ q: exports.QUERY_200, | ||
}; | ||
exports.LUIS_QUERY_PARAMS_200_BAD = { | ||
q: exports.QUERY_200_BAD, | ||
'subscription-key': exports.SUBSCRIPTION_KEY, | ||
timezoneOffset: 0, | ||
verbose: true, | ||
}; | ||
exports.LUIS_QUERY_PARAMS_ERROR = { | ||
q: exports.QUERY_ERROR, | ||
'subscription-key': exports.SUBSCRIPTION_KEY, | ||
timezoneOffset: 0, | ||
verbose: true, | ||
}; | ||
exports.LUIS_QUERY_PARAMS_204 = { | ||
@@ -100,2 +124,3 @@ q: exports.QUERY_200, | ||
}; | ||
exports.LUIS_RESPONSE_ERROR = 'some error in request'; | ||
exports.LUIS_RESPONSE_204 = { | ||
@@ -102,0 +127,0 @@ query: exports.QUERY_200, |
@@ -1,2 +0,3 @@ | ||
declare const luisMock: (basePath: string) => void; | ||
import nock = require('nock'); | ||
declare const luisMock: (basePath: string) => nock.Scope; | ||
export default luisMock; |
@@ -14,11 +14,17 @@ "use strict"; | ||
function AddGetReplyToNock(nock, nockGetParams) { | ||
if (nockGetParams.queryParams !== undefined) { | ||
if (nockGetParams.replyWithError) { | ||
return nock.get(nockGetParams.uri) | ||
.query(true) | ||
// .query(nockGetParams.queryParams) | ||
.reply(nockGetParams.code, nockGetParams.body); | ||
.replyWithError(nockGetParams.replyWithError); | ||
} | ||
else { | ||
return nock.get(nockGetParams.uri) | ||
.reply(nockGetParams.code, nockGetParams.body); | ||
if (nockGetParams.queryParams !== undefined) { | ||
return nock.get(nockGetParams.uri) | ||
.query(true) | ||
.reply(nockGetParams.code, nockGetParams.body); | ||
} | ||
else { | ||
return nock.get(nockGetParams.uri) | ||
.reply(nockGetParams.code, nockGetParams.body); | ||
} | ||
} | ||
@@ -38,2 +44,15 @@ } | ||
{ | ||
uri: luisQueryUrl(Constants.LUIS_URI_PARTS_200_BAD), | ||
queryParams: Constants.LUIS_QUERY_PARAMS_200_BAD, | ||
code: 200, | ||
body: {}, | ||
headers: undefined | ||
}, | ||
{ | ||
uri: luisQueryUrl(Constants.LUIS_URI_PARTS_ERROR), | ||
queryParams: Constants.LUIS_QUERY_PARAMS_ERROR, | ||
replyWithError: Constants.LUIS_RESPONSE_ERROR, | ||
headers: undefined | ||
}, | ||
{ | ||
uri: luisQueryUrl(Constants.LUIS_URI_PARTS_204), | ||
@@ -55,7 +74,5 @@ queryParams: Constants.LUIS_QUERY_PARAMS_204, | ||
var cases = luisCases; | ||
cases.reduce((scope, current) => AddGetReplyToNock(scope, current), nock(basePath)); | ||
/*for (let mockUrl of nock.pendingMocks()) { | ||
console.error('url: %j', mockUrl); | ||
}*/ | ||
const luisMockOut = cases.reduce((scope, current) => AddGetReplyToNock(scope, current), nock(basePath)); | ||
return luisMockOut; | ||
}; | ||
exports.default = luisMock; |
export {}; |
@@ -41,2 +41,19 @@ "use strict"; | ||
}); | ||
it('request LUIS with utterace with result in request error', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const app = { | ||
id: 'ID', | ||
type: 'luis', | ||
params: { | ||
key: Constants.SUBSCRIPTION_KEY, | ||
appHost: Constants.BASE_PATH, | ||
appId: Constants.APP_ID_CODE_ERROR | ||
} | ||
}; | ||
const sut = new luis_1.LuisRecognizer(app); | ||
const result = yield sut.recognice(Constants.QUERY_ERROR).catch((error) => { | ||
chai_1.expect(error).to.be.instanceOf(Error); | ||
chai_1.expect(error.message).to.be.equal('some error in request'); | ||
}); | ||
chai_1.expect(result).to.be.undefined; | ||
})); | ||
it('request LUIS with utterace with result code 200', function () { | ||
@@ -63,2 +80,21 @@ return __awaiter(this, void 0, void 0, function* () { | ||
}); | ||
it('request LUIS with utterace with bad result code 200', function () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const app = { | ||
id: 'ID', | ||
type: 'luis', | ||
params: { | ||
key: Constants.SUBSCRIPTION_KEY, | ||
appHost: Constants.BASE_PATH, | ||
appId: Constants.APP_ID_CODE_200_BAD | ||
} | ||
}; | ||
const sut = new luis_1.LuisRecognizer(app); | ||
const result = yield sut.recognice(Constants.QUERY_200_BAD).catch((error) => { | ||
chai_1.expect(error).to.be.instanceof(Error); | ||
chai_1.expect(error.message).to.be.equal('Cannot read property \'intent\' of undefined'); | ||
}); | ||
chai_1.expect(result).to.be.undefined; | ||
}); | ||
}); | ||
it('request LUIS with utterace with result code 204', function () { | ||
@@ -104,9 +140,4 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
// expect(result.intent).is.deep.equal({ | ||
// name: "INTENT.204", | ||
// score: 0.2 | ||
// }); | ||
// expect(result.entities.length).is.equal(0); | ||
}); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ import { IRecognizerParams, IRecognizerResponse } from '../../model/app'; |
@@ -39,4 +39,4 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
try { | ||
request(options, (error, response, body) => { | ||
request(options, (error, response, body) => { | ||
try { | ||
if (error) { | ||
@@ -47,6 +47,5 @@ reject(error); | ||
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { | ||
// const bodyObject = JSON.parse(body); | ||
const intent = { | ||
name: body.intent.name, | ||
score: body.intent.score, | ||
score: body.intent.confidence, | ||
}; | ||
@@ -70,10 +69,10 @@ const myResponse = { | ||
else { | ||
reject(new Error(JSON.stringify({ response, body: body }))); | ||
reject(new Error(JSON.stringify({ response, body }))); | ||
} | ||
} | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
}); | ||
@@ -80,0 +79,0 @@ }); |
@@ -0,1 +1,2 @@ | ||
import { IRecognizerResponse } from "../../../model/app"; | ||
export interface RasaUriParts { | ||
@@ -6,3 +7,6 @@ host: string; | ||
export declare const QUERY_200: string; | ||
export declare const QUERY_200_BAD: string; | ||
export declare const QUERY_204: string; | ||
export declare const QUERY_400: string; | ||
export declare const QUERY_Error: string; | ||
export declare const RASA_RESPONSE_204: { | ||
@@ -24,3 +28,8 @@ proyect: string; | ||
model: string; | ||
entities: never[]; | ||
entities: { | ||
confidence: number; | ||
entity: string; | ||
value: string; | ||
}[]; | ||
}; | ||
export declare const RASA_EXPECTED_200_RECOGNIZER_RESULT: IRecognizerResponse; |
@@ -6,3 +6,6 @@ "use strict"; | ||
exports.QUERY_200 = 'QUERY_200'; | ||
exports.QUERY_200_BAD = 'QUERY_200_BAD'; | ||
exports.QUERY_204 = 'asd'; | ||
exports.QUERY_400 = 'QUERY_400'; | ||
exports.QUERY_Error = 'some-error'; | ||
exports.RASA_RESPONSE_204 = { | ||
@@ -24,3 +27,34 @@ proyect: 'mock', | ||
model: 'model1232', | ||
entities: [] | ||
entities: [{ | ||
confidence: 0.82, | ||
entity: 'entity', | ||
value: 'some entitie', | ||
}] | ||
}; | ||
exports.RASA_EXPECTED_200_RECOGNIZER_RESULT = { | ||
id: 'ID', | ||
engine: 'rasa', | ||
entities: [{ | ||
score: 0.82, | ||
type: 'entity', | ||
value: 'some entitie', | ||
} | ||
], | ||
intent: { | ||
name: 'intent1', | ||
score: 0.3 | ||
}, | ||
originalResponse: { | ||
proyect: 'mock', | ||
intent: { | ||
name: 'intent1', | ||
confidence: 0.3 | ||
}, | ||
model: 'model1232', | ||
entities: [{ | ||
confidence: 0.82, | ||
entity: 'entity', | ||
value: 'some entitie' | ||
}] | ||
} | ||
}; |
@@ -1,2 +0,3 @@ | ||
declare const rasaMock: (basePath: string) => void; | ||
import nock = require('nock'); | ||
declare const rasaMock: (basePath: string) => nock.Scope; | ||
export default rasaMock; |
@@ -11,7 +11,12 @@ "use strict"; | ||
const nock = require("nock"); | ||
//const querystring = require('querystring'); | ||
const Constants = __importStar(require("./rasa.constants.spec")); | ||
function AddPostReplyToNock(nock, nockPostParams) { | ||
return nock.post(nockPostParams.uri, nockPostParams.requestBody) | ||
.reply(nockPostParams.code, nockPostParams.body); | ||
if (nockPostParams.replyWithError) { | ||
return nock.post(nockPostParams.uri, nockPostParams.requestBody) | ||
.replyWithError(nockPostParams.replyWithError); | ||
} | ||
else { | ||
return nock.post(nockPostParams.uri, nockPostParams.requestBody) | ||
.reply(nockPostParams.code, nockPostParams.body); | ||
} | ||
} | ||
@@ -32,2 +37,22 @@ var rasaCases = [ | ||
body: Constants.RASA_RESPONSE_204, | ||
}, | ||
{ | ||
uri: '/parse', | ||
requestBody: { q: Constants.QUERY_400 }, | ||
code: 400, | ||
headers: undefined, | ||
body: [], | ||
}, | ||
{ | ||
uri: '/parse', | ||
requestBody: { q: Constants.QUERY_200_BAD }, | ||
code: 200, | ||
headers: undefined, | ||
body: {} | ||
}, | ||
{ | ||
uri: '/parse', | ||
requestBody: { q: Constants.QUERY_Error }, | ||
code: 500, | ||
replyWithError: "some error in request" | ||
} | ||
@@ -37,7 +62,7 @@ ]; | ||
var cases = rasaCases; | ||
cases.reduce((scope, current) => AddPostReplyToNock(scope, current), nock(basePath)); | ||
// for (let mockUrl of nock.pendingMocks()) { | ||
// console.error('url: %j', mockUrl); | ||
// } | ||
const rasaMockOut = cases.reduce((scope, current) => { | ||
return AddPostReplyToNock(scope, current); | ||
}, nock(basePath)); | ||
return rasaMockOut; | ||
}; | ||
exports.default = rasaMock; |
export {}; |
@@ -39,3 +39,3 @@ "use strict"; | ||
}); | ||
it('request RASA with utterace with result code 200', () => __awaiter(void 0, void 0, void 0, function* () { | ||
it('request RASA with utterace with result in request error', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const app = { | ||
@@ -49,5 +49,50 @@ id: 'ID', | ||
const sut = new rasa_1.RasaRecognizer(app); | ||
const result = yield sut.recognice(Constants.QUERY_Error).catch((error) => { | ||
chai_1.expect(error).to.be.instanceOf(Error); | ||
chai_1.expect(error.message).to.be.equal('some error in request'); | ||
}); | ||
chai_1.expect(result).to.be.undefined; | ||
})); | ||
it('request RASA with utterace with result code 200', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const app = { | ||
id: 'ID', | ||
type: 'rasa', | ||
params: { | ||
appHost: Constants.BASE_PATH | ||
} | ||
}; | ||
const sut = new rasa_1.RasaRecognizer(app); | ||
const result = yield sut.recognice(Constants.QUERY_200); | ||
chai_1.expect(result).to.be.equal(result); | ||
chai_1.expect(result).to.be.deep.equal(Constants.RASA_EXPECTED_200_RECOGNIZER_RESULT); | ||
})); | ||
it('request RASA with utterace with result code 200 bad response', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const app = { | ||
id: 'ID', | ||
type: 'rasa', | ||
params: { | ||
appHost: Constants.BASE_PATH | ||
} | ||
}; | ||
const sut = new rasa_1.RasaRecognizer(app); | ||
const result = yield sut.recognice(Constants.QUERY_200_BAD).catch((error) => { | ||
chai_1.expect(error).to.be.instanceof(Error); | ||
chai_1.expect(error.message).to.be.equal('Cannot read property \'name\' of undefined'); | ||
}); | ||
chai_1.expect(result).to.be.undefined; | ||
})); | ||
it('request RASA with utterance tith result code 400', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const app = { | ||
id: 'ID', | ||
type: 'rasa', | ||
params: { | ||
appHost: Constants.BASE_PATH | ||
} | ||
}; | ||
const sut = new rasa_1.RasaRecognizer(app); | ||
const result = yield sut.recognice(Constants.QUERY_400).catch((error) => { | ||
chai_1.expect(error).to.be.instanceOf(Error); | ||
chai_1.expect(error.message).to.be.equal('{"response":{"statusCode":400,"body":[],"headers":{"content-type":"application/json"},"request":{"uri":{"protocol":"http:","slashes":true,"auth":null,"host":"rasa_host","port":80,"hostname":"rasa_host","hash":null,"search":null,"query":null,"pathname":"/parse","path":"/parse","href":"http://rasa_host/parse"},"method":"POST","headers":{"Content-Type":"application/json","accept":"application/json","content-length":17}}},"body":[]}'); | ||
}); | ||
chai_1.expect(result).to.be.undefined; | ||
})); | ||
}); |
@@ -0,0 +0,0 @@ import { IRecognizerParams, IRecognizerResponse } from '../../model/app'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRecognizerParams } from './model/app'; |
@@ -37,2 +37,3 @@ "use strict"; | ||
for (const recognizer of this.recognizers) { | ||
//TODO: Se puede catchear el error y asignarlo a recognizerResult | ||
const recognizerResult = yield recognizer.recognice(utterance); | ||
@@ -39,0 +40,0 @@ if (this.isAcceptable(recognizerResult)) { |
export {}; |
@@ -32,3 +32,3 @@ "use strict"; | ||
const configuration = { | ||
threshold: 0.8, | ||
threshold: 0.83, | ||
recognizers: [ | ||
@@ -80,7 +80,22 @@ { | ||
}); | ||
it('can be constructed with empy configuration', () => { | ||
const configurationEmpy = {}; | ||
const sut = new index_1.NlpHub(configurationEmpy); | ||
chai_1.expect(sut).to.be.instanceof(index_1.NlpHub); | ||
}); | ||
it('can be set defalut threshold with empy configuration', () => { | ||
const configurationEmpy = {}; | ||
const sut = new index_1.NlpHub(configurationEmpy); | ||
chai_1.expect(sut.threshold).to.be.equal(0.8); | ||
}); | ||
it('can be set defalut recognizers with empy configuration', () => { | ||
const configurationEmpy = {}; | ||
const sut = new index_1.NlpHub(configurationEmpy); | ||
chai_1.expect(sut.recognizers).to.be.deep.equal([]); | ||
}); | ||
it('can be set threshold', () => { | ||
const sut = new index_1.NlpHub(configuration); | ||
chai_1.expect(sut.threshold).to.be.equals(0.8); | ||
chai_1.expect(sut.threshold).to.be.equals(0.83); | ||
}); | ||
it('can be set apps', () => { | ||
it('can be set recognizers', () => { | ||
const sut = new index_1.NlpHub(configuration); | ||
@@ -87,0 +102,0 @@ chai_1.expect(sut.recognizers[0]._id).to.be.equals('HolaRegex'); |
@@ -0,0 +0,0 @@ export interface IRecognizerParams { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export interface ILuisResponse { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export interface IRasaResponse { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "nlp-hub-v4", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "The hub for natural language processing (nlp) engines. Fork (https://github.com/marcelofelman/nlp-hub.git)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
## NLP-Hub | ||
[![Build Status](https://travis-ci.org/lorenzojlamas/nlp-hub-v4.svg?branch=master)](https://travis-ci.org/lorenzojlamas/nlp-hub-v4) | ||
[![NPM](https://badgen.net/npm/v/nlp-hub-v4)](https://www.npmjs.com/package/nlp-hub-v4) | ||
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=lorenzojlamas_nlp-hub-v4&metric=coverage)](https://sonarcloud.io/dashboard?id=lorenzojlamas_nlp-hub-v4) | ||
Migration to bot framwork v4 (WIP) | ||
This is a library to connect different recognizers to a bot, currently supports: | ||
- Regex | ||
- Luis | ||
- Rasa | ||
By now, the only strategy supported is that of firsMatch, it goes through the configured recognizers and when the first one passes a certain threshold it returns the common data structure of the response. You must configure a default response as detailed in the example. This library is an open source and anyone who wants to participate will be welcome. | ||
Example conf | ||
``` | ||
{ | ||
"threshold": "0.8", | ||
"apps": [ | ||
{ "id": "HolaRegex", "intent": "greetings", "exp": "(^hola$|^holaa$|^holas$|^holi$|^holis$|^hi$|^hello$)", "type": "regex" }, | ||
{ "id": "recommender", "intent": "recommender", "exp": "^Comprar vuelo$", "type": "regex" }, | ||
{ "type": "luis", "appId": "APP_ID_204", "key": "SUBS_KEY", "appHost": "http://westus.api.cognitive.microsoft.com" }, | ||
{ "type": "rasa", "appHost": "http://localhost:5000" } | ||
Use example: | ||
```Typescript | ||
const configuration: INlpHubConfiguration = { | ||
threshold: 0.83, | ||
recognizers: [ | ||
{ | ||
id: "HolaRegex", | ||
type: "regex", | ||
params: { | ||
intent: "greetings", | ||
exp: "(^hola$|^holaa$|^holas$|^holi$|^holis$|^hi$|^hello$)" | ||
} | ||
}, | ||
{ | ||
id: "recommender", | ||
type: "regex" , | ||
params: { | ||
intent: "recommender", | ||
exp: "^Comprar vuelo$" | ||
} | ||
}, | ||
{ | ||
id: "Luis-1", | ||
type: "luis", | ||
params: { | ||
"appId": "APP_ID", | ||
"key": "SUBS_KEY", | ||
"appHost": "http://westus.api.cognitive.microsoft.com" } | ||
}, | ||
{ | ||
id: "Rasa-1", | ||
type: "rasa", | ||
params: { | ||
appHost: "http://RASA_HOST" | ||
} | ||
}, | ||
{ | ||
id: "default-1", | ||
type:"default" , | ||
params: { | ||
intent: "NoneDialog" | ||
} | ||
} | ||
] | ||
} | ||
}; | ||
const nlpHub: NlpHub = new NlpHub(configuration); | ||
const utterance: string = 'Hola'; | ||
const response: any = await nlpHub.firstMatch(utterance); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
225403
79
1934
62
0