[.Net SDK, QnA Maker] Train API is not working?
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;
}
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.
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.
Can you confirm that the userID you used everytime is unique?
Yes..I am sending user id from "1" to "50". These are not real users, just dummy test values
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.
I have published it but it does not work
Can you drop a mail to [email protected] with details of your KB, so we can take a look?
I have dropped email to [email protected] with the details from my official email address [email protected]
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.
I'm also having the same issue. Did you find a solution for it?
Can you drop a mail to [email protected] with details of your KB, so we can take a look?
Hi All,
We recently deployed a fix for this issue. Can you please re-check this?
I tried but I could not.
Can you please let us know if the issue still persists?
Closing per last comment from @pchoudhari.