Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public QnaLuisDialog(ILogger logger)
 {
     _logger    = logger;
     qnaService = MakeQnaServiceFromAttributes();
     keyPhrases.Add("learn english", "LearnEnglish");
     keyPhrases.Add("start learning", "LearnEnglish");
 }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 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));
 }
Exemplo n.º 7
0
 public QnaLuisDialog()
 {
     qnaService = MakeQnaServiceFromAttributes();
 }