我正在尝试将我的机器人从 QnAMaker v2 API 迁移到 QnAMaker v4 API。我可以将更新发送到知识库,但似乎不需要发布。这是我正在使用的代码。
static void Main(string[] args)
{
MainAsync(args).Wait();
}
static async Task MainAsync(string[] args)
{
Console.WriteLine("We're starting.");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", mySubKey);
var uri = new Uri($"https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/{myKBId}");
var payload = "{\"add\": {\"qnaList\": [{\"id\": 0,\"answer\": \"A woodchuck could chuck all the wood he could chuck if a woodchuck could chuck wood.\",\"source\": \"Custom Editorial\",\"questions\": [\"How much wood could a woodchuck chuck if a woodchuck could chuck wood?\"],\"metadata\": []}]},\"delete\": {},\"update\": {}}";
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, uri);
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var responseMessage = await response.Content.ReadAsStringAsync();
Console.Write(responseMessage);
Console.ReadLine();
method = new HttpMethod("POST");
payload = "";
request = new HttpRequestMessage(method, uri);
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
response = await client.SendAsync(request);
responseMessage = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseMessage);
Console.ReadLine();
}
我的测试过程是
- 向机器人询问土拨鼠。
- 运行此代码。
- 验证知识库中关于土拨鼠的 q/a 对。
- 再次向机器人询问土拨鼠。
到目前为止,api 的响应符合预期,但我的机器人仍然没有注意到重要的土拨鼠知识,直到我点击 qnamaker.ai 网站上的发布。我错过了什么?