1

LUIS が QnA インテントであることを認識した後、QnaMakerDialog を実装しようとしています。Dialogs フォルダーには、BasicLuisDialog.cs と BasicQnAMakerDialog.cs の 2 つのファイルがあります。私のコントローラーでは、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): error CS0246: The type or namespace name 'BasicQnAMakerDialog' could not be found (are you missing a using directive or an assembly reference?)

Code for 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