4

chatgpt-api:基于ChatGPT API的Node.js应用

 1 year ago
source link: https://www.jdon.com/64878.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

chatgpt-api:基于ChatGPT API的Node.js应用


这个包是 OpenAI 围绕 ChatGPT 的Node.js[url=https://openai.com/blog/chatgpt]包装[/url]器,可以使用它开始构建由 ChatGPT 支持的项目,例如聊天机器人、网站等...

它现在使用官方的 OpenAI  API和 ChatGPT 在后台使用的leaked模型。

安装:
npm install chatgpt

注册OpenAI API 密钥并将其存储在您的环境中:

import { ChatGPTAPI } from 'chatgpt'

const api = new ChatGPTAPI({
  apiKey: process.env.OPENAI_API_KEY
})

const res = await api.sendMessage('Hello World!')
console.log(res.text)

OPENAI_API_KEY在 .env 中设置。
更新后的版本明显更加轻巧和健壮。您也不必担心 IP 问题或速率限制!

详细点击标题


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK