botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[.Net SDK, QnA Maker] Train API is not working?

Open pkpaul5 opened this issue 9 years ago • 15 comments

I am trying to train Microsoft QnAMaker programmatically for alternate question. I am calling the REST API for training for more than 50 times for alternate question. But it is not working. The code is provided below :

var client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "b6da7e5e904148a88e651d3781e3e519");
            var uri = "https://westus.api.cognitive.microsoft.com/qnamaker/v2.0/knowledgebases/e31c0d13-6531-4af6-9352-5f7c125d448d/train";

            HttpResponseMessage response;
            QnAMakerTrainObject data = new QnAMakerTrainObject();
            data.feedbackRecords = new List<FeedbackRecord>();
            FeedbackRecord f = new FeedbackRecord();
            f.kbQuestion = "q3";
            f.kbAnswer = "a3";
            f.userQuestion = question;
            f.userId = userID;
            data.feedbackRecords.Add(f);
            string json = JsonConvert.SerializeObject(data);
            byte[] messageBytes = System.Text.Encoding.UTF8.GetBytes(json);

            var content = new ByteArrayContent(messageBytes);
            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            var method = new HttpMethod("PATCH");
            var request = new HttpRequestMessage(method, uri);
            request.Content = content;
            response = await client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var responseContent = response.Content;
                string responseString = responseContent.ReadAsStringAsync().Result;
            }

pkpaul5 avatar Aug 18 '17 10:08 pkpaul5

Hi,

Please see https://qnamaker.ai/Documentation/ActiveLearning on how active learning and the train API work.

If you simply want to add a question alteration to the KB, just use the Update KB API.

pchoudhari avatar Aug 21 '17 04:08 pchoudhari

As I mentioned earlier, I am trying to train the QnA Maker for Alternate question. I am not trying to update the question. I am calling the below API "https://westus.api.cognitive.microsoft.com/qnamaker/v2.0/knowledgebases/e31c0d13-6531-4af6-9352-5f7c125d448d/train" more than 50 times, As you can see in the code provided above I am providing the alternate question, original question and answer while calling the API.

pkpaul5 avatar Aug 21 '17 05:08 pkpaul5

Can you confirm that the userID you used everytime is unique?

pchoudhari avatar Aug 22 '17 05:08 pchoudhari

Yes..I am sending user id from "1" to "50". These are not real users, just dummy test values

pkpaul5 avatar Aug 22 '17 06:08 pkpaul5

The alternate question you add, will not reflect in your production endpoint directly. You need to publish the changes for the endpoint to be updated. You can do this via the portal or APIs

This gives you a chance to review the changes before impacting the endpoint.

pchoudhari avatar Aug 22 '17 08:08 pchoudhari

I have published it but it does not work

pkpaul5 avatar Aug 22 '17 08:08 pkpaul5

Can you drop a mail to [email protected] with details of your KB, so we can take a look?

pchoudhari avatar Aug 22 '17 11:08 pchoudhari

I have dropped email to [email protected] with the details from my official email address [email protected]

pkpaul5 avatar Aug 22 '17 11:08 pkpaul5

Some problem here following the same procedure (users from 1 to 50). I get 204 statusCode but on my knowledge base nothing seems to update.

ThanosDi avatar Sep 01 '17 11:09 ThanosDi

I'm also having the same issue. Did you find a solution for it?

vaartun avatar Sep 27 '17 08:09 vaartun

Can you drop a mail to [email protected] with details of your KB, so we can take a look?

pchoudhari avatar Sep 28 '17 06:09 pchoudhari

Hi All,

We recently deployed a fix for this issue. Can you please re-check this?

pchoudhari avatar Oct 06 '17 04:10 pchoudhari

I tried but I could not.

harasawa avatar Feb 16 '18 05:02 harasawa

Can you please let us know if the issue still persists?

fanidamj-zz avatar Jun 21 '18 23:06 fanidamj-zz

Closing per last comment from @pchoudhari.

vishwacsena avatar Jun 26 '18 00:06 vishwacsena