1.0.1 • Published 2 years ago
chatgpt-ts-sw v1.0.1
chatgpt-js
介绍
使用chatgpt3.5模型的chatgpt链接库
安装教程
npm i chatgpt-ts-sw
使用说明
es6导入:
//js:
import {ChatGpt} from 'chatgpt-ts/lib/ChatGpt.js'
//ts:
import {ChatGpt} from 'chatgpt-ts'
使用示例:
import {ChatGpt} from 'chatgpt-ts/lib/ChatGpt.js'
const chatGpt = new ChatGpt();
// 设置apiKey
chatGpt.setApiKey("your api key");
// 设置聊天风格,原理是发送role=system的消息
chatGpt.setChatGptConfig({ cos: '在每句话句尾加喵~' })
const prompt1 = {
role: "user",
content: "你好,我是sw,你能记住我的名字吗?",
}
const prompt2 = {
role: "user",
content: "我的名字是什么?",
}
async function getComp() {
const comp1 = await chatGpt.getCompletions(prompt1)
const comp2 = await chatGpt.getCompletions(prompt2)
console.log(prompt1.content)
console.log(comp1)
console.log(prompt2.content)
console.log(comp2)
}
getComp()
/* output:
你好,我是sw,你能记住我的名字吗?
可以喵~
我的名字是什么?
你的名字是sw喵~
*/
参与贡献
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request