【问题标题】:C# - Auto suggestions in chat bot using Bot FrameworkC# - 使用 Bot Framework 的聊天机器人中的自动建议
【发布时间】:2018-12-17 01:20:24
【问题描述】:

我正在尝试使用 C# 中的 Bot Framework 在聊天机器人中实现自动问题建议弹出窗口。如何将多个自动问题建议弹出窗口保留在一行中。当我输入 hi(文本字段)时,它会给出多个建议(比如你好,嘿,嗨等)并点击建议它会自动完成它,它应该像谷歌建议。

我是用 C# 实现的,但它给出了多个答案的建议。下面是我的示例代码

[QnAMaker("set yout subscription key here", "set your kbid here", "I don't understand this right now! Try another query!", 0.50, 3)]
    public class QnABotWithCustomAnswer : QnAMakerDialog
    {
        protected override async Task QnAFeedbackStepAsync(IDialogContext context, QnAMakerResults qnaMakerResults)
        {
            // responding with the top answer when score is above some threshold
            if (qnaMakerResults.Answers.Count > 0 && qnaMakerResults.Answers.FirstOrDefault().Score > 0.75)
            {
                await context.PostAsync(qnaMakerResults.Answers.FirstOrDefault().Answer);
            }
            else
            {
                await base.QnAFeedbackStepAsync(context, qnaMakerResults);
            }
        }
}

请帮帮我。

【问题讨论】:

    标签: c# botframework azure-bot-service


    【解决方案1】:

    它给出了多个答案的建议

    在您的代码中,我们可以发现您将top属性(返回的答案数)设置为3,如果您希望您的QnAMaker对话框返回前1个答案,您可以设置@ 987654322@ 属性到 1

    [QnAMaker("{subscriptionKey_here}", "{ knowledgebaseId_here}", "I don't understand this right now! Try another query!", 0.50, 1)]
    

    这里是QnAMakerAttribute的定义,大家可以查看一下,了解各个参数的详细情况:

    // Summary:
    //     Construct the QnA Knowledgebase information.
    //
    // Parameters:
    //   knowledgebaseId:
    //     The QnA Knowledgebase ID.
    //
    //   defaultMessage:
    //     The default message returned when no match found.
    //
    //   scoreThreshold:
    //     The threshold for answer score.
    //
    //   top:
    //     The number of answers to return.
    public QnAMakerAttribute(string authKey, string knowledgebaseId, string defaultMessage = null, double scoreThreshold = 0.3, int top = 1, string endpointHostName = null);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 2017-11-10
      • 2020-10-07
      相关资源
      最近更新 更多