Skip to content

Commit

Permalink
Auto-translate README
Browse files Browse the repository at this point in the history
  • Loading branch information
Continuous Integration committed Sep 27, 2023
1 parent 711636c commit a6c936e
Show file tree
Hide file tree
Showing 3 changed files with 422 additions and 57 deletions.
111 changes: 55 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,126 +2,125 @@

Join the [Telegram Group](https://t.me/+_01cz9tAkUc1YzZl) chat to share your user experience or report Bugs.

[英文](./README.md) | [简体中文](./README.zh-CN.md)[繁体中文](./README.zh-TW.md)
[English](./README.md) | [Simplified Chinese](./README.zh-CN.md)[Traditional Chinese](./README.zh-TW.md)

## ✨ Features

支持 ChatGPT GPT4 API
Supports ChatGPT and GPT4 API

支持 duckduckgo,Google 联网搜索🔍。默认提供 duckduckgo 搜索,google 搜索需要自行申请官方 API。可以回答之前 gpt 回答不了的实时信息,比如今天的微博热搜,今天某地的天气,某某人或新闻的进展
Supports online search using duckduckgo and Google🔍. DuckDuckGo search is provided by default, and the official API for Google search needs to be applied by the user. It can provide real-time information that GPT could not answer before, such as Weibo hot search today, weather in a certain place today, and the progress of a certain person or news.

支持基于嵌入向量数据库的文档问答。在搜索中,对于搜索到的 pdf,可以自动对 PDF 文档进行向量化语义搜索,并基于向量数据库提取 pdf 相关的内容。支持使用 qa 命令对含有 sitemap.xml 文件的网站整体向量化,并基于向量数据库回答问题,特别适合一些项目的文档网站,wiki 网站
Supports document QA based on the embedded vector database. In the search, for the searched PDF, automatic vector semantic search of PDF documents is performed, and pdf-related content is extracted based on the vector database. Supports using the "qa" command to vectorize the entire website with the "sitemap.xml" file, and answer questions based on the vector database, which is especially suitable for document websites and wiki websites of some projects.

支持在聊天框内使用 info 命令通过点击按钮自由切换 gpt3.5,gpt4 等模型
Supports switching between GPT3.5, GPT4 and other models through the "info" command in the chat window

异步处理消息,多线程回答问题,支持对话隔离,不同用户不同对话
Asynchronously processes messages, multi-threadedly answers questions, supports isolated dialogues, and different users have different dialogues

支持精准的消息 Markdown 渲染,用的是我的另一个[项目](https://github.com/yym68686/md2tgmd)
Supports accurate Markdown rendering of messages, using another [project](https://github.com/yym68686/md2tgmd) of mine

支持流式输出,实现打字机效果
Supports streaming output, achieving typewriter effect

支持白名单,防止滥用与信息泄漏
Supports whitelisting to prevent abuse and information leakage

全平台,随时随地,只要有 telegram 就可以打破知识壁垒
Cross-platform, breaking knowledge barriers anytime and anywhere with Telegram

支持一键 ZeaburReplit 部署,真正的零成本,傻瓜式部署,支持 kuma 防睡眠。同时支持 docker,fly.io 部署
Supports one-click Zeabur, Replit deployment, true zero cost, idiotic deployment, and supports kuma anti-sleep. Also supports Docker, fly.io deployment

## 环境变量
## Environment variables

| 变量名称 | 备注 |
| Variable Name | Comment |
| ---------------------- | ------------------------------------------------------------ |
| **BOT_TOKEN(必填)** | telegram 机器人令牌,在 [BotFather](https://t.me/BotFather) 创建一个 bot 以获取 BOT_TOKEN。 |
| **WEB_HOOK(必填)** | telegram bot 每次收到用户消息,都会把消息传给 WEB_HOOK,机器人会在此监听,及时处理 telegram 里面收到的消息。 |
| **API(必填)** | OpenAI 或者第三方的 api key。 |
| API_URL(可选) | 如果使用 OpenAI 官方 API,不需要设置此项。如果使用第三方API,需要填写第三方代理网址,默认值为:https://api.openai.com/v1/chat/completions |
| GPT_ENGINE(可选) | 设置默认的问答模型,默认为:`gpt-3.5-turbo`,该项可以使用机器人 info 命令自由切换,原则上不需要设置。 |
| NICK(可选) | 默认为空,NICK 是机器人的名字。当用户输入消息以 NICK 开头,机器人才会回答,否则机器人会回答任何消息。尤其在群聊里,没有 NICK,机器人会对所有消息进行回复。 |
| PASS_HISTORY(可选) | 默认为真,表示机器人会记住对话历史,下次回复时会考虑上下文。如果设置为假,机器人会忘记对话历史,只考虑当前对话。 |
| GOOGLE_API_KEY(可选) | 如果需要谷歌搜索,则需要设置。如果不设置此环境变量,机器人默认提供 duckduckgo 搜索。在 Google cloud 的 [API 与服务](https://console.cloud.google.com/apis/api/customsearch.googleapis.com) 中创建凭据,在凭据页面 API Key 就是 GOOGLE_API_KEY。Google 搜索一天可以查询 100 次,轻度使用完全足够,达到限额,机器人会自动关闭 Google 搜索。 |
| GOOGLE_CSE_ID(可选) | 如果需要谷歌搜索,则需要与 GOOGLE_API_KEY 一起设置。在[可编程搜索引擎](https://programmablesearchengine.google.com/) 中新建搜索引擎,其中 搜索引擎 ID 就是 GOOGLE_CSE_ID 的值。 |
| whitelist(可选) | 设置哪些用户可以访问机器人,将授权使用机器人的用户 ID 用`,`连接起来。默认值为`None`,即对所有人开放机器人。 |

## Zeabur 远程部署 (推荐)

一键部署:

| **BOT_TOKEN (required)** | Telegram bot token. Create a bot on [BotFather](https://t.me/BotFather) to get the BOT_TOKEN. |
| **WEB_HOOK (required)** | Whenever the telegram bot receives a user message, the message will be passed to WEB_HOOK, where the bot will listen to it and process the received messages in a timely manner. |
| **API (required)** | OpenAI or third-party API key. |
| API_URL(optional) | If you are using the OpenAI official API, you don't need to set this. If you using a third-party API, you need to fill in the third-party proxy website. The default is: https://api.openai.com/v1/chat/completions |
| GPT_ENGINE (optional) | Set the default QA model; the default is:`gpt-3.5-turbo`. This item can be freely switched using the bot's "info" command, and it doesn't need to be set in principle. |
| NICK (optional) | The default is empty, and NICK is the name of the bot. The bot will only respond when the message starts with NICK that the user inputs, otherwise the bot will respond to any message. Especially in group chats, if there is no NICK, the bot will reply to all messages. |
| PASS_HISTORY (optional) | The default is true. The bot remembers the conversation history and considers the context when replying next time. If set to false, the bot will forget the conversation history and only consider the current conversation. |
| GOOGLE_API_KEY (optional)| If you need to use Google search, you need to set it. If you do not set this environment variable, the bot will default to provide duckduckgo search. Create credentials in Google Cloud's [APIs & Services](https://console.cloud.google.com/apis/api/customsearch.googleapis.com) and the API Key will be GOOGLE_API_KEY on the credentials page. Google search can be queried 100 times a day, which is completely sufficient for light use. When the usage limit has been reached, the bot will automatically turn off Google search. |
| GOOGLE_CSE_ID (optional) | If you need to use Google search, you need to set it together with GOOGLE_API_KEY. Create a search engine in [Programmable Search Engine](https://programmablesearchengine.google.com/), where the search engine ID is the value of GOOGLE_CSE_ID. |
| whitelist (optional) | Set which users can access the bot, and connect the user IDs authorized to use the bot with ','. The default value is `None`, which means that the bot is open to everyone. |

## Zeabur Remote Deployment (Recommended)

One-click deployment:
[![Deploy on Zeabur](https://zeabur.com/button.svg)](https://zeabur.com/templates/R5JY5O?referralCode=yym68686)

如果需要后续功能更新,则推荐以下部署方式:
If you need follow-up function updates, the following deployment method is recommended:

先 fork 本仓库,再注册 [Zeabur](https://zeabur.com),免费额度足够轻度使用,从自己的 Github 仓库导入,设置好域名(必须与 WEB_HOOK 一致)和环境变量后,重新部署即可。后续需要功能更新只需要在自己的仓库里同步本仓库并在 Zeabur 重新部署即可获得最新功能。
Fork this repository first, then register for [Zeabur](https://zeabur.com). The free quota is sufficient for light use. Import from your own Github repository, set the domain name (which must be consistent with WEB_HOOK) and environment variables, and redeploy. If you need function updates in the follow-up, just synchronize this repository in your own repository and redeploy in Zeabur to get the latest functions.

## Replit 远程部署
## Replit Remote Deployment

[![Run on Repl.it](https://replit.com/badge/github/yym68686/ChatGPT-Telegram-Bot)](https://replit.com/new/github/yym68686/ChatGPT-Telegram-Bot)

导入 Github 仓库后,设置运行命令
After importing the Github repository, set the running command

```bash
pip install -r requirements.txt > /dev/null && python3 main.py
```

在左边栏 Tools 里面选择 Secrets,添加机器人需要的环境变量,其中:
Select Secrets in the Tools sidebar, add the environment variables required by the bot, where:

- WEB_HOOK: 在 Replit 会自动分配一个域名给你,填入 `https://appname.username.repl.co`
- WEB_HOOK: Replit will automatically assign a domain name to you, fill in `https://appname.username.repl.co`
- Remember to open "Always On"

点击屏幕上方的 run,即可运行机器人。记得打开 Always On。
Click the run button on the top of the screen to run the bot.

## fly.io 远程部署
## fly.io Remote Deployment

官方文档:https://fly.io/docs/
Official documentation: https://fly.io/docs/

使用 Docker 镜像部署 fly.io 应用
Use Docker image to deploy fly.io application

```bash
flyctl launch --image yym68686/chatgpt:1.0
```

输入应用的名字,若提示初始化 Postgresql Redis,一律选择否。
Enter the name of the application when prompted, and select No for initializing Postgresql or Redis.

按照提示部署。在官网控制面板会提供一个二级域名,可以使用这个二级域名访问到服务。
Follow the prompts to deploy. A secondary domain name will be provided in the official control panel, which can be used to access the service.

设置环境变量
Set environment variables

```bash
flyctl secrets set WEB_HOOK=https://flyio-app-name.fly.dev/
flyctl secrets set BOT_TOKEN=bottoken
flyctl secrets set API=
flyctl secrets set COOKIES=
# 可选
# optional
flyctl secrets set NICK=javis
```

查看所有环境变量
View all environment variables

```bash
flyctl secrets list
```

移除环境变量
Remove environment variables

```bash
flyctl secrets unset MY_SECRET DATABASE_URL
```

ssh 连接 fly.io 容器
ssh to fly.io container

```bash
# 生成密钥
flyctl ssh issue --agent
# ssh 连接
# ssh connection
flyctl ssh establish
```

查看 webhook url 是否正确
Check whether the webhook URL is correct

```
```bash
https://api.telegram.org/bot<token>/getWebhookInfo
```

## Docker 本地部署
## Docker Local Deployment

启动容器
Start the container

```bash
docker run -p 80:8080 -dit \
Expand All @@ -132,7 +131,7 @@ docker run -p 80:8080 -dit \
yym68686/chatgpt:1.0
```

或者你想使用 Docker Compose,下面是 docker-compose.yml 示例:
Or if you want to use Docker Compose, here is a docker-compose.yml example:

```yaml
version: "3.5"
Expand All @@ -149,13 +148,13 @@ services:
- 80:8080
```
后台运行 Docker Compose 容器
Run Docker Compose container in the background
```bash
docker-compose up -d
```

仓库打包 Docker 镜像,推送到 Docker Hub
Package the Docker image in the repository and upload it to Docker Hub

```bash
docker build --no-cache -t chatgpt:1.0 -f Dockerfile.build --platform linux/amd64 .
Expand All @@ -165,7 +164,7 @@ docker push yym68686/chatgpt:1.0

## Reference

参考项目:
Reference Projects:

https://core.telegram.org/bots/api

Expand All @@ -175,7 +174,7 @@ https://github.com/franalgaba/chatgpt-telegram-bot-serverless

https://github.com/gpchelkin/scdlbot/blob/d64d14f6c6d357ba818e80b8a0a9291c2146d6fe/scdlbot/__main__.py#L8

消息的 markdown 渲染用的是我的另一个项目:https://github.com/yym68686/md2tgmd
The markdown rendering of the message used is another [project](https://github.com/yym68686/md2tgmd) of mine.

## Star History

Expand Down
Loading

0 comments on commit a6c936e

Please sign in to comment.