diff --git a/README.md b/README.md
index b2d1e48ce..0607950c2 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,15 @@
ChatGPT Next Web
+English / [简体中文](./README_CN.md)
+
One-Click to deploy well-designed ChatGPT web UI on Vercel.
一键免费部署你的私人 ChatGPT 网页应用。
-[演示 Demo](https://chat-gpt-next-web.vercel.app/) / [反馈 Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Join Discord](https://discord.gg/zrhvHCr79N) / [QQ 群](https://user-images.githubusercontent.com/16968934/231095592-330adc52-0337-4c13-8452-938ec169e367.jpeg) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa)
+[Demo](https://chat-gpt-next-web.vercel.app/) / [Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Join Discord](https://discord.gg/zrhvHCr79N) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa)
+
+[演示](https://chat-gpt-next-web.vercel.app/) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [QQ 群](https://user-images.githubusercontent.com/16968934/231095592-330adc52-0337-4c13-8452-938ec169e367.jpeg) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg)
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FYidadaa%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=chatgpt-next-web&repository-name=ChatGPT-Next-Web)
@@ -22,7 +26,7 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel.
- **Deploy for free with one-click** on Vercel in under 1 minute
- Privacy first, all data stored locally in the browser
- Responsive design, dark mode and PWA
-- Fast first screen loading speed (~100kb)
+- Fast first screen loading speed (~100kb), support streaming response
- Awesome prompts powered by [awesome-chatgpt-prompts-zh](https://github.com/PlexPt/awesome-chatgpt-prompts-zh) and [awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt-prompts)
- Automatically compresses chat history to support long conversations while also saving your tokens
- One-click export all chat history with full Markdown support
@@ -45,7 +49,7 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel.
- 在 1 分钟内使用 Vercel **免费一键部署**
- 精心设计的 UI,响应式设计,支持深色模式,支持 PWA
-- 极快的首屏加载速度(~100kb)
+- 极快的首屏加载速度(~100kb),支持流式响应
- 隐私安全,所有数据保存在用户浏览器本地
- 海量的内置 prompt 列表,来自[中文](https://github.com/PlexPt/awesome-chatgpt-prompts-zh)和[英文](https://github.com/f/awesome-chatgpt-prompts)
- 自动压缩上下文聊天记录,在节省 Token 的同时支持超长对话
@@ -76,7 +80,9 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel.
## FAQ
-[简体中文 > 常见问题](./docs/faq-cn.md) | [English > FAQ](./docs/faq.en.md)
+[简体中文 > 常见问题](./docs/faq-cn.md)
+
+[English > FAQ](./docs/faq-en.md)
## Keep Updated
@@ -86,13 +92,18 @@ If you have deployed your own project with just one click following the steps ab
We recommend that you follow the steps below to re-deploy:
-- Delete the original repo;
-- Fork this project;
-- Go to the Vercel dashboard, delete the original project, then create a new project and select the project you just forked to redeploy;
-- Please manually add an environment variable named `OPENAI_API_KEY` and enter your API key as the value during the redeploy process.
+- Delete the original repository;
+- Use the fork button in the upper right corner of the page to fork this project;
+- Choose and deploy in Vercel again, [please see the detailed tutorial](./docs/vercel-cn.md).
-This project will be continuously updated, and after forking the project, the upstream code will be automatically synchronized every day without additional operations.
+### Enable Automatic Updates
+After forking the project, due to the limitations imposed by Github, you need to manually enable Workflows and Upstream Sync Action on the Actions page of the forked project. Once enabled, automatic updates will be scheduled every hour:
+
+
+
+
+### Manually Updating Code
If you want to update instantly, you can check out the [Github documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) to learn how to synchronize a forked project with upstream code.
You can star or watch this project or follow author to get release notifictions in time.
diff --git a/README_CN.md b/README_CN.md
index 0833ae1ac..db08ee445 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -38,12 +38,18 @@
如果你按照上述步骤一键部署了自己的项目,可能会发现总是提示“存在更新”的问题,这是由于 Vercel 会默认为你创建一个新项目而不是 fork 本项目,这会导致无法正确地检测更新。
推荐你按照下列步骤重新部署:
-- 删除掉原先的 repo;
-- fork 本项目;
-- 前往 vercel 控制台,删除掉原先的 project,然后新建 project,选择你刚刚 fork 出来的项目重新进行部署即可;
-- 在重新部署的过程中,请手动添加名为 `OPENAI_API_KEY` 的环境变量,并填入你的 api key 作为值。
+- 删除掉原先的仓库;
+- 使用页面右上角的 fork 按钮,fork 本项目;
+- 在 Vercel 重新选择并部署,[请查看详细教程](./docs/vercel-cn.md#如何新建项目)。
-本项目会持续更新,当你 Fork 项目之后,默认会每天自动同步上游代码,无需额外操作。
+### 打开自动更新
+当你 fork 项目之后,由于 Github 的限制,需要手动去你 fork 后的项目的 Actions 页面启用 Workflows,并启用 Upstream Sync Action,启用之后即可开启每小时定时自动更新:
+
+
+
+
+
+### 手动更新代码
如果你想让手动立即更新,可以查看 [Github 的文档](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) 了解如何让 fork 的项目与上游代码同步。
diff --git a/app/requests.ts b/app/requests.ts
index 3d559e369..86d180f71 100644
--- a/app/requests.ts
+++ b/app/requests.ts
@@ -171,10 +171,15 @@ export async function requestChatStream(
const resTimeoutId = setTimeout(() => finish(), TIME_OUT_MS);
const content = await reader?.read();
clearTimeout(resTimeoutId);
- const text = decoder.decode(content?.value, { stream: true });
+
+ if (!content || !content.value) {
+ break;
+ }
+
+ const text = decoder.decode(content.value, { stream: true });
responseText += text;
- const done = !content || content.done;
+ const done = content.done;
options?.onMessage(responseText, false);
if (done) {
diff --git a/docs/faq-cn.md b/docs/faq-cn.md
index 7a71e75d8..6251889ca 100644
--- a/docs/faq-cn.md
+++ b/docs/faq-cn.md
@@ -6,6 +6,8 @@
# 部署相关问题
+各种部署方式详细教程参考:https://rptzik3toh.feishu.cn/docx/XtrdduHwXoSCGIxeFLlcEPsdn8b
+
## 为什么 Docker 部署版本一直提示更新
Docker 版本相当于稳定版,latest Docker 总是与 latest release version 一致,目前我们的发版频率是一到两天发一次,所以 Docker 版本会总是落后最新的提交一到两天,这在预期内。
@@ -51,6 +53,18 @@ keepalive_timeout 300; # 设定keep-alive超时时间为65秒
- 到服务器的路由通吗?
- 域名正确解析了吗?
+## 什么是代理,如何使用?
+由于OpenAI的IP限制,中国和其他一些国家/地区无法直接连接OpenAI API,需要通过代理。你可以使用代理服务器(正向代理),或者已经设置好的OpenAI API反向代理。
+- 正向代理例子:科学上网梯子。docker部署的情况下,设置环境变量HTTP_PROXY为你的代理地址(例如:10.10.10.10:8002)。
+- 反向代理例子:可以用别人搭建的代理地址,或者通过Cloudflare免费设置。设置项目环境变量BASE_URL为你的代理地址。
+
+## 国内服务器可以部署吗?
+可以但需要解决的问题:
+- 需要代理才能连接github和openAI等网站;
+- 国内服务器要设置域名解析的话需要备案;
+- 国内政策限制代理访问外网/ChatGPT相关应用,可能被封。
+
+
# 使用相关问题
## 为什么会一直提示“出错了,稍后重试吧”
@@ -69,17 +83,6 @@ keepalive_timeout 300; # 设定keep-alive超时时间为65秒
## 使用时提示"You exceeded your current quota, ..."
API KEY有问题。余额不足。
-## 什么是代理,如何使用?
-由于OpenAI的IP限制,中国和其他一些国家/地区无法直接连接OpenAI API,需要通过代理。你可以使用代理服务器(正向代理),或者已经设置好的OpenAI API反向代理。
-- 正向代理例子:科学上网梯子。docker部署的情况下,设置环境变量HTTP_PROXY为你的代理地址(http://地址:端口)。
-- 反向代理例子:可以用别人搭建的代理地址,或者通过Cloudflare免费设置。设置项目环境变量BASE_URL为你的代理地址。
-
-## 国内服务器可以部署吗?
-可以但需要解决的问题:
-- 需要代理才能连接github和openAI等网站;
-- 国内服务器要设置域名解析的话需要备案;
-- 国内政策限制代理访问外网/ChatGPT相关应用,可能被封。
-
# 网络服务相关问题
## Cloudflare是什么?
Cloudflare(CF)是一个提供CDN,域名管理,静态页面托管,边缘计算函数部署等的网络服务供应商。常见的用途:购买和/或托管你的域名(解析、动态域名等),给你的服务器套上CDN(可以隐藏ip免被墙),部署网站(CF Pages)。CF免费提供大多数服务。
@@ -98,6 +101,17 @@ Vercel 是一个全球化的云平台,旨在帮助开发人员更快地构建
- 国内服务器供应商:阿里云,腾讯等;
国内服务器事项:解析域名需要备案;国内服务器带宽较贵;访问国外网站(Github, openAI等)需要代理。
+## 什么情况下服务器要备案?
+在中国大陆经营的网站按监管要求需要备案。实际操作中,服务器位于国内且有域名解析的情况下,服务器供应商会执行监管的备案要求,否则会关停服务。通常的规则如下:
+|服务器位置|域名供应商|是否需要备案|
+|---|---|---|
+|国内|国内|是|
+|国内|国外|是|
+|国外|国外|否|
+|国外|国内|通常否|
+
+换服务器供应商后需要转备案。
+
# OpenAI相关问题
## 如何注册OpenAI账号?
去chat.openai.com注册。你需要:
@@ -135,3 +149,17 @@ OpenAI只接受指定地区的信用卡(中国信用卡无法使用)。一
- 通过上述两个方法就可以定位到你的 token 被快速消耗的原因:
- 如果 openai 消费记录异常,但是 docker 日志没有问题,那么说明是 api key 泄露;
- 如果 docker 日志发现大量 got access code 爆破记录,那么就是密码被爆破了。
+
+## API是怎么计费的?
+OpenAI网站计费说明:https://openai.com/pricing#language-models
+OpenAI根据token数收费,1000个token通常可代表750个英文单词,或500个汉字。输入(Prompt)和输出(Completion)分别统计费用。
+|模型|用户输入(Prompt)计费|模型输出(Completion)计费|每次交互最大token数|
+|----|----|----|----|
+|gpt-3.5|$0.002 / 1千tokens|$0.002 / 1千tokens|4096|
+|gpt-4|$0.03 / 1千tokens|$0.06 / 1千tokens|8192|
+|gpt-4-32K|$0.06 / 1千tokens|$0.12 / 1千tokens|32768|
+
+## gpt-3.5-turbo和gpt3.5-turbo-0301(或者gpt3.5-turbo-mmdd)模型有什么区别?
+官方文档说明:https://platform.openai.com/docs/models/gpt-3-5
+- gpt-3.5-turbo是最新的模型,会不断得到更新。
+- gpt-3.5-turbo-0301是3月1日定格的模型快照,不会变化,预期3个月后被新快照替代。
diff --git a/docs/faq.en.md b/docs/faq-en.md
similarity index 100%
rename from docs/faq.en.md
rename to docs/faq-en.md
diff --git a/docs/images/enable-actions-sync.jpg b/docs/images/enable-actions-sync.jpg
new file mode 100644
index 000000000..4a69da928
Binary files /dev/null and b/docs/images/enable-actions-sync.jpg differ
diff --git a/docs/images/enable-actions.jpg b/docs/images/enable-actions.jpg
new file mode 100644
index 000000000..a4f4f0f1f
Binary files /dev/null and b/docs/images/enable-actions.jpg differ
diff --git a/docs/images/vercel/vercel-create-1.jpg b/docs/images/vercel/vercel-create-1.jpg
new file mode 100644
index 000000000..f0bbd0028
Binary files /dev/null and b/docs/images/vercel/vercel-create-1.jpg differ
diff --git a/docs/images/vercel/vercel-create-2.jpg b/docs/images/vercel/vercel-create-2.jpg
new file mode 100644
index 000000000..157768a88
Binary files /dev/null and b/docs/images/vercel/vercel-create-2.jpg differ
diff --git a/docs/images/vercel/vercel-create-3.jpg b/docs/images/vercel/vercel-create-3.jpg
new file mode 100644
index 000000000..2eaae1f9f
Binary files /dev/null and b/docs/images/vercel/vercel-create-3.jpg differ
diff --git a/docs/images/vercel/vercel-env-edit.jpg b/docs/images/vercel/vercel-env-edit.jpg
new file mode 100644
index 000000000..5b115935e
Binary files /dev/null and b/docs/images/vercel/vercel-env-edit.jpg differ
diff --git a/docs/images/vercel/vercel-redeploy.jpg b/docs/images/vercel/vercel-redeploy.jpg
new file mode 100644
index 000000000..ee3483fa7
Binary files /dev/null and b/docs/images/vercel/vercel-redeploy.jpg differ
diff --git a/docs/vercel-cn.md b/docs/vercel-cn.md
new file mode 100644
index 000000000..c49229694
--- /dev/null
+++ b/docs/vercel-cn.md
@@ -0,0 +1,39 @@
+# Vercel 的使用说明
+
+## 如何新建项目
+当你从 Github fork 本项目之后,需要重新在 Vercel 创建一个全新的 Vercel 项目来重新部署,你需要按照下列步骤进行。
+
+
+1. 进入 Vercel 控制台首页;
+2. 点击 Add New;
+3. 选择 Project。
+
+
+1. 在 Import Git Repository 处,搜索 chatgpt-next-web;
+2. 选中新 fork 的项目,点击 Import。
+
+
+1. 在项目配置页,点开 Environmane Variables 开始配置环境变量;
+2. 依次新增名为 OPENAI_API_KEY 和 CODE 的环境变量;
+3. 填入环境变量对应的值;
+4. 点击 Add 确认增加环境变量;
+5. 请确保你添加了 OPENAI_API_KEY,否则无法使用;
+6. 点击 Deploy,创建完成,耐心等待 5 分钟左右部署完成。
+
+## 如何增加自定义域名
+[TODO]
+
+## 如何更改环境变量
+
+1. 进去 Vercel 项目内部控制台,点击顶部的 Settings 按钮;
+2. 点击左侧的 Environment Variables;
+3. 点击已有条目的右侧按钮;
+4. 选择 Edit 进行编辑,然后保存即可。
+
+⚠️️ 注意:每次修改完环境变量,你都需要[重新部署项目](#如何重新部署)来让改动生效!
+
+## 如何重新部署
+
+1. 进入 Vercel 项目内部控制台,点击顶部的 Deployments 按钮;
+2. 选择列表最顶部一条的右侧按钮;
+3. 点击 Redeploy 即可重新部署。
\ No newline at end of file