在微软的认知服务提供的QnA Maker服务中,我们可以通过手动插入QnA对来训练我们的知识库(知识库)。
有没有办法让这个过程自动化,这样我们就可以随时更新我们的知识库了?有一个API文档,但我找不到用于此目的的文档
发布于 2017-03-17 20:28:19
发布于 2020-06-28 17:58:18
我已经创建了一个机器人,将自动更新QnA制造商知识库。目前支持添加操作,即在KB中添加QnA对并发布。我通过C#使用了QnA Maker客户端库。您可以找到文档here。
在用户提供qna对时,我将调用客户端库。
if ((bool)stepContext.Result)
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Here are the details you provided."), cancellationToken);
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Questions - "), cancellationToken);
for (int i = 0; i < QnAData.QuestionPhrase.Count; i++)
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text(QnAData.QuestionPhrase[i]), cancellationToken);
}
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Answer - " + (string)stepContext.Values["Answer"]), cancellationToken);
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Please wait while I update your Knowledge Base."), cancellationToken);
var authoringURL = $"https://{Configuration["ResourceName"]}.cognitiveservices.azure.com";
// <AuthorizationAuthor>
var client = new QnAMakerClient(new ApiKeyServiceClientCredentials(Configuration["Key"]))
{ Endpoint = authoringURL };
// </AuthorizationAuthor>
QnAClient.UpdateKB(client, Configuration["KnowledgeBaseId"], (string)stepContext.Values["Answer"]).Wait();
QnAClient.PublishKb(client, Configuration["KnowledgeBaseId"]).Wait();
await stepContext.Context.SendActivityAsync(MessageFactory.Text("I have added your qna pair in the Knowledge Base. Thank you for using QnA Updator Bot Service."));
return await stepContext.EndDialogAsync(null, cancellationToken);
}
else
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Request Not Confirmed."));
return await stepContext.EndDialogAsync(cancellationToken: cancellationToken);
}
你可以在这里找到完整的文章:https://jd-bots.com/auto-updater-qna-maker-kb-bot/。
你可以观看视频来检查机器人的结果:https://youtu.be/nSGgph_RXiE。
https://stackoverflow.com/questions/42851224
复制相似问题