npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wechat-openai

v0.3.1

Published

http://openai.weixin.qq.com,AI,智能对话

Downloads

15

Readme

官方的版本安装了使用不起来,所以fork修改了一下。(〃'▽'〃)

快速开始

1. 安装wechat-openai


  yarn add wechat-openai
  import { OpenAI } from 'wechat-openai'

2. 引入并初始化相关参数


  import { OpenAI } from 'wechat-openai'
 const ai = new OpenAI("","")

3. 聊天接口


  ai.chat({
    username: "uid",
    msg: "你好吗"
  }).then(res => {
      console.log('机器人返回:', res)
  }, res => {
      console.log('reject res:', res)
  }).catch(e => {
      console.log('error', e)
  })

4.nlp相关接口

4.1 分词

    // 分词
    ai.nlp.tokenize({
        uid: "uid",
        data: {
            q: "我的家乡叫中国。"
        }
    }).then(res => {
        console.log('词法分析返回:', res)
    }, res => {
        console.log('reject res:', res)
    }).catch(e => {
        console.log('error', e)
    })

   // 分词接口返回值
   {
      words: ['我', '的', '家乡', '叫', '中国', '。'],
      POSs: [27, 30, 16, 31, 20, 34],
      words_mix: ['我的家乡', '叫', '中国', '。'],
      POSs_mix: [16, 31, 20, 34],
      entities: ['我的家乡', '我的', '中国'],
      entity_types: [0, 0, 100000012]
  }

4.2 数字日期时间识别

    // 数字日期时间识别
    ai.nlp.ner({
        uid: "uid",
        data: {
            q: "帮我订两张后天上午的火车票"
        }
    }).then(res => {
        console.log('数字日期时间识别返回:', res)
    }, res => {
        console.log('reject res:', res)
    }).catch(e => {
        console.log('error', e)
    })

   // 数字日期时间识别接口返回值
   [
      {
          type: 'number',
          span: [3, 4],
          text: '两',
          norm: '2'
      },
      {
          type: 'datetime_interval',
          span: [5, 9],
          text: '后天上午',
          norm: '2019-11-23 08:00:00~2019-11-23 11:59:59'
      }
    ]

4.3 情感分析

    // 情感分析
    ai.nlp.sentiment({
        uid: "uid",
        data: {
            q: "恭喜小张脱单成功",
            mode: "6class"
        }
    }).then(res => {
        console.log('情感分析返回:', res)
    }, res => {
        console.log('reject res:', res)
    })
    .catch(e => {
        console.log('error', e)
    })

   // 情感分析接口返回值
   {
      error: null,
      result: [
          ['高兴', 0.9011998772621155],
          ['无情感', 0.08493703603744507],
          ['喜欢', 0.011011340655386448],
          ['悲伤', 0.0015742022078484297],
          ['厌恶', 0.0006485909689217806],
          ['愤怒', 0.000628964276984334]
      ]
  }

4.4 敏感词识别

    // 敏感词识别
    ai.nlp.sensitive({
        uid: "uid",
        data: {
            q: "楼主真垃圾,祝你早日死全家"
        }
    }).then(res => {
        console.log('敏感词识别返回:', res)
    }, res => {
        console.log('reject res:', res)
    }).catch(e => {
        console.log('error', e)
    })

   // 敏感词识别接口返回值
   {
      error: null,
      result: [
          ['dirty_curse', 0.9999999900000001],
          ['other', 9.9999999e-9],
          ['dirty_politics', 0],
          ['dirty_porno', 0]
      ]
  }