Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge chatgpt-api into main #782

Merged
merged 23 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7fd9fad
fix: 'tigger' to 'trigger'
kx-Huang Dec 13, 2022
6fa5884
feat: 🎸 add block words
RealTong Mar 12, 2023
e14cee1
Merge pull request #708 from RealTong/chatgpt-api
RealTong Mar 12, 2023
eafb93f
feat: 🎸 Support for using custom ChatGPT API
RealTong Mar 14, 2023
871cbf9
Merge pull request #718 from RealTong/chatgpt-api
RealTong Mar 14, 2023
b47c448
Merge remote-tracking branch 'kx-Huang/fix-typo' into chatgpt-api
RealTong Mar 15, 2023
dfac72e
Merge pull request #726 from RealTong/chatgpt-api
RealTong Mar 15, 2023
8f2909d
add continuous dialogue feat
RealTong Mar 17, 2023
d046c2b
fix: 🐛 修复群聊无法设置prompt的bug
RealTong Mar 18, 2023
0e91ff1
Merge pull request #743 from RealTong/chatgpt-api
RealTong Mar 18, 2023
d10c880
fix: 🐛 Fix docker start error
RealTong Mar 18, 2023
179c1ab
Merge pull request #744 from RealTong/chatgpt-api
RealTong Mar 18, 2023
3101b11
fix: 🐛 修复可能以wechaty-puppet-wechat4u启动的bug
RealTong Mar 19, 2023
8b369b1
refactor: 💡 Refactor the continuous dialogue section
RealTong Mar 19, 2023
a465b6b
feat: 🎸 add dalle
RealTong Mar 19, 2023
a6c8878
Merge pull request #753 from RealTong/chatgpt-api
RealTong Mar 19, 2023
4d079a0
fix: 🐛 Fix the bug that docker failed to start
RealTong Mar 20, 2023
80e3189
Merge pull request #755 from RealTong/chatgpt-api
RealTong Mar 20, 2023
a7c329b
feat: 🎸 Add whisper support
RealTong Mar 21, 2023
02b0aac
Merge pull request #772 from RealTong/chatgpt-api
RealTong Mar 21, 2023
0eba8b8
Add WeChat/ChatGPT interaction & deployment/config options
RealTong Mar 22, 2023
173faae
Merge pull request #781 from RealTong/chatgpt-api
RealTong Mar 22, 2023
14b0a6e
Merge pull request #779 from 24322162/main
RealTong Mar 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
OPENAI_API_KEY=""
MODEL="gpt-3.5-turbo"
CHAT_PRIVATE_TRIGGER_KEYWORD=
CHAT_PRIVATE_TRIGGER_KEYWORD=
TEMPERATURE=
BLOCK_WORDS="VPN"
CHATGPT_BLOCK_WORDS="VPN"
WECHATY_PUPPET=wechaty-puppet-wechat
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,6 @@ cache.json
config.yaml
.vscode

data/
data/

public/
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ENV WECHATY_PUPPET_WECHAT_ENDPOINT=/usr/bin/google-chrome
CMD xvfb-run --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR" npm run dev
65 changes: 56 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/dMLG70?referralCode=bIYugQ)

## 🌟 Feature
## 🌟 Features

