【问题标题】:Changing Wit.ai Default Max Steps更改 Wi.ai 默认最大步数
【发布时间】:2016-11-16 01:33:24
【问题描述】:

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

似乎这个数字现在是在 lib/config.js 中定义的,而不是像以前那样在 lib/wit.js 中定义。无论我在我的配置文件中将 DEFAULT_MAX_STEPS 常量更改为什么,当我希望机器人发送一些响应/执行时,我的机器人似乎在我的日志中抛出“达到最大步数,停止”错误之前达到了相同的限制 (5)连续几个动作。

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

配置文件:

我如何尝试将它链接到我的 index.js 文件:

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

【问题讨论】:

  • 您的应用在第二张截图中的位置?

标签: node.js wit.ai


【解决方案1】:

我将编写使用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:

运行操作

Wit converse API 的高级方法。 runActions 重置 最后打开新消息和错误。

采用以下参数:

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

【讨论】:

  • 澄清一下,我的应用程序设置正确(不在包文件夹内),Wit 工程师之前建议通过修改包文件来修改默认最大步数 - github.com/wit-ai/node-wit/issues/65 你的解决方案对我有用不过,谢谢!
  • 很高兴我的回答很有用(:
猜你喜欢
  • 2019-01-09
  • 2013-02-01
  • 2012-09-15
  • 2017-01-23
  • 2012-06-12
  • 1970-01-01
  • 2018-04-14
  • 2017-11-22
  • 1970-01-01
相关资源
最近更新 更多