# 使用GPT-3.5 API创建的ChatGPT聊天页面,模型回复效果与官网的ChatGPT一致
## Star the [Repository](https://github.com/LiangYang666/ChatGPT-Web)
<details>
<summary>TODO List</summary>
- [ ] 界面优化
- [ ] 代码规范化,请求返回值规范、代码文件划分
- [x] 实现聊天记录文件下载,以及上传合并
- [x] 界面适应手机
- [x] 处理聊天记录更多由本地完成,即js完成聊天记录的请求
- [x] 添加token设置栏,按钮中设置
- [x] 在连续对话模式下支持多人同时使用
- [x] 重载历史记录
- [x] 切换聊天模式和重置时提示
- [x] 支持多对话管理
- [x] 公式显示
- [x] 流式拉取,逐字词动态实时显示
- [x] 代码高亮显示
- [x] 查余额
</details>
## 特性
> 极简配置
> 支持Zeabur云部署(推荐,两分钟部署完成)
> 支持railway云部署
> 支持多用户使用
> 多对话管理
> 公式显示
> 流式逐字加载显示
> 代码高亮
> 查余额
> 可设置访问密码
## 演示动图
![演示](https://user-images.githubusercontent.com/38237931/227176542-c924084c-8ceb-41cd-9e09-1f82e1d14366.gif)
## 使用前提
> 1. 因国内IP被封或OpenAI API被墙,因此自己需要有代理,稍后需要配置,(若使用railway部署时不需要有代理)
> 2. 有openai账号,注册事项可以参考[此文章](https://juejin.cn/post/7173447848292253704)
> 3. 创建好api_key, 进入[OpenAI链接](https://platform.openai.com/),右上角点击,进入页面设置
![image](https://user-images.githubusercontent.com/38237931/222461544-260ef350-2d05-486d-bf36-d078873b0f7a.png)
## 部署方法
分别介绍下面几种部署方法,选择一种即可,部署完成后直接跳转至后面的使用介绍继续即可
<details>
<summary>1. Zeabur云部署(最为推荐,无需代理,云部署,通过url随时随地访问,聊天记录云同步)</summary>
> - 关于Zeabur:Zeabur是云容器提供商,你能够使用它部署你的应用,并使用url链接随时随地访问你的应用,类似于Railway,但无时间限制
> 1. 首先将代码fork到你的github中
> 2. 点击网址注册账号,[Zeabur](zeabur.com) ,绑定GitHub账号
> 3. 进入[项目创建链接](https://dash.zeabur.com/projects),点击Create Project,输入名称 ChatGPT-Web创建项目
> 4. 创建完成后,点击如图,添加服务
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/eb9c8b10-de16-4cfe-906f-d5f64ccca693)
> 5. 弹出的界面中,点击如下
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/e8da843e-e4d0-4599-bdd1-9216ed6fdbdb)
> 6. 弹出界面中,左侧选择你的GitHub,如果未绑定,请授权Zeabur访问你GitHub的所有项目,搜索ChatGPT-Web,即你clone的仓库,点击Import
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/c462b508-e3e9-4d4a-9c81-2515b8242245)
> 7. 选择分支为main,点击部署
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/51a40409-fc65-430d-a97a-ce5a59642041)
> 8. 等待片刻后,将显示运行中,即部署完成,但此时还需要设置一些环境变量
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/59599caa-13bb-4806-bf77-22dcc7a745dc)
分别设置`DEPLOY_ON_ZEABUR`为`true`,`PORT`为`5000`,以及`OPENAI_API_KEY`设置为你的apikey即可,如为保证安全性,防止他人使用还可设置`PASSWORD`以及`ADMIN_PASSWORD`环境变量(可暂不设置,有需要再设),这两个环境变量分别代表普通访问密码,以及管理员密码,设置后用户访问网页时需要使用访问密码认证,而管理员密码用于下载以及合并所有用户的聊天记录时使用
> 9. 设置访问域名,url,点击如下,再填入可用主机名保存url即可,如自己有域名,也可绑定自己的域名
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/152e12d7-aecc-42dc-a6a2-0ac87a6e8391)
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/0dff69bf-ba48-478c-9898-80e3e698a9ec)
> 10. 点击redeploy重新部署,等待片刻后部署完成,一般一分钟以内部署完成,若未刷新可手动刷新网页查看,使用生成的url访问即可使用
![image](https://github.com/LiangYang666/ChatGPT-Web/assets/38237931/a00781f8-f594-4c35-9a61-a99162ef2552)
> 11. 使用new:xxx创建用户即可使用,或者上传已有聊天记录,相关使用方式见使用介绍
> 12. 请注意,当设置密码或其它环境变量时请在设置后重新部署,每次部署后都会清除聊天记录,可先下载好已有用户记录再重新部署
</details>
<details>
<summary>2. 本地源代码部署(推荐,方便更新,需要有代理)</summary>
> 前提:python3.7及以上运行环境
> 1. 执行 `pip install -r requirements.txt`安装必要包
> 2. 打开`config.yaml`文件,配置HTTPS_PROXY和OPENAI_API_KEY,相关细节已在配置文件中描述,如果在境外部署无需代理,将HTTPS_PROXY行删除即可
> 5. 执行`python main.py`运行程序.若程序中未指定apikey也可以在终端执行时添加环境变量,如执行`OPANAI_API_KEY=sk-XXXX python main.py`来运行,其中`sk-XXXX`为你的apikey
> 6. 打开本地浏览器访问`127.0.0.1:5000`,部署完成
> 7. 关于更新,当代码更新时,使用git pull更新重新部署即可
> 8. 使用linux开机自启动部署
> 执行`vim /etc/systemd/system/chatGpt.service`,编辑内容如下
```bash
[Unit]
Description=my chat-gpt web
After=syslog.target network.target
Wants=network.target
[Service]
Environment="ADMIN_PASSWORD=123456"
Environment="OPENAI_API_KEY=sk-***"
Environment="PASSWORD=123456"
Type=simple
User=nano
WorkingDirectory=/home/nano/Project/ChatGPT-Web
ExecStart=/usr/bin/python3 main.py
Restart= always
RestartSec=1min
[Install]
WantedBy=multi-user.target
```
最后启动
```bash
#启动
systemctl daemon-reload
systemctl start chatGpt.service
#设置为开机启动
systemctl enable chatGpt.service
```
</details>
<details>
<summary>3. Railway部署(无需代理,云部署,通过url随时随地访问)</summary>
> - 关于Railway:Railway是云容器提供商,你能够使用它部署你的应用,并使用url链接随时随地访问你的应用,Railway使用前提是你的GitHub账号满180天,绑定并验证后每月送5美元和500小时的使用时长,大概21天,因此如果使用这种方式需要在某些不使用的时段停止你的容器
> 1. 首先将代码fork到你的github中
> 2. 点击右侧[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new),然后选择`Deploy from GitHub repo`,再选择`Configure GitHub App`,将会弹出新的窗口,在该窗口中选择`Only select repositories`,然后到下拉列表中选择刚才fork到你账号的仓库
![image](https://user-images.githubusercontent.com/38237931/228179892-340ab8e5-dc20-4365-80bb-8ecc2568a4a8.png)
> 3. 授权完成后,`Configure GitHub App`下将会出现授权的项目
![image](https://user-images.githubusercontent.com/38237931/228181108-597230a2-49b6-4202-bacf-4dd3f9d3da92.png)
> 4. 不要点击立即部署,点击添加变量
![image](https://user-images.githubusercontent.com/38237931/228181839-c7fd4404-69ca-4800-bd43-ae1926e82650.png)
> 5. 将会跳转至新页面,依次添加`PORT`,`DEPLOY_ON_RAILWAY`以及`OPENAI_API_KEY`三个环境变量,相应值如下PORT为5000,DEPLOY_ON_RAILWAY为true
![image](https://user-images.githubusercontent.com/38237931/228186399-c2a1a802-7394-4c54-8148-057284e047b2.png)
> 6. 修改变
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 20 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/8b9566d6b7ee402eb11b3ab031c6660f_fl1768317420.jpg!1)
FL1768317420
- 粉丝: 4992
- 资源: 5748
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)