Socket
Socket
Sign inDemoInstall

ai-unit

Package Overview
Dependencies
37
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-unit

baidu nlu platform UNIT API


Version published
Maintainers
1
Weekly downloads
3

Weekly downloads

Readme

Source

UNIT

BAIDU UNIT API, see more UNIT

INSTALL

npm install unit

EXAMPLE

const { Unit } = require('ai-unit')
async function main() {
  try {
    const unitClient = new Unit({
      apikey:    'your key', 
      secretkey: 'yout secret key', 
      sceneid:   '15386'
    })
    const sessionId = Date.now()
    let answer
  
    answer = await unitClient.query('我要买电影票', sessionId.toString())
    console.log('[PERSON]:' + '我要买电影票')
    console.log('[BOT]:' + answer)

    answer = await unitClient.query('心理罪', sessionId.toString())
    console.log('[PERSON]:' + '心理罪')
    console.log('[BOT]:' + answer)

    answer = await unitClient.query('天幕吧', sessionId.toString())
    console.log('[PERSON]:' + '天幕吧')
    console.log('[BOT]:' + answer)
  } catch (error) {
    console.error(error)
  }
}
main()

Result as follows:

[PERSON]:我要买电影票
[BOT]:看哪部电影?
[PERSON]:心理罪
[BOT]:去哪个电影院?
[PERSON]:天幕吧
[BOT]:订哪天的?

API

  1. Unit.getAccessToken()
  2. Unit.query(content: string, sessionId?: string)
  3. Unit.setScene(sceneId)

Keywords

FAQs

Last updated on 13 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc