public async Task Call_QnA() { var kbId = "13b548dd-e2c7-4513-b331-237511233965"; var qnaKey = "93a2ad45-07b9-4032-beb8-39902fd9a525"; var caller = new QnaCaller(kbId, qnaKey); var question = "hi"; var qnaResult = await caller.Query(question); Assert.AreEqual("Hello!", qnaResult.Answers[0].Answer); Assert.AreEqual(100, qnaResult.Answers[0].Score); }
public static async Task <string> IsQnA(string messsage) { var qna = new QnaCaller(ConfigurationManager.AppSettings["QnaAppId"], ConfigurationManager.AppSettings["QnaAppKey"]); var qnaResult = await qna.Query(messsage); var qnaTopResult = qnaResult.Answers.OrderByDescending(x => x.Score).FirstOrDefault(); var threshold = double.Parse(ConfigurationManager.AppSettings["QnaThreshold"]); if (qnaTopResult != null && qnaTopResult.Score > threshold) { LogHelper.LogQnaResult(messsage, qnaResult, false, threshold); return(qnaTopResult.Answer); } LogHelper.LogQnaResult(messsage, qnaResult, true, threshold); return(string.Empty); }