如何自动训练知识库(QnAMaker服务)?

时间:2017-03-17 07:05:29

标签: microsoft-cognitive

在Microsoft的认知服务提供的QnA Maker服务中,我们可以通过手动插入QnA对来训练我们的KB(知识库)。

有没有办法自动化这个过程,以便我们可以随时保持我们的KB最新?有一个API文档,但我找不到一个用于此目的

2 个答案:

答案 0 :(得分:1)

新的V2.0 APIs可让您以编程方式管理知识库。现在,您可以使用API​​执行以下操作:

  • 创建知识库
  • 删除知识库
  • 更新知识库
  • 下载知识库
  • 发布知识库

答案 1 :(得分:0)

我创建了一个自动更新QnA Maker 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

相关问题