1

在 LUIS 识别出它是 QnA Intent 之后,我正在尝试实现 QnaMakerDialog。在我的 Dialogs 文件夹中,我有两个文件:BasicLuisDialog.cs 和 BasicQnAMakerDialog.cs。在我的控制器中,它调用 BasicLuisDialog,我想在其中调用 QnAMakerDialog。这是我的完整 BasicLuisDialog 代码:

using System;
using System.Configuration;
using System.Threading.Tasks;
using System.Web.Http;

using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
using System.Web.Http.Description;
using System.Net.Http;
using System.Diagnostics;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using System.Threading;
using Microsoft.Bot.Sample.QnABot;




namespace Microsoft.Bot.Sample.LuisBot
{
    [Serializable]
    public class BasicLuisDialog : LuisDialog<object>
    {
        public BasicLuisDialog() : base(new LuisService(new LuisModelAttribute("asdf", "asdf")))
//replace asdf with keys 
        {
        }

        [LuisIntent("None")]
        public async Task NoneIntent(IDialogContext context, LuisResult result)
        {
            await context.PostAsync($"You have reached the none intent. You said: {result.Query}"); //
            context.Wait(MessageReceived);
        }

        [LuisIntent("Weather.GetCondition")]
        public async Task ConditionIntent(IDialogContext context, LuisResult result)
        {
            await context.PostAsync($"You have reached the Condition intent. You said: {result.Query}"); //
            context.Wait(MessageReceived);
        }

        [LuisIntent("Weather.GetForecast")]
        public async Task ForecastIntent(IDialogContext context, LuisResult result)
        {
            await context.PostAsync($"You have reached the ForecastIntent intent. You said: {result.Query}"); //
            context.Wait(MessageReceived);
        }

        [LuisIntent("GetQnA")]
        public async Task GetQnA(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
        {
        var msg = await activity;
        var cts = new CancellationTokenSource();
        var faq = new BasicQnAMakerDialog();
        await context.Forward(faq, AfterFAQDialog, msg, CancellationToken.None);

        }

        private async Task AfterFAQDialog(IDialogContext context, IAwaitable<object> result)
        {
        context.Wait(MessageReceived);
        }

    }
}

我得到错误:

Dialogs\BasicLuisDialog.cs(51,23):错误 CS0246:找不到类型或命名空间名称“BasicQnAMakerDialog”(您是否缺少 using 指令或程序集引用?)

BasicQnAMakerDialog.cs 的代码:

using System;
using System.Configuration;

using Microsoft.Bot.Builder.CognitiveServices.QnAMaker;

namespace Microsoft.Bot.Sample.QnABot
{
    [Serializable]
    public class BasicQnAMakerDialog : QnAMakerDialog
    {
        public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute("asdf", "asdf","No good match in FAQ",0.2,3))) 
        {
        }

        protected override async Task DefaultWaitNextMessageAsync(IDialogContext context, IMessageActivity message, QnAMakerResults results)
        {
            Console.WriteLine("KB Question: " + results.Answers.First().Questions.First());
            Console.WriteLine("KB Answer: " + results.Answers.First().Answer);
            await base.DefaultWaitNextMessageAsync(context, message, results);
        }
    }

}
4

1 回答 1

0

using为 所在的命名空间添加一个BasicQnAMakerDialog.cs

using Microsoft.Bot.Sample.QnABot 
于 2017-11-09T18:24:33.130 回答