微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有办法检查Wit.ai意向响应的信心?

如何解决有没有办法检查Wit.ai意向响应的信心?

我正在尝试在HTML页面中检查API响应的可信度。 如果置信度为0 {转到此页} 如果置信度为1 {转到此页} 我可以检查其他事情,但不能检查意图信心,我该怎么做?

fetch(`https://api.wit.ai/message?q=${transcript}`,{
    headers: {
        Authorization: `Bearer ${token}`,'Content-Type': 'application/json',},}).then(res => res.json())
.then(function (data){
    if (data.intents[0].value==[0]) {
        console.log("intent 1")
        //throw "Error";
    }
    else if (data.text==="pay"){
        console.log("works")
    }
    else {
        if(data.intents==="checkout"){
            console.log("intent 2");
        }
    }
})

解决方法

intents属性是一个对象数组。

您可以使用以下内容访问置信度分数;

data.intents[0].confidence

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。