将LUIS与C#Bot框架集成-错误

我正在尝试将Luis.ai集成到C#机器人框架中。该代码运行,但是当我向机器人发送消息时,它显示此错误:

“很抱歉,我的机器人代码出了问题”

当它根据使用意图的条目进行回复时,我只有两个意图“ None”和“ perfil”。

这是我的日志:

http://img3.mukewang.com/609643dd0001056412570205.jpg

这是我的类Perfil.cs:


using Microsoft.Bot.Builder.Dialogs;

using Microsoft.Bot.Builder.Luis;

using Microsoft.Bot.Builder.Luis.Models;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using System.Web;


namespace SistemaExperto.Dialogs

{

    [LuisModel(modelID: "e6168727-2f3e-438b-b46a-88449f4ab52f", subscriptionKey: "ed5f1bda20ac42649123b8969d30e1aa")]

    [Serializable]

    public class Perfil : LuisDialog<string>

    {


        [LuisIntent("None")]

        public async Task None(IDialogContext context, LuisServiceResult result)

        {

            await context.PostAsync("I'm sorry I don't have that information");

            await context.PostAsync("Try again");

        }


        [LuisIntent("perfil")]

        public async Task perfil(IDialogContext context, LuisServiceResult result)

        {

            await context.PostAsync("My name is Alex");

        }



    }

}


杨__羊羊
浏览 147回答 1
1回答

蝴蝶不菲

我测试了您提供的代码,并用我的LUIS应用程序modelID&subscriptionKey替换了该代码,如果该代码达到了perfil意图,则该代码将按预期工作。如果LuisDialog无法根据收到的消息解析要执行的方法(意图),则会收到异常:给定的键在词典中不存在。为了解决这个问题,我[LuisIntent("")]在None方法之上添加了内容。[LuisModel(modelID: "{your_modelID}", subscriptionKey: "{your_ subscriptionKey}")][Serializable]public class Perfil : LuisDialog<object>{&nbsp; &nbsp; [LuisIntent("")]&nbsp; &nbsp; [LuisIntent("None")]&nbsp; &nbsp; public async Task None(IDialogContext context, LuisResult result)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; await context.PostAsync("I'm sorry I don't have that information");&nbsp; &nbsp; &nbsp; &nbsp; await context.PostAsync("Try again");&nbsp; &nbsp; }&nbsp; &nbsp; [LuisIntent("perfil")]&nbsp; &nbsp; public async Task perfil(IDialogContext context, LuisResult result)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; await context.PostAsync("My name is Alex");&nbsp; &nbsp; }}测试结果:达成perfil目标:异常错误:
打开App,查看更多内容
随时随地看视频慕课网APP