我正在尝试在LUIS识别出它是QnA Intent之后实现QnaMakerDialog。在我的Dialogs文件夹中,我有两个文件:BasicLuisDialog.cs和BasicQnAMakerDialog.cs。在我的Controller中,它调用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);
}
}
}
答案 0 :(得分:0)
为using
所在的命名空间添加BasicQnAMakerDialog.cs
。
using Microsoft.Bot.Sample.QnABot