For some reason I'm unable to increase the default max steps for my chat bot.
It seems that this number is now defined in lib/config.js rather than lib/wit.js like it used to be. No matter what I change the DEFAULT_MAX_STEPS constant to in my config file my bot seems to hit the same limit (5) before throwing the 'Max steps reached, stopping' error in my log when I want the bot to send a few responses/execute a few actions in a row.
I've tried linking the file the same way the example project seems to link to the wit.js and log.js files in the module via node-wit/lib
The config file:
How I've tried to link it to my index.js file:
I'm assuming I'm not referencing the config.js file properly...
I'll write example steps of using node-wit
1) create and app folder, go to it and run: npm init
2) run npm i --save node-wit
3) app.js
:
const {Wit, log, config} = require('node-wit');
const client = new Wit({accessToken: 'MY_TOKEN'});
4) from documentation :
runActions
A higher-level method to the Wit converse API. runActions resets the last turn on new messages and errors.
Takes the following parameters:
sessionId - a unique identifier describing the user session message - the text received from the user context - the object representing the session state maxSteps - (optional) the maximum number of actions to execute (defaults to 5)
so I'll add MAX_STEPS
to example there:
const MAX_STEPS = 25;
const sessionId = 'some-session-id';
const context0 = {};
client
.runActions(sessionId, 'events nearby', context0, MAX_STEPS)
.then((context1) => {
return client.runActions(sessionId, 'how about in London?', context1, MAX_STEPS - 1);
})
.then((context2) => {
console.log('The session state is now: ' + JSON.stringify(context2));
})
.catch((e) => {
console.log('Oops! Got an error: ' + e);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.