New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

botbuilder

Package Overview
Dependencies
Maintainers
1
Versions
633
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botbuilder - npm Package Compare versions

Comparing version 3.8.0-beta6 to 3.8.0-beta7

lib/dialogs/IntentRecognizer.js

4

lib/botbuilder.js

@@ -56,2 +56,4 @@ "use strict";

exports.PromptTime = PromptTime_1.PromptTime;
var IntentRecognizer_1 = require("./dialogs/IntentRecognizer");
exports.IntentRecognizer = IntentRecognizer_1.IntentRecognizer;
var IntentRecognizerSet_1 = require("./dialogs/IntentRecognizerSet");

@@ -73,2 +75,4 @@ exports.IntentRecognizerSet = IntentRecognizerSet_1.IntentRecognizerSet;

exports.SimpleDialog = SimpleDialog_1.SimpleDialog;
var WaterfallDialog_1 = require("./dialogs/WaterfallDialog");
exports.WaterfallDialog = WaterfallDialog_1.WaterfallDialog;
var EntityRecognizer_1 = require("./dialogs/EntityRecognizer");

@@ -75,0 +79,0 @@ exports.EntityRecognizer = EntityRecognizer_1.EntityRecognizer;

14

lib/bots/ChatConnector.js

@@ -366,9 +366,11 @@ "use strict";

