botbuilder-wit
Advanced tools
Comparing version 1.1.2 to 1.1.3
"use strict"; | ||
var CacheAdapter = (function () { | ||
function CacheAdapter() { | ||
function CacheAdapter(expire) { | ||
this.expire = expire; | ||
} | ||
@@ -5,0 +6,0 @@ return CacheAdapter; |
@@ -11,3 +11,3 @@ "use strict"; | ||
function MemcachedAdapter(memcachedClient, expire) { | ||
var _this = _super.call(this) || this; | ||
var _this = _super.call(this, expire) || this; | ||
_this.memcachedClient = memcachedClient; | ||
@@ -23,2 +23,6 @@ _this.expire = expire; | ||
}; | ||
MemcachedAdapter.prototype.touch = function (key, callback) { | ||
this.memcachedClient.touch(key, this.expire, callback); | ||
}; | ||
; | ||
return MemcachedAdapter; | ||
@@ -25,0 +29,0 @@ }(CacheAdapter_1.default)); |
@@ -11,3 +11,3 @@ "use strict"; | ||
function RedisAdapter(redisClient, expire) { | ||
var _this = _super.call(this) || this; | ||
var _this = _super.call(this, expire) || this; | ||
_this.redisClient = redisClient; | ||
@@ -23,2 +23,6 @@ _this.expire = expire; | ||
}; | ||
RedisAdapter.prototype.touch = function (key, callback) { | ||
this.redisClient.expire(key, this.expire, callback); | ||
}; | ||
; | ||
return RedisAdapter; | ||
@@ -25,0 +29,0 @@ }(CacheAdapter_1.default)); |
@@ -20,3 +20,3 @@ "use strict"; | ||
CacheClients[CacheClients["Memcached"] = 2] = "Memcached"; | ||
})(CacheClients || (CacheClients = {})); | ||
})(CacheClients = exports.CacheClients || (exports.CacheClients = {})); | ||
var WitRecognizer = (function () { | ||
@@ -121,6 +121,6 @@ function WitRecognizer(accessToken, options) { | ||
return function (utterance) { | ||
var hash = crypto.createHash('sha256'); | ||
hash.update(utterance); | ||
var key = hash.digest('hex'); | ||
return new Promise(function (resolve, reject) { | ||
var hash = crypto.createHash('sha256'); | ||
hash.update(utterance); | ||
var key = hash.digest('hex'); | ||
_this.cacheAdapter.get(key, function (error, result) { | ||
@@ -140,2 +140,6 @@ if (error) { | ||
if (result) { | ||
_this.cacheAdapter.touch(key, function (error, result) { | ||
if (error) | ||
console.error(error); | ||
}); | ||
return Promise.resolve(result); | ||
@@ -147,5 +151,2 @@ } | ||
if (!result.error) { | ||
var hash = crypto.createHash('sha256'); | ||
hash.update(utterance); | ||
var key = hash.digest('hex'); | ||
var value = JSON.stringify(result); | ||
@@ -167,3 +168,4 @@ _this.cacheAdapter.set(key, value, function (error, result) { | ||
}()); | ||
module.exports = WitRecognizer; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = WitRecognizer; | ||
//# sourceMappingURL=WitRecognizer.js.map |
{ | ||
"name": "botbuilder-wit", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Provides Wit.ai NLP integration for the Microsoft Bot Builder SDK. Supports caching with Redis and Memcached.", | ||
"main": "lib/WitRecognizer.js", | ||
"main": "lib/WitRecognizer", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "build": "tsc", |
@@ -14,3 +14,2 @@ # botbuilder-wit | ||
## General Usage | ||
This package does **not** work with Wit.ai's *Story* feature. It was designed to be used in conjunction with the IntentDialog class. | ||
``` | ||
@@ -25,3 +24,9 @@ const { IntentDialog } = require('botbuilder'); | ||
bot.dialog('/', intents) | ||
bot.dialog('/', intents); | ||
// Alternatively, you can add a global recognizer to the bot | ||
bot.recognizer(new WitRecognizer('Wit.ai_access_token')); | ||
bot.dialog('/doSomething', session => {...}).triggerAction({ | ||
matches: 'intent.name' | ||
}); | ||
``` | ||
@@ -65,4 +70,2 @@ | ||
``` | ||
## Recompiling the TypeScript source | ||
If you want to recompile the source, you will need to make sure the ```node-wit``` dependency has a type definitions file in its root directory. Even though there is a TypeScript definitions package for node-wit you can install with ```npm install --save-dev @types/node-wit```, the compiler will complain when using it. So instead, you can use the minimalistic version in the resources directory that will do the job. | ||
@@ -69,0 +72,0 @@ ## License |
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
24717
304
71
17