【发布时间】:2019-07-30 07:21:29
【问题描述】:
我目前正在使用带有 Luis 的 Enterprise Bot Template 将意图路由到正确的 QnAMaker 知识库。 QnAMaker 知识库端点存储在机器人文件中。我有一个启用多提示的请求:https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/qnamaker-prompting/csharp_dotnetcore
在提供的示例中,QnAMaker 知识库端点位于 appsettings.json 中,我无法弄清楚如何将其他知识库端点添加到 appsettings 并将意图发送到适当的知识库或让多提示对话框改为从 bot 文件中提取端点信息。
在示例中,知识库是在启动时设置的
BotBuilder-Samples-master\BotBuilder-Samples-master\experimental\qnamaker-prompting\csharp_dotnetcore\Helpers\QnAService.cs:
private static (QnAMakerOptions options, QnAMakerEndpoint endpoint) InitQnAService(IConfiguration configuration)
{
var options = new QnAMakerOptions
{
Top = 3
};
var hostname = configuration["QnAEndpointHostName"];
if (!hostname.StartsWith("https://"))
{
hostname = string.Concat("https://", hostname);
}
if (!hostname.EndsWith("/qnamaker"))
{
hostname = string.Concat(hostname, "/qnamaker");
}
var endpoint = new QnAMakerEndpoint
{
KnowledgeBaseId = configuration["QnAKnowledgebaseId"],
EndpointKey = configuration["QnAEndpointKey"],
Host = hostname
};
return (options, endpoint);
}
BotBuilder-Samples-master\BotBuilder-Samples-master\experimental\qnamaker-prompting\csharp_dotnetcore\Startup.cs:
// Helper code that makes the actual HTTP calls to QnA Maker. It is injectable for local unit testing.
services.AddHttpClient<IQnAService, QnAService>();
这是我的设置,没有对示例代码进行任何修改:
从主对话框:
else if (intent == Dispatch.Intent.q_RJH_Test_multiprompt)
{
_services.QnAServices.TryGetValue("RJH_Test_multiprompt", out var qnaService);
if (qnaService == null)
{
throw new Exception("The specified QnA Maker Service could not be found in your Bot Services configuration.");
}
else
{
QnABotState newState = null;
var query = dc.Context.Activity.Text;
var qnaResult = await _qnaService.QueryQnAServiceAsync(query, newState);
if (qnaResult != null && qnaResult.Count() > 0)
{
// start QnAPrompt dialog
await dc.BeginDialogAsync(nameof(QnADialog));
}
else
{
await _responder.ReplyWith(dc.Context, MainResponses.ResponseIds.Confused);
}
}
}
如果在 InitQnAService 方法中提供了端点,则对话框正确启动并且多提示可以工作 - 但我无法弄清楚如何在此设置中使用多个知识库。
【问题讨论】:
-
是什么阻止您将“QnAKnowledgebaseId1”等放入您的 appsettings 并在新变量名下使用它们构建新的 QnAMakerEndpoint?
-
@JJ_Wailes - 添加其他变量来处理多个 QnAMakerEndpoints 时,我不知道如何在端点变量之间切换。所以说一个意图命中 QnAKnowledgebaseId2,当调用 QueryQnAServiceAsync 方法时,requestUrl 仅基于一个端点变量进行硬编码。我正在努力将端点的标识从 MainDialog 传递到 BeginDialogAsync 方法调用中的 QnADialog。
标签: c# botframework azure-language-understanding qnamaker