- [x] Use ChatGPT on WeChat with [wechaty](https://github.com/wechaty/wechaty)
and [Official API](https://openai.com/blog/introducing-chatgpt-and-whisper-apis)
- [x] Add conversation Support
- [x] Add Dockerfile, you can use it with [docker](#use-with-docker---recommended-)
- [x] Publish to Docker.hub
- [x] Deploy using [docker compose](#use-with-docker-compose---recommended-)
- [x] Add Railway deploy
- Interact with WeChat and ChatGPT:
- Use ChatGPT on WeChat with [wechaty](https://github.com/wechaty/wechaty) and [Official API](https://openai.com/blog/introducing-chatgpt-and-whisper-apis)
- Add conversation support
- Support command setting

- Deployment and configuration options:
- Add Dockerfile, deployable with [docker](#use-with-docker)
- Support deployment using [docker compose](#use-with-docker-compose)
- Support [Railway](#use-with-railway) and [Fly.io](#use-with-flyio) deployment

- Other features:
- Support [Dall·E](https://labs.openai.com/)
- Support [whisper](https://openai.com/blog/introducing-chatgpt-and-whisper-apis)
- Support setting prompt
- Support proxy (in development)

## 🚀 Usage
- [Use with Railway](#use-with-railway)(PaaS, Free, Stable, ✅Recommended)
Expand Down Expand Up @@ -78,7 +86,6 @@
flyctl deploy
```


## Use with docker

```sh
Expand Down Expand Up @@ -128,6 +135,46 @@ npm run dev

> Please make sure your WeChat account can log in [WeChat on web](https://wx.qq.com/)

## 📝 Environment Variables

| name | default | example | description |
|------------------------------|------------------------|------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ~~API~~ | https://api.openai.com | | ~~API endpoint of ChatGPT~~ |
| OPENAI_API_KEY | 123456789 | sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | [create new secret key](https://platform.openai.com/account/api-keys) |
| MODEL | gpt-3.5-turbo | | ID of the model to use. Currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported. |
| TEMPERATURE | 0.6 | | What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. |
| CHAT_TRIGGER_RULE | | | Private chat triggering rules. |
| DISABLE_GROUP_MESSAGE | true | | Prohibited to use ChatGPT in group chat. |
| CHAT_PRIVATE_TRIGGER_KEYWORD | | | Keyword to trigger ChatGPT reply in WeChat private chat |
| BLOCK_WORDS | "VPN" | "WORD1,WORD2,WORD3" | Chat blocker words, (works for both private and group chats, Use, Split) |
| CHATGPT_BLOCK_WORDS | "VPN" | "WORD1,WORD2,WORD3" | The blocked words returned by ChatGPT(works for both private and group chats, Use, Split) |

## 📝 Using Custom ChatGPT API

> https://github.com/fuergaosi233/openai-proxy

```shell
# Clone the project
git clone https://github.com/fuergaosi233/openai-proxy
# Install dependencies
npm install && npm install -g wrangler && npm run build
# Deploy to CloudFlare Workers
npm run deploy
# Custom domain (optional)
Add `Route` to `wrangler.toml`
routes = [
{ pattern = "Your Custom Domain", custom_domain = true },
]
```

## ⌨️ Commands
> Enter in the WeChat chat box
```shell
/cmd help # Show help
/cmd prompt <PROMPT> # Set prompt
/cmd clear # Clear all sessions since last boot
```

## ✨ Contributor

<a href="https://github.com/fuergaosi233/wechat-chatgpt/graphs/contributors">
Expand Down
72 changes: 64 additions & 8 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,46 @@

## 🌟 功能点

- [x] 通过 [wechaty](https://github.com/wechaty/wechaty) 和 [官方 API](https://openai.com/blog/introducing-chatgpt-and-whisper-apis),将 ChatGPT 接入微信
- [x] 加入了持续对话的功能
- [x] 加入 Dockerfile, 通过 [Docker](#通过docker使用-推荐) 进行部署
- [x] 发布到 Docker.hub
- [x] 使用[docker compose](#通过docker-compose使用-推荐)进行部署
- [x] 通过 Railway 进行部署
- 使用 WeChat 和 ChatGPT 进行互动:
- 基于 [wechaty](https://github.com/wechaty/wechaty) 和 [Official API](https://openai.com/blog/introducing-chatgpt-and-whisper-apis) 在微信中使用 ChatGPT
- 支持多轮对话
- 支持[命令](#-命令)设置

- 部署和配置选项:
- 提供 Dockerfile,可以通过 [docker](#通过docker使用) 进行部署
- 支持使用 [docker compose](#通过docker-compose使用) 进行部署
- 支持在 [Railway](#使用railway进行部署) 和 [Fly.io](#通过flyio进行部署) 上部署

- 其他功能:
- 支持 [Dall·E](https://labs.openai.com/)
- 支持 [whisper](https://openai.com/blog/introducing-chatgpt-and-whisper-apis)
- 支持设置 prompt
- 支持代理(开发中)

## 🚀 使用

- [在 Railway 部署](#使用railway进行部署)(PaaS, 免费, 稳定, ✅推荐)
- [在 Fly.io 部署](#通过flyio进行部署)(PaaS, 免费, ✅推荐)
- [使用 Docker 部署](#通过docker使用)(自托管, 稳定, ✅推荐)
- [使用 Docker Compose 部署](#通过docker-compose使用)(自托管, 稳定, ✅推荐)
- [使用 NodeJS 部署](#使用nodejs运行)

## 使用Railway进行部署

> Railway 是一个免费的 PaaS 平台,5刀以内的账单免费或者每个月500小时的运行时间

1. 点击 [Railway](https://railway.app/template/dMLG70?referralCode=bIYugQ) 按钮,进入 Railway 部署页面
2. 点击 `Deploy Now` 按钮,进入 Railway 部署页面
3. 填写 仓库名称和 `OPENAI_API_KEY`(需要连接 GitHub 账号)
4. 点击 `Deploy` 按钮
5. 点击 `View Logs` 按钮,等待部署完成

## 通过Fly.io进行部署

> 请为应用程序分配 512 MB 内存,否则可能会出现内存溢出

> Fly.io 5刀以内的账单免费(免费计划的3个256MB的应用不在账单内)也就是可以同时可以部署 `1*512MB + 3*256MB`
> Fly.io 5刀以内的账单免费(免费计划的3个256MB的应用不在账单内)也就是可以同时可以部署 `1*512MB + 3*256MB`

1. 安装 [flyctl](https://fly.io/docs/getting-started/installing-flyctl/)
```shell
# macOS
Expand Down Expand Up @@ -91,6 +105,7 @@ docker run -it --name wechat-chatgpt \
# 使用二维码登陆
docker logs -f wechat-chatgpt
```

> 如何获取 OPENAI API KEY?请参考 [OpenAI API](https://platform.openai.com/account/api-keys)。

## 通过docker compose使用
Expand All @@ -107,7 +122,9 @@ docker logs -f wechat-chatgpt
```

## 使用NodeJS运行

> 请确认安装的NodeJS版本为18.0.0以上

```sh
# 克隆项目
git clone https://github.com/fuergaosi233/wechat-chatgpt.git && cd wechat-chatgpt
Expand All @@ -120,8 +137,46 @@ vim .env # 使用你喜欢的文本编辑器修改配置文件
npm run dev
# 如果您是初次登陆,那么需要扫描二维码
```

> 请确保您的账号可以登陆 [网页版微信](https://wx.qq.com/)。

## 📝 Environment Variables

| name | default | example | description |
|------------------------------|------------------------|------------------------------------------------|-------------------------------------------------------------|
| ~~API~~ | https://api.openai.com | | ~~ChatGPT API 地址~~ |
| OPENAI_API_KEY | 123456789 | sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | [创建你的 API 密钥](https://platform.openai.com/account/api-keys) |
| MODEL | gpt-3.5-turbo | | 要使用的模型ID, 目前仅支持`gpt-3.5-turbo` 和 `gpt-3.5-turbo-0301` |
| TEMPERATURE | 0.6 | | 在0和2之间。较高的数值如0.8会使 ChatGPT 输出更加随机,而较低的数值如0.2会使其更加稳定。 |
| CHAT_TRIGGER_RULE | | | 私聊触发规则 |
| DISABLE_GROUP_MESSAGE | true | | 禁用在群聊里使用ChatGPT |
| CHAT_PRIVATE_TRIGGER_KEYWORD | | | 在私聊中触发ChatGPT的关键词, 默认是无需关键词即可触发 |
| BLOCK_WORDS | "VPN" | "WORD1,WORD2,WORD3" | 聊天屏蔽关键词(同时在群组和私聊中生效, 避免 bot 用户恶意提问导致封号 |
| CHATGPT_BLOCK_WORDS | "VPN" | "WORD1,WORD2,WORD3" | ChatGPT回复屏蔽词, 如果ChatGPT的回复中包含了屏蔽词, 则不回复 |

## 📝 使用自定义ChatGPT API
> https://github.com/fuergaosi233/openai-proxy
```shell
# 克隆项目
git clone https://github.com/fuergaosi233/openai-proxy
# 安装依赖
npm install && npm install -g wrangler && npm run build
# 部署到 CloudFlare Workers
npm run deploy
# 自定义域名(可选)
添加 `Route`` 到 `wrangler.toml`
routes = [
{ pattern = "Your Custom Domain", custom_domain = true },
]
```

## ⌨️ 命令
> 在微信聊天框中输入
```shell
/cmd help # 显示帮助信息
/cmd prompt <PROMPT> # 设置ChatGPT Prompt
/cmd clear # 清除WeChat-ChatGPT保存的会话记录
```

## ✨ Contributor

Expand All @@ -131,7 +186,8 @@ npm run dev

## 🤝 为项目添砖加瓦

欢迎提出 Contributions, issues 与 feature requests!<br />随时查看 [issues page](https://github.com/fuergaosi233/wechat-chatgpt/issues).
欢迎提出 Contributions, issues 与 feature requests!<br />
随时查看 [issues page](https://github.com/fuergaosi233/wechat-chatgpt/issues).

## 感谢支持 🙏

Expand Down
Loading