我无法从 wit.ai 调用中检索意图
I can't retrieve the intent from my wit.ai call
我开始使用 Wit.ai 来增强我制作的一个小机器人。我可以通过以下方式向 wit.ai 发出请求:
function sendToWitAI($query){
$witRoot = "https://api.wit.ai/message?";
$witVersion = "20170822";
$witURL = $witRoot . "v=" . $witVersion . "&q=" . $query;
$ch = curl_init();
$header = array();
$header[] = "Authorization: Bearer xxxxxxxx";
curl_setopt($ch, CURLOPT_URL, $witURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
return $server_output;
}
但是,当收到输出时,我收到的消息与我发送的消息相同。例如,如果用户键入 "I want to make a reservation" 我的 $server_output
现在是 "I want to make a reservation" 在上面的所有代码块之后。
不过,我知道它成功地达到了机智,因为我可以在那里的日志中看到它并且我知道机器人说(来自 wit.ai):
{
"confidence": null
"action": null
"type": "action"
}
最重要的是,如果我只是使用相同的查询执行 curl:
curl -XPOST 'https://api.wit.ai/converse?v=20170822&session_id=123abc&q=I%20want%20to%20make%20a%20reservation' \
> -H "Content-Type: application/json" \
> -H "Accept: application/json" \
> -H 'Authorization: Bearer xxxxxxxx'
我得到以下输出:
{
"confidence" : null,
"type" : "action",
"action" : null,
"entities" : {
"contact" : [ {
"suggested" : true,
"value" : "reservation",
"type" : "value",
"confidence" : 0.95062723294726
} ],
"intent" : [ {
"confidence" : 0.98638622681962,
"value" : "make_reservation"
} ]
}
}
我不确定我的错误在哪里或者我缺少什么来正确处理我需要的值的使用。
我一直在谷歌上不停地搜索,但在他们 (wit.ai) 弃用 "stories" 之后我找不到任何东西,而且很少有关于处理响应的东西。
您使用了 2 个不同的端点:/message 和 /converse。
您粘贴的日志来自 /converse,所以我什至不确定您的第一个电话是否接通。你可以像这样尝试 curl 到 /message
curl -XGET 'https://api.wit.ai/message?v=20170307&q=I%20want%20to%20make%20a%20reservation' \
-H 'Authorization: Bearer $TOKEN'
我开始使用 Wit.ai 来增强我制作的一个小机器人。我可以通过以下方式向 wit.ai 发出请求:
function sendToWitAI($query){
$witRoot = "https://api.wit.ai/message?";
$witVersion = "20170822";
$witURL = $witRoot . "v=" . $witVersion . "&q=" . $query;
$ch = curl_init();
$header = array();
$header[] = "Authorization: Bearer xxxxxxxx";
curl_setopt($ch, CURLOPT_URL, $witURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
return $server_output;
}
但是,当收到输出时,我收到的消息与我发送的消息相同。例如,如果用户键入 "I want to make a reservation" 我的 $server_output
现在是 "I want to make a reservation" 在上面的所有代码块之后。
不过,我知道它成功地达到了机智,因为我可以在那里的日志中看到它并且我知道机器人说(来自 wit.ai):
{
"confidence": null
"action": null
"type": "action"
}
最重要的是,如果我只是使用相同的查询执行 curl:
curl -XPOST 'https://api.wit.ai/converse?v=20170822&session_id=123abc&q=I%20want%20to%20make%20a%20reservation' \
> -H "Content-Type: application/json" \
> -H "Accept: application/json" \
> -H 'Authorization: Bearer xxxxxxxx'
我得到以下输出:
{
"confidence" : null,
"type" : "action",
"action" : null,
"entities" : {
"contact" : [ {
"suggested" : true,
"value" : "reservation",
"type" : "value",
"confidence" : 0.95062723294726
} ],
"intent" : [ {
"confidence" : 0.98638622681962,
"value" : "make_reservation"
} ]
}
}
我不确定我的错误在哪里或者我缺少什么来正确处理我需要的值的使用。
我一直在谷歌上不停地搜索,但在他们 (wit.ai) 弃用 "stories" 之后我找不到任何东西,而且很少有关于处理响应的东西。
您使用了 2 个不同的端点:/message 和 /converse。 您粘贴的日志来自 /converse,所以我什至不确定您的第一个电话是否接通。你可以像这样尝试 curl 到 /message
curl -XGET 'https://api.wit.ai/message?v=20170307&q=I%20want%20to%20make%20a%20reservation' \
-H 'Authorization: Bearer $TOKEN'