亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將LUIS與C#Bot框架集成-錯誤

將LUIS與C#Bot框架集成-錯誤

C#
楊__羊羊 2021-04-27 13:08:46
我正在嘗試將Luis.ai集成到C#機器人框架中。該代碼運行,但是當我向機器人發送消息時,它顯示此錯誤:“很抱歉,我的機器人代碼出了問題”當它根據使用意圖的條目進行回復時,我只有兩個意圖“ None”和“ perfil”。這是我的日志:這是我的類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");        }    }}
查看完整描述

1 回答

?
蝴蝶不菲

TA貢獻1810條經驗 獲得超4個贊

我測試了您提供的代碼,并用我的LUIS應用程序modelID&subscriptionKey替換了該代碼,如果該代碼達到了perfil意圖,則該代碼將按預期工作。


如果LuisDialog無法根據收到的消息解析要執行的方法(意圖),則會收到異常:


給定的鍵在詞典中不存在。


為了解決這個問題,我[LuisIntent("")]在None方法之上添加了內容。


[LuisModel(modelID: "{your_modelID}", subscriptionKey: "{your_ subscriptionKey}")]

[Serializable]

public class Perfil : LuisDialog<object>

{

    [LuisIntent("")]

    [LuisIntent("None")]

    public async Task None(IDialogContext context, LuisResult 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, LuisResult result)

    {

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

    }


}

測試結果:


達成perfil目標:

http://img1.sycdn.imooc.com//609643f500015a8d08860569.jpg

異常錯誤:

http://img1.sycdn.imooc.com//609644020001db9508940571.jpg


查看完整回答
反對 回復 2021-05-08
  • 1 回答
  • 0 關注
  • 169 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號