ChatConnector.prototype.onDispatchEvents = function (events, callback) {
if (this.isInvoke(events[0])) {
this.onInvokeHandler(events[0], callback);
if (events && events.length > 0) {
if (this.isInvoke(events[0])) {
this.onInvokeHandler(events[0], callback);
}
else {
this.onEventHandler(events);
callback(null, null, 202);
}
}
else {
this.onEventHandler(events);
callback(null, null, 202);
}
};

@@ -375,0 +377,0 @@ ChatConnector.prototype.dispatch = function (msg, res) {

@@ -7,3 +7,3 @@ "use strict";

};
var SimpleDialog_1 = require("../dialogs/SimpleDialog");
var WaterfallDialog_1 = require("../dialogs/WaterfallDialog");
var ActionSet_1 = require("../dialogs/ActionSet");

@@ -381,8 +381,5 @@ var IntentRecognizerSet_1 = require("../dialogs/IntentRecognizerSet");

}
if (Array.isArray(dialog)) {
d = new SimpleDialog_1.SimpleDialog(SimpleDialog_1.createWaterfall(dialog));
if (Array.isArray(dialog) || typeof dialog === 'function') {
d = new WaterfallDialog_1.WaterfallDialog(dialog);
}
else if (typeof dialog == 'function') {
d = new SimpleDialog_1.SimpleDialog(SimpleDialog_1.createWaterfall([dialog]));
}
else {

@@ -389,0 +386,0 @@ d = dialog;

@@ -7,3 +7,3 @@ "use strict";

};
var SimpleDialog_1 = require("./SimpleDialog");
var WaterfallDialog_1 = require("./WaterfallDialog");
var DialogAction_1 = require("./DialogAction");

@@ -113,3 +113,3 @@ var Dialog_1 = require("./Dialog");

if (Array.isArray(dialogId)) {
this.handlers[id] = SimpleDialog_1.createWaterfall(dialogId);
this.handlers[id] = WaterfallDialog_1.WaterfallDialog.createHandler(dialogId);
}

@@ -120,3 +120,3 @@ else if (typeof dialogId === 'string') {

else {
this.handlers[id] = SimpleDialog_1.createWaterfall([dialogId]);
this.handlers[id] = WaterfallDialog_1.WaterfallDialog.createHandler([dialogId]);
}

@@ -133,3 +133,3 @@ return this;

if (Array.isArray(dialogId)) {
this.handlers[consts.Intents.Default] = SimpleDialog_1.createWaterfall(dialogId);
this.handlers[consts.Intents.Default] = WaterfallDialog_1.WaterfallDialog.createHandler(dialogId);
}

@@ -140,3 +140,3 @@ else if (typeof dialogId === 'string') {

else {
this.handlers[consts.Intents.Default] = SimpleDialog_1.createWaterfall([dialogId]);
this.handlers[consts.Intents.Default] = WaterfallDialog_1.WaterfallDialog.createHandler([dialogId]);
}

@@ -143,0 +143,0 @@ return this;

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var IntentRecognizer_1 = require("./IntentRecognizer");
var utils = require("../utils");

@@ -9,22 +15,25 @@ var async = require("async");

})(RecognizeOrder = exports.RecognizeOrder || (exports.RecognizeOrder = {}));
var IntentRecognizerSet = (function () {
var IntentRecognizerSet = (function (_super) {
__extends(IntentRecognizerSet, _super);
function IntentRecognizerSet(options) {
if (options === void 0) { options = {}; }
this.options = options;
if (typeof this.options.intentThreshold !== 'number') {
this.options.intentThreshold = 0.1;
var _this = _super.call(this) || this;
_this.options = options;
if (typeof _this.options.intentThreshold !== 'number') {
_this.options.intentThreshold = 0.1;
}
if (!this.options.hasOwnProperty('recognizeOrder')) {
this.options.recognizeOrder = RecognizeOrder.parallel;
if (!_this.options.hasOwnProperty('recognizeOrder')) {
_this.options.recognizeOrder = RecognizeOrder.parallel;
}
if (!this.options.recognizers) {
this.options.recognizers = [];
if (!_this.options.recognizers) {
_this.options.recognizers = [];
}
if (!this.options.processLimit) {
this.options.processLimit = 4;
if (!_this.options.processLimit) {
_this.options.processLimit = 4;
}
if (!this.options.hasOwnProperty('stopIfExactMatch')) {
this.options.stopIfExactMatch = true;
if (!_this.options.hasOwnProperty('stopIfExactMatch')) {
_this.options.stopIfExactMatch = true;
}
this.length = this.options.recognizers.length;
_this.length = _this.options.recognizers.length;
return _this;
}

@@ -36,3 +45,3 @@ IntentRecognizerSet.prototype.clone = function (copyTo) {

};
IntentRecognizerSet.prototype.recognize = function (context, done) {
IntentRecognizerSet.prototype.onRecognize = function (context, done) {
if (this.options.recognizeOrder == RecognizeOrder.parallel) {

@@ -104,3 +113,3 @@ this.recognizeInParallel(context, done);

return IntentRecognizerSet;
}());
}(IntentRecognizer_1.IntentRecognizer));
exports.IntentRecognizerSet = IntentRecognizerSet;
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var IntentRecognizer_1 = require("./IntentRecognizer");
var RegExpRecognizer_1 = require("./RegExpRecognizer");
var LocalizedRegExpRecognizer = (function () {
var LocalizedRegExpRecognizer = (function (_super) {
__extends(LocalizedRegExpRecognizer, _super);
function LocalizedRegExpRecognizer(intent, key, namespace) {
this.intent = intent;
this.key = key;
this.namespace = namespace;
this.recognizers = {};
var _this = _super.call(this) || this;
_this.intent = intent;
_this.key = key;
_this.namespace = namespace;
_this.recognizers = {};
return _this;
}
LocalizedRegExpRecognizer.prototype.recognize = function (context, callback) {
LocalizedRegExpRecognizer.prototype.onRecognize = function (context, callback) {
var locale = context.preferredLocale();

@@ -28,3 +37,3 @@ var recognizer = this.recognizers[locale];

return LocalizedRegExpRecognizer;
}());
}(IntentRecognizer_1.IntentRecognizer));
exports.LocalizedRegExpRecognizer = LocalizedRegExpRecognizer;
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var IntentRecognizer_1 = require("./IntentRecognizer");
var request = require("request");
var LuisRecognizer = (function () {
var url = require("url");
var LuisRecognizer = (function (_super) {
__extends(LuisRecognizer, _super);
function LuisRecognizer(models) {
var _this = _super.call(this) || this;
if (typeof models == 'string') {
this.models = { '*': models };
_this.models = { '*': models };
}
else {
this.models = (models || {});
_this.models = (models || {});
}
return _this;
}
LuisRecognizer.prototype.recognize = function (context, cb) {
LuisRecognizer.prototype.onRecognize = function (context, callback) {
var result = { score: 0.0, intent: null };

@@ -44,6 +54,6 @@ if (context && context.message && context.message.text) {

}
cb(null, result);
callback(null, result);
}
else {
cb(err, null);
callback(err, null);
}

@@ -53,7 +63,7 @@ });

else {
cb(new Error("LUIS model not found for locale '" + locale + "'."), null);
callback(new Error("LUIS model not found for locale '" + locale + "'."), null);
}
}
else {
cb(null, result);
callback(null, result);
}

@@ -63,8 +73,11 @@ };

try {
var uri = modelUrl.trim();
if (uri.lastIndexOf('&q=') != uri.length - 3) {
uri += '&q=';
var uri = url.parse(modelUrl, true);
uri.query['q'] = utterance || '';
if (uri.search) {
delete uri.search;
}
uri += encodeURIComponent(utterance || '');
request.get(uri, function (err, res, body) {
if (!Object.prototype.hasOwnProperty.call(uri.query, 'allowSampling')) {
uri.query['allowSampling'] = 'true';
}
request.get(url.format(uri), function (err, res, body) {
var result;

@@ -106,3 +119,3 @@ try {

return LuisRecognizer;
}());
}(IntentRecognizer_1.IntentRecognizer));
exports.LuisRecognizer = LuisRecognizer;

@@ -7,3 +7,3 @@ "use strict";

};
var SimpleDialog_1 = require("./SimpleDialog");
var WaterfallDialog_1 = require("./WaterfallDialog");
var DialogAction_1 = require("./DialogAction");

@@ -283,3 +283,3 @@ var Dialog_1 = require("./Dialog");

if (Array.isArray(dialogId)) {
this.handlers[id] = SimpleDialog_1.createWaterfall(dialogId);
this.handlers[id] = WaterfallDialog_1.WaterfallDialog.createHandler(dialogId);
}

@@ -290,3 +290,3 @@ else if (typeof dialogId === 'string') {

else {
this.handlers[id] = SimpleDialog_1.createWaterfall([dialogId]);
this.handlers[id] = WaterfallDialog_1.WaterfallDialog.createHandler([dialogId]);
}

@@ -293,0 +293,0 @@ return this;

"use strict";
var RegExpRecognizer = (function () {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var IntentRecognizer_1 = require("./IntentRecognizer");
var RegExpRecognizer = (function (_super) {
__extends(RegExpRecognizer, _super);
function RegExpRecognizer(intent, expressions) {
this.intent = intent;
var _this = _super.call(this) || this;
_this.intent = intent;
if (expressions instanceof RegExp || typeof expressions.exec === 'function') {
this.expressions = { '*': expressions };
_this.expressions = { '*': expressions };
}
else {
this.expressions = (expressions || {});
_this.expressions = (expressions || {});
}
return _this;
}
RegExpRecognizer.prototype.recognize = function (context, cb) {
RegExpRecognizer.prototype.onRecognize = function (context, cb) {
var result = { score: 0.0, intent: null };

@@ -38,3 +47,3 @@ if (context && context.message && context.message.text) {

return RegExpRecognizer;
}());
}(IntentRecognizer_1.IntentRecognizer));
exports.RegExpRecognizer = RegExpRecognizer;

@@ -8,3 +8,2 @@ "use strict";

var Dialog_1 = require("./Dialog");
var consts = require("../consts");
var SimpleDialog = (function (_super) {

@@ -29,52 +28,1 @@ __extends(SimpleDialog, _super);

exports.SimpleDialog = SimpleDialog;
function createWaterfall(steps) {
return function waterfallAction(s, r) {
var skip = function (result) {
result = result || {};
if (result.resumed == null) {
result.resumed = Dialog_1.ResumeReason.forward;
}
waterfallAction(s, result);
};
if (r && r.hasOwnProperty('resumed')) {
if (r.resumed !== Dialog_1.ResumeReason.reprompt) {
var step = s.dialogData[consts.Data.WaterfallStep];
switch (r.resumed) {
case Dialog_1.ResumeReason.back:
step -= 1;
break;
default:
step++;
}
if (step >= 0 && step < steps.length) {
try {
s.logger.log(s.dialogStack(), 'waterfall() step ' + step + 1 + ' of ' + steps.length);
s.dialogData[consts.Data.WaterfallStep] = step;
steps[step](s, r, skip);
}
catch (e) {
s.error(e);
}
}
else {
s.endDialogWithResult(r);
}
}
}
else if (steps && steps.length > 0) {
try {
s.logger.log(s.dialogStack(), 'waterfall() step 1 of ' + steps.length);
s.dialogData[consts.Data.WaterfallStep] = 0;
steps[0](s, r, skip);
}
catch (e) {
s.error(e);
}
}
else {
s.logger.warn(s.dialogStack(), 'waterfall() empty waterfall detected');
s.endDialogWithResult({ resumed: Dialog_1.ResumeReason.notCompleted });
}
};
}
exports.createWaterfall = createWaterfall;

@@ -5,3 +5,3 @@ {

"description": "Bot Builder is a dialog system for building rich bots on virtually any platform.",
"version": "3.8.0-beta6",
"version": "3.8.0-beta7",
"license": "MIT",

@@ -8,0 +8,0 @@ "keywords": [

@@ -62,2 +62,2 @@ # Bot Builder for Node.js

* [Core Concepts Guide](http://docs.botframework.com/builder/node/guides/core-concepts/)
* [Bot Builder for Node.js Reference](http://docs.botframework.com/sdkreference/nodejs/modules/_botbuilder_d_.html)
* [Bot Builder for Node.js Reference](https://docs.botframework.com/en-us/node/builder/chat-reference/modules/_botbuilder_d_.html)

@@ -170,12 +170,14 @@ var assert = require('assert');

bot.on('send', function (message) {
switch (message.text) {
case 'ChooseFood':
connector.processMessage("goodbye");
break;
case 'goodbye':
done();
break;
default:
assert(false);
break;
if (message.text) {
switch (message.text) {
case 'ChooseFood':
connector.processMessage("goodbye");
break;
case 'goodbye':
done();
break;
default:
assert(false);
break;
}
}

@@ -182,0 +184,0 @@ });

@@ -334,12 +334,14 @@ var assert = require('assert');

bot.on('send', function (message) {
switch (message.text) {
case 'index-en1':
connector.processMessage('goodbye');
break;
case 'index-en2':
done();
break;
default:
assert(false);
break;
if (message.text) {
switch (message.text) {
case 'index-en1':
connector.processMessage('goodbye');
break;
case 'index-en2':
done();
break;
default:
assert(false);
break;
}
}

@@ -346,0 +348,0 @@ });

@@ -70,3 +70,3 @@ var assert = require('assert');

it('should enable/disable a RecognizerFilter', function (done) {
it('should enable/disable a recognizer', function (done) {
var step = 0;

@@ -77,3 +77,3 @@ var connector = new builder.ConsoleConnector();

});
var recognizer = new builder.RecognizerFilter(new builder.RegExpRecognizer('HelpIntent', /^help/i))
var recognizer = new builder.RegExpRecognizer('HelpIntent', /^help/i)
.onEnabled(function (context, callback) {

@@ -100,3 +100,3 @@ callback(null, step === 0);

it('should filter the output using a RecognizerFilter', function (done) {
it('should filter the output of a recognizer', function (done) {
var step = 0;

@@ -107,4 +107,4 @@ var connector = new builder.ConsoleConnector();

});
var recognizer = new builder.RecognizerFilter(new builder.RegExpRecognizer('HelpIntent', /^help/i))
.onRecognized(function (context, result, callback) {
var recognizer = new builder.RegExpRecognizer('HelpIntent', /^help/i)
.onFilter(function (context, result, callback) {
callback(null, step === 0 ? result : { score: 0.0, intent: null });

@@ -111,0 +111,0 @@ });

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc