【问题标题】:Unable to retrieve entity values from LUIS in Microsoft Bot framework (node.js)无法从 Microsoft Bot 框架 (node.js) 中的 LUIS 检索实体值
【发布时间】:2017-01-30 20:40:36
【问题描述】:

在 Azure 的新机器人服务上部署了一个 LUIS 模板。在本地测试了代码,它运行良好。但是,在将相同的代码加载到机器人服务时,我无法检索 LUIS 生成的实体。

下面是这段代码:

bot.dialog('/', intents);

intents.matches('getWeather',[
function(session, args, next)
{
    //session.send("Inside weather intent")
    var intent = args.intent;
    var location = builder.EntityRecognizer.findEntity(intent.entities, 'place');

我还尝试了以下方法:

var location = builder.EntityRecognizer.findEntity(args.entities, 'place');

最后:

var location = builder.EntityRecognizer.findEntity(args.intent.entities, 'place');

似乎无法检索实体。我在控制台上使用 i/o 在本地尝试了以下代码,它工作正常:

bot.dialog('/', dialog);
dialog.matches('getWeather',[
function(session, args, next)
{
    console.log("Inside weather intent")
    var location = builder.EntityRecognizer.findEntity(args.entities, 'place');

LUIS 模型已经过训练,我交叉检查了 API 变量。意图也被正确识别和触发。输出为“null”或“[object Object]”

【问题讨论】:

  • 根据示例github.com/Microsoft/BotBuilder-Samples/blob/master/Node/…,我们需要使用args.entities,顺便问一下,如果place,你能确定你有特定的类型吗?
  • @GaryLiu-MSFT,是的,我已经交叉检查了这些实体。也针对不同的实体集尝试了其他意图。使用控制台在本地执行代码作为输出会产生所需的结果。但是,部署到 Bot Service 的代码似乎没有检测到实体。我已经尝试了 GItHub 上发布的示例列表以及主要文档中的所有可能组合,但无济于事。

标签: node.js azure botframework


【解决方案1】:

要检索实体,只需使用

<entity-name>.entity

其中 entity-name 是您的var location。我希望这能解决问题。

【讨论】:

    【解决方案2】:

    我之前也遇到过同样的问题,你试过下面的代码看看你的实体是否存在?

    if(args.entities[0]) {
            session.send(args.entities[0]["entity"])
            session.send(args.entities[0]["type"])
    }
    

    如果它们确实存在,您的环境变量和 LuisModelUrl 是如何设置的?如果您使用 EV 和 "api.projectoxford.com" 作为 LuisAPIHostName,请尝试将主机名更新为 ".api.cognitive.microsoft.com"。

    【讨论】:

      猜你喜欢
      • 2018-09-13
      • 1970-01-01
      • 2020-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-03
      • 1970-01-01
      相关资源
      最近更新 更多