更改 Wit.ai 默认最大步数

Changing Wit.ai Default Max Steps

出于某种原因,我无法增加聊天机器人的默认最大步数。

似乎这个数字现在是在 lib/config.js 中定义的,而不是像以前那样在 lib/wit.js 中定义的。无论我在我的配置文件中将 DEFAULT_MAX_STEPS 常量更改为什么,当我希望机器人发送一些 responses/execute连续几个动作。

我已经尝试 link 以与示例项目似乎 link 到模块中的 wit.js 和 log.js 文件相同的方式通过 node-wit/lib

配置文件:

我是如何尝试 link 它到我的 index.js 文件中的:

我假设我没有正确引用 config.js 文件...

我将编写使用 node-wit

的示例步骤

1) 创建和 app 文件夹,转到它并 运行: npm init

2) 运行 npm i --save node-wit

3) app.js :

const {Wit, log, config} = require('node-wit');
const client = new Wit({accessToken: 'MY_TOKEN'});

4) 来自 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)

所以我会在此处添加 MAX_STEPS 示例:

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);
  });