Esempio n. 1
0
        Uri IQnAService.BuildFeedbackRequest(string userId, string userQuery, string kbQuestion, string kbAnswer, out QnAMakerTrainingRequestBody postBody, out string subscriptionKey, out string knowledgebaseId)
        {
            knowledgebaseId = this.qnaInfo.KnowledgebaseId;
            subscriptionKey = this.qnaInfo.SubscriptionKey;
            var builder        = new UriBuilder($"{UriBase}/{knowledgebaseId}/train");
            var feedbackRecord = new FeedbackRecord {
                UserId = userId, UserQuestion = userQuery, KbQuestion = kbQuestion, KbAnswer = kbAnswer
            };
            var feedbackRecords = new List <FeedbackRecord>();

            feedbackRecords.Add(feedbackRecord);
            postBody = new QnAMakerTrainingRequestBody {
                KnowledgeBaseId = knowledgebaseId, FeedbackRecords = feedbackRecords
            };
            return(builder.Uri);
        }
Esempio n. 2
0
        async Task <bool> IQnAService.ActiveLearnAsync(Uri uri, QnAMakerTrainingRequestBody postBody, string subscriptionKey)
        {
            try
            {
                string json;
                using (WebClient client = new WebClient())
                {
                    //Set the encoding to UTF8
                    client.Encoding = Encoding.UTF8;

                    //Add the subscription key header
                    client.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
                    client.Headers.Add("Content-Type", "application/json");

                    json = client.UploadString(uri, "PATCH", JsonConvert.SerializeObject(postBody));
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }