This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@zhengxs/ernie-api
TypeScript icon, indicating that this package has built-in type declarations

0.6.3 • Public • Published

banner


TypeScriptcode style: prettiernpm packagenpm downloadsnpm downloadsLicense

文心一言 · 人工智能语言模型




一个 文心一言 封装,提供快速接入的能力。

安装

# With NPM
$ npm i -S @zhengxs/ernie-api

# With Yarn
$ yarn add @zhengxs/ernie-api

# With PNPM
$ pnpm add @zhengxs/ernie-api

示例

CLI 聊天

设置 ERNIE_BOT_COOKIE 环境变量可以不用传递 cookie。

# 开始聊天
$ erniebot

# or
$ erniebot --cookie xxxxxxx

提示: 输入 /new 可以开启新对话,输入 /exit 退出聊天

教程

简单对话

import { ErnieAPI } from '@zhengxs/ernie-api'

const api = new ErnieAPI({
  // 文心一言的 Cookie
  cookie: 'BDUSS=xxxxxxxxxxxxxxxxxx;',
})

const res = await api.createChatConversation({
  text: '你好',
})

console.log('Ernie BOT:', res.text)

连续对话

传递 sessionIdparentChatId 参数,可以保持聊天上下文,激活连续对话的能力。

const res = await api.createChatConversation({
  text: '你好',
})

console.log('Ernie BOT:', res.text)

const res2 = await api.createChatConversation({
  sessionId: res.sessionId,
  parentChatId: res.id,
  text: '我刚刚说了什么?',
})

console.log('Ernie BOT:', res2.text)

画图

图片的地址可以通过 content 获取。

const res = await api.createChatConversation({
  text: '画一只鸟',
})

// 图片链接
console.log(res.content)

插件

参考 插件列表

使用插件

import { ErnieAPI } from '@zhengxs/ernie-api'

const res = await api.createChatConversation({
  text: '北京智者天下科技有限公司的股东是谁?',
  plugins: [ErnieAPI.plugins.aiQiCha],
})

插件列表

ID 名称 描述
aiQiCha 商业信息查询 爱企查提供商业信息检索能力,可用于查企业工商/上市等信息、查老板任职/投资情况
chatFile 览卷文档 原ChatFile,可基于文档完成摘要、问答、创作等任务,仅支持10MB以内文档,不支持扫描件
eChart E言易图 基于 Apache ECharts 为您提供数据洞察和图表制作,目前支持柱状图、折线图、饼图、雷达图、散点图、漏斗图、思维导图(树图)
imageAI 说图解画 基于图片进行文字创作、回答问题,帮你写文案、想故事。暂仅支持10MB以内的图片
treeMind TreeMind树图 思维导图软件,支持脑图、逻辑图、树形图、鱼骨图、组织架构图、时间轴、时间线等多种专业格式

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @zhengxs/ernie-api

Weekly Downloads

0

Version

0.6.3

License

MIT

Unpacked Size

312 kB

Total Files

40

Last publish

Collaborators

  • zhengxs