html52.com
我爱小程序-开发者交流社区

如何正确调用openaiwidget中的情感分析API?

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各位大佬了,救救孩子吧

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付