private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var mess = await result; if (mess.Text.ToLower().StartsWith("nikdo") || mess.Text.ToLower() == "n" || mess.Text.ToLower() == "back") { context.Done(true); return; } var qna = new QnaService("<knowledgebase id>", "<key>"); var answer = await qna.QnAMakerQueryAsync(_entity == null?mess.Text : _entity); if (answer != null) { await context.PostAsync(answer); } else { await context.PostAsync("Toho neznám..."); } _entity = null; await context.PostAsync("Kdo dál?"); context.Wait(MessageReceivedAsync); }
public QnaLuisDialog(ILogger logger) { _logger = logger; qnaService = MakeQnaServiceFromAttributes(); keyPhrases.Add("learn english", "LearnEnglish"); keyPhrases.Add("start learning", "LearnEnglish"); }
public IActionResult UpdateQnAServices([FromBody] QnAServicesInput qnAServicesInput) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } List <QnaService> qnaServicesList = new List <QnaService>(); foreach (var item in qnAServicesInput.qnaServices) { QnaService qnaService = new QnaService() { type = item.type, endpointKey = item.endpointKey, hostname = item.hostname, id = item.id, kbId = item.kbId, name = item.name, subscriptionKey = item.subscriptionKey }; qnaServicesList.Add(qnaService); } _writeOptions.Update(opt => { opt.qnaServices = qnaServicesList; }); return(NoContent()); }
public void InitTest() { _mockRepository = new MockRepository(MockBehavior.Default); _client = _mockRepository.Create <IQnaClient>(); _configuration = _mockRepository.Create <QnaConfiguration>(); _target = new QnaService(_client.Object, _configuration.Object); _fixture = new Fixture(); }
public void InitTest() { var webClient = new RestClient { Proxy = new WebProxy("127.0.0.1", 8888) }; var configuration = new QnaConfiguration { UrlFormat = "https://westus.api.cognitive.microsoft.com/qnamaker/v2.0/knowledgebases/{0}/generateAnswer", Token = "%QNA_TOKEN%", KnowledgeBase = "your-kb-id" }; var client = new QnaClient(webClient, configuration, new CustomJsonSerializer()); _target = new QnaService(client, configuration); }
public IActionResult AddQna([FromBody] QnaServiceInfo qnaServiceInfo) { if (!ModelState.IsValid) { return(BadRequest(400)); } _writeOptions.Update(opt => { QnaService qnaService = new QnaService() { type = qnaServiceInfo.type, endpointKey = qnaServiceInfo.endpointKey, hostname = qnaServiceInfo.hostname, id = qnaServiceInfo.id, kbId = qnaServiceInfo.kbId, name = qnaServiceInfo.name, subscriptionKey = qnaServiceInfo.subscriptionKey }; opt.qnaServices.Add(qnaService); }); return(Created("/api/BotConfiguration/AddQna", qnaServiceInfo)); }
public QnaLuisDialog() { qnaService = MakeQnaServiceFromAttributes(); }