前言

最近ChatGPT挺火的.网上教程也多.推荐:

自己在本机搭建了下,感觉挺简单的,打算又水一篇.😁

如果没openai账号就玩不了.

环境准备

安装:

1
2
3
4
brew install nodejs
brew install pnpm
brew install redis
brew install git

没有安装brew?

方法一:完整版安装脚本

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

方法二:精简版安装脚本

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed

QQ机器人软件及插件的安装

Yunzai-Bot的安装

使用git下载项目

1
git clone --depth=1 -b main https://github.com/Le-niao/Yunzai-Bot.git

进入Yunzai目录

1
cd Yunzai-Bot

安装依赖

1
pnpm install -P

chatgpt-plugin的安装

进入yunzai根目录

1
cd Yunzai-Bot

安装依赖

1
pnpm install -w chatgpt undici showdown mathjax-node

克隆项目

1
git clone https://github.com/ikechan8370/chatgpt-plugin.git ./plugins/chatgpt-plugin

修改配置

编辑plugins/chatgpt/config/index.js文件主要修改其中的SESSION_TOKEN常量

1
2
3
4
5
const SESSION_TOKEN = ''

export const Config = {
token: SESSION_TOKEN
}

访问https://chat.openai.com/chat右键检查或者F12

在应用中找到__Secure-next-auth.session-token

image-20221212160635319

然后复制内容到引号之间.

image-20221212160719573

启动机器人

1
node app

其他插件

https://github.com/yhArcadia/Yunzai-Bot-plugins-index

(不过目前OpenAI套了CF,访问API变得困难.非官方chatgpt-api)