app.json: (openaiwidget 初始化)
“sitemapLocation”: “sitemap.json”,
“plugins”: {
“chatbot”: {
“version”: “1.2.10”,
“provider”: “wx8c631f7e9f2465e1”
}
},
“requiredBackgroundModes”: [
“audio”
]
page1.js(openaiwidget调用处)
wx.cloud.callFunction({
name:‘getusrid’, //该云函数返回openid,经过测试,openid可以被返回
complete:res=>{
openid = res.result.openid;
console.log(‘openid:’,openid);
plugin.init({
appid: “************”,
openid:openid,
success:function(){
console.log(“AI initialized successfully!”);//每次调用也都是输出的这个
},
fail: (error) => {
console.log(“AI initialized failed!”);
},
});
}
});
const txt = “恭喜小张脱单成功”;
plugin.api.nlp(‘sentiment’, {q: txt, mode: ‘6class’}).then(res => {
console.log("sentiment result : ", res);
});//这里我直接用的微信官方文档上的代码,但是每次都会输出sentiment result : {success: false, code: 874883, msg: “系统异常,请稍候再试”}
ballball各位大佬了,救救孩子吧