【问题标题】:LuisDialog returns an InvalidIntentHandlerException every timeLuisDialog 每次都返回 InvalidIntentHandlerException
【发布时间】:2018-06-17 05:55:29
【问题描述】:

使用提琴手,我可以看到当查询传递到我的机器人应用程序时,LUIS 正在返回正确的 JSON 对象。它甚至包括列出的正确实体和意图。但是,我的班级必须设置错误,因为我在每次调用时都会收到 InvalidIntentHandlerException,这会阻止我向用户发送消息。我的意图根据我在 LUIS 中看到的内容按原样命名,所以我不知道什么被认为是无效的。

结构如下:

namespace BotApplication1.Dialogs
{
    [LuisModel("value...", "value...",)] //removed, but valid in the code as Fiddler shows this results in the proper endpoint
    [Serializable]
    public class MyDialog : LuisDialog<object> //also tried LuisDialog<string>
    {
        [LuisIntent("None")]
        public async Task None(IDialogContext context, LuisServiceResult result) // I also tried LuisResult instead of LuisServiceResult on a whim. No difference.
        {
            await context.PostAsync("I don't understand.");
            await Task.Delay(1000);
            await context.PostAsync("What were you saying?");
        }


        [LuisIntent("MessageDelete")]
        public async Task MessageDelete(IDialogContext context, LuisServiceResult result)
        {
            await context.PostAsync($"Message deleted!");
        }
    }
}

调试输出:

Exception thrown: 'Microsoft.Bot.Builder.Dialogs.InvalidIntentHandlerException' in mscorlib.dll
Error: None //the error returned to the MessageController by the LuisDialog class. It shows "None" even when I can see that LUIS returned a valid intent other than "None"

编辑:另外,我在输出中看到了这一点,但我不确定它是否重要:Service url localhost:6986 is not trusted and JwtToken cannot be sent to it. 这与应用程序连接的端口不同。

【问题讨论】:

  • 你使用的是什么版本的机器人框架?
  • 3.15.2.2(我相信是最新的稳定版)
  • 您只为 1 个意图训练过它?还是你训练的意图不在代码中?
  • [LuisIntent("None")]上方添加[LuisIntent("")],看看是否有效,这将有助于我们了解您是否没有在代码中添加Luis意图
  • 我只训练了 2 个意图,但两者都在代码中。我什至删除了我所有的意图,除了那里列出的那个。

标签: c# visual-studio-2017 artificial-intelligence botframework azure-language-understanding


【解决方案1】:

Microsoft.Bot.Builder/Dialogs/LuisDialog.cs,我们可以找到:

/// <summary>
/// The handler for a LUIS intent.
/// </summary>
/// <param name="context">The dialog context.</param>
/// <param name="luisResult">The LUIS result.</param>
/// <returns>A task representing the completion of the intent processing.</returns>
public delegate Task IntentHandler(IDialogContext context, LuisResult luisResult);

因此,应将 LUIS 意图的处理程序定义为接受 LuisResult 类型参数。

此外,正如 Ashwin Kumar 所提到的,您可以尝试在 None 方法之上添加 [LuisIntent("")],这可以帮助解决“字典中不存在给定键”错误,更多信息可以参考这个SO thread

【讨论】:

  • 是的,我根据一些例子设计了我的文件,包括这个:我猜语法已经改变了,直到昨晚我才意识到。我正在使用这个示例和其他一些示例:youtube.com/watch?v=qyQEf_rwCD0
【解决方案2】:

当我将 LuisServiceResult 的 每个 引用替换为 LuisResult 时,错误消失了,我的意图方法开始发挥作用。我仍然希望能够使用 LuisServiceResult,因为它包含更多信息;然而,这是一个家庭作业,所以它解决了我的迫切需要。

【讨论】:

    猜你喜欢
    • 2017-10-07
    • 2015-08-21
    • 2019-02-26
    • 2014-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    • 2016-05-22
    相关资源
    最近更新 更多