RedisAI bindings for node_redis
npm install node-redisai-js


This package allows node-redis (2.8+) to interface with the RedisAI module.
To use this module, you will need Redis 4.0 or higher and the RedisAI module installed.
The RedisAI commands will be mapped to javascript-friendly names (ai.tensorset becomes client.ai_tensorset).
``js
var
redis = require('redis'),
redisai = require('node-redisai-js');
redisai(redis);
`
it can be run with any Tensor keys from the database as its input. The model's output, after it was executed, is stored in RedisAI Tensors as well.
Here is a quick example!The inputs for the example are the tensors stored under the 'tA' and 'tB' keys. Once the model's run had finished, a new RedisAI Tensor key called 'tC' is created and stores the model's output.
`javascript
var redis = require('redis');
var redisai = require('node-redisai-js');
var fs = require('fs')
redisai(redis);var client = redis.createClient();
var model_blob = fs.readFileSync('./examples/graph.pb');
client.ai_modelset(["mymodel", "TF", "CPU", "INPUTS", "a", "b", "OUTPUTS", "c", "BLOB", model_blob]);
client.ai_tensorset(["tA", "FLOAT", 2, "VALUES", 2, 3]);
client.ai_tensorset(["tB", "FLOAT", 2, "VALUES", 3, 5]);
client.ai_modelrun(["mymodel", "INPUTS", 'tA', 'tB', "OUTPUTS", 'tC']);
client.ai_tensorget(["tC", "VALUES"], function (err, res) {
console.log(res)
});
// Output should be
// [ '6', '15' ]
client.quit();
``