Skip to content

Commit

Permalink
20230325 (#4)
Browse files Browse the repository at this point in the history
* chore: change docs

* feat: 添加 Prompt 模板和 Prompt 商店支持 (Chanzhaoyu#268)

* feat: 添加Prompt模板和Prompt商店支持

* feat: well done

---------

Co-authored-by: Redon <[email protected]>

* feat: 设置添加关闭按钮

* chore: format

* chore: 2.10.4

* chore: cover

* fix: 更新JSON导入检查 (Chanzhaoyu#523)

* feat: Improve zh-TW locale (Chanzhaoyu#511)

* fix: cors in auth_secret_key model (Chanzhaoyu#499)

* fix: 修改最大行数与官方保持一致 (Chanzhaoyu#502)

* chore: rename environment variables files

* docs: update README.md about .env file

* feat: support long reply

* chore: upgrade chatgpt package and set long reply to false default

* chore: set long reply to false default

* fix: change maxRows to 8

* feat: mobile max row

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* feat: support linux command line proxy standard (Chanzhaoyu#308)

* feat: support linux command line proxy standard with env HTTPS_PROXY and ALL_PROXY

* chore: update docs for linux command linux proxy standard

* fix: Prompt商店在线导入可以导入两种recommend.json里提到的模板 (Chanzhaoyu#516) (Chanzhaoyu#521)

* fix(PromptStore): import prompt template using different dict keys

* chore(PromptStore): clear url field after downloading

* feat: 仓库添加翻译

* feat: 仓库查询筛选

* feat: 调整界面

* chore: update deps

* feat: improve zh-TW locale, translate new strings (Chanzhaoyu#542)

* feat: 语言设定改为下拉框选择

* feat: 修改 Prompt Store 移动端样式

* chore: docs change

* feat: 权限输入框改为密码类型

* fix: 清空上下文时不应该重置会话标题

* chore: docs change

* chore: optimize dockerfile to speed up building and reduce docker image size (Chanzhaoyu#520)

* chore: v2.10.5

* fix: 修复导入、导出错误

* fix: inverted parameter for before each function (Chanzhaoyu#585)

* fix: 🐛 fix scroll bar style (Chanzhaoyu#617)

* fix: typo (Chanzhaoyu#636)

* perf: 优化移动端 prompt 商店样式 (Chanzhaoyu#608)

* feat: 修改移动端 prompt 商店样式

* add: 修改移动端 prompt 商店样式

* perf: 清理代码

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* chore: extract proxy setup code into reusable function (Chanzhaoyu#583)

* perf: 记录上下文设定保存到本地

* perf: 优化部份判断

* docs: 移除 docker-compose.yml 省略

* feat: show api balance (Chanzhaoyu#582)

* feat: show api balance

* Update index.ts

* 保留小数点后五位

* perf: 判断优化

---------

Co-authored-by: Redon <[email protected]>

* chore: update deps and lint fix

* feat: session 返回接口方式做显示判断

* fix: highlight.js 控制台兼容性警告

* chore: v2.10.6

* fix: 回退 chatgpt 版本导致的代理失效

* fix: 添加 usingContext 缺省

* chore: v2.10.7

* feat: 查询余额使用 API_BASE_URL 参数

* feat: 渲染的链接新窗口打开

* perf: config 接口添加权限验证

* fix: 手动重置异常的 loading

* feat: 添加用于显示回复消息原文的选项 (Chanzhaoyu#672)

* feat: 添加显示用于原文的选项

* chore: 修复暗色主题下文本颜色问题

给输入和输出气泡添加了 css 类,用来处理在暗色主题下聊天气泡的文本颜色

* feat: 用户输入不应该被渲染,防止 xss

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* feat: 新增限流功能 (Chanzhaoyu#718)

* 请求速率限制

* perf: 优化代码

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* feat: 添加角色设定预留API 设定页(Chanzhaoyu#768)

* add systemMessage

* perf: 优化代码和类型

* perf: 补全翻译和为以后做准备

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* perf: 重置回答时滚动定位至该回答 (Chanzhaoyu#781)

* chore: 重置回答时滚动定位至该回答

* perf: format code

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* perf: scrollToBottom 改成 scrollToBottomIfAtBottom (Chanzhaoyu#771)

* feat: 更新依赖并兼容已存在的代理

* feat: 当用gpt-4的API 时增加可用的 Max Tokens (Chanzhaoyu#729)

* fix: 用GPT-4 API时增加max token

* style: eslint fix

---------

Co-authored-by: Redon <[email protected]>

* feat: Create start.cmd (Chanzhaoyu#656)

在windows下也可以运行

* chore(vsc-debug): 增加 visual-studio-code 的 debug 启动文件 (Chanzhaoyu#296)

* fix line end with new-line in some backend (Chanzhaoyu#474)

* fix line end with new-line in some backend

In backend with golang (like https://github.com/sashabaranov/go-openai), the responseText always has '\n'.

* feat: 补全遗漏

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* feat: 增加 ChatGPTUnofficialProxyAPI 的模型自定义配置 (Chanzhaoyu#632)

* feat: 增加 ChatGPTUnofficialProxyAPI 的模型自定义配置(Chanzhaoyu#618)

* perf: 修改判断

---------

Co-authored-by: ChenZhaoYu <[email protected]>

* chore: 显示原文时使用 .whitespace-pre-wrap (Chanzhaoyu#779)

显示 ChatGPT 输出的原文时保留空格和换行

* feat:  PWA 默认不开启

* feat:  切换 history 时自动聚焦输入框 (Chanzhaoyu#735)

* feat: 修改 scrollToBottom 行为(当滚动条在底部或发送问题时才会进入自动滚动,滚轮向上滚动会中止自动滚动,方便复制和查看之前的代码; 切换 history 时自动聚焦输入框,方便直接输入文字,不用再次去点击输入框;)

* chore: 通过eslint检查

* perf: 清理重复功能

---------

Co-authored-by: Redon <[email protected]>

* perf: 网络连接时 500 自动跳转到主页

* docs: fix docker port to private (Chanzhaoyu#802)

* feat: add zh-TW prompts in the Promt Store (Chanzhaoyu#796)

* fix: prompt store 样式问题

* chore: v2.10.8

* fix: 重置时应该移除本地储存

* fix: PWA 未添加的问题 (Chanzhaoyu#807)

Co-authored-by: bingo235 <>

* fix: 移动端新建会话关闭侧边栏 (Chanzhaoyu#813)

* perf: 移动端删除 chat 时,侧边栏应该收起

* fix: ESM error (Chanzhaoyu#826)

* perf: 自动焦点时移动端上的不便

* fix: 移动端焦点不触发的问题

* perf: 本地地址

* fix: 反向代理限流失效 (Chanzhaoyu#863)

https://docs.colyseus.io/zh_hk/colyseus/how-to/rate-limit/

使用nginx限流会只识别为服务器ip,需启用trust proxy

---------

Co-authored-by: ChenZhaoYu <[email protected]>
Co-authored-by: Nothing1024 <[email protected]>
Co-authored-by: Peter Dave Hello <[email protected]>
Co-authored-by: Yige <[email protected]>
Co-authored-by: Eason <[email protected]>
Co-authored-by: 吴杉(Shan Wu) <[email protected]>
Co-authored-by: Wisdom <[email protected]>
Co-authored-by: Hayden Chen <[email protected]>
Co-authored-by: 碎花爱洋裙 <[email protected]>
Co-authored-by: CornerSkyless <[email protected]>
Co-authored-by: Kirk Lin <[email protected]>
Co-authored-by: pzcn <[email protected]>
Co-authored-by: Yi <[email protected]>
Co-authored-by: xiaozhu <[email protected]>
Co-authored-by: quzard <[email protected]>
Co-authored-by: 舜岳 <[email protected]>
Co-authored-by: 吴杉(Shan Wu) <[email protected]>
Co-authored-by: vulgate <[email protected]>
Co-authored-by: KeepRunning <[email protected]>
Co-authored-by: Liut <[email protected]>
Co-authored-by: hncboy <[email protected]>
Co-authored-by: Allen <[email protected]>
Co-authored-by: 东子 <[email protected]>
Co-authored-by: Bing <[email protected]>
Co-authored-by: Kid <[email protected]>
Co-authored-by: gitgitgogogo <[email protected]>
  • Loading branch information
1 parent 3c36e00 commit 2953435
Show file tree
Hide file tree
Showing 64 changed files with 1,681 additions and 324 deletions.
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Glob API URL
VITE_GLOB_API_URL=/api

VITE_APP_API_BASE_URL=http://localhost:3002/
VITE_APP_API_BASE_URL=http://127.0.0.1:3002/

# Whether long replies are supported, which may result in higher API fees
VITE_GLOB_OPEN_LONG_REPLY=false

# When you want to use PWA
VITE_GLOB_APP_PWA=false
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Web App",
"url": "http://localhost:1002",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Service Server",
"runtimeExecutable": "${workspaceFolder}/service/node_modules/.bin/esno",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/service/src/index.ts",
"outFiles": ["${workspaceFolder}/service/**/*.js"],
"envFile": "${workspaceFolder}/service/.env"
}
]
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"linkify",
"logprobs",
"mdhljs",
"mila",
"nodata",
"OPENAI",
"pinia",
Expand Down
111 changes: 111 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,114 @@
## v2.10.8

`2023-03-23`

如遇问题,请删除 `node_modules` 重新安装依赖。

## Feature
- 显示回复消息原文的选项 [[yilozt](https://github.com/Chanzhaoyu/chatgpt-web/pull/672)]
- 添加单 `IP` 每小时请求限制。环境变量: `MAX_REQUEST_PER_HOUR` [[zhuxindong ](https://github.com/Chanzhaoyu/chatgpt-web/pull/718)]
- 前端添加角色设定,仅 `API` 方式可见 [[quzard](https://github.com/Chanzhaoyu/chatgpt-web/pull/768)]
- `OPENAI_API_MODEL` 变量现在对 `ChatGPTUnofficialProxyAPI` 也生效,注意:`Token``API` 的模型命名不一致,不能直接填入 `gpt-3.5` 或者 `gpt-4` [[hncboy](https://github.com/Chanzhaoyu/chatgpt-web/pull/632)]
- 添加繁体中文 `Prompts` [[PeterDaveHello](https://github.com/Chanzhaoyu/chatgpt-web/pull/796)]

## Enhancement
- 重置回答时滚动定位至该回答 [[shunyue1320](https://github.com/Chanzhaoyu/chatgpt-web/pull/781)]
-`API``gpt-4` 时增加可用的 `Max Tokens` [[simonwu53](https://github.com/Chanzhaoyu/chatgpt-web/pull/729)]
- 判断和忽略回复字符 [[liut](https://github.com/Chanzhaoyu/chatgpt-web/pull/474)]
- 切换会话时,自动聚焦输入框 [[JS-an](https://github.com/Chanzhaoyu/chatgpt-web/pull/735)]
- 渲染的链接新窗口打开
- 查询余额可选 `API_BASE_URL` 代理地址
- `config` 接口添加验证防止被无限制调用
- `PWA` 默认不开启,现在需手动修改 `.env` 文件 `VITE_GLOB_APP_PWA` 变量
- 当网络连接时,刷新页面,`500` 错误页自动跳转到主页

## BugFix
- `scrollToBottom` 调回 `scrollToBottomIfAtBottom` [[shunyue1320](https://github.com/Chanzhaoyu/chatgpt-web/pull/771)]
- 重置异常的 `loading` 会话

## Common
- 创建 `start.cmd``windows` 下也可以运行 [vulgatecnn](https://github.com/Chanzhaoyu/chatgpt-web/pull/656)]
- 添加 `visual-studio-code` 中调试配置 [[ChandlerVer5](https://github.com/Chanzhaoyu/chatgpt-web/pull/296)]
- 修复文档中 `docker` 端口为本地 [[kilvn](https://github.com/Chanzhaoyu/chatgpt-web/pull/802)]
## Other
- 依赖更新


## v2.10.7

`2023-03-17`

## BugFix
- 回退 `chatgpt` 版本,原因:导致 `OPENAI_API_BASE_URL` 代理失效
- 修复缺省状态的 `usingContext` 默认值

## v2.10.6

`2023-03-17`

## Feature
- 显示 `API` 余额 [[pzcn](https://github.com/Chanzhaoyu/chatgpt-web/pull/582)]

## Enhancement
- 美化滚动条样式和 `UI` 保持一致 [[haydenull](https://github.com/Chanzhaoyu/chatgpt-web/pull/617)]
- 优化移动端 `Prompt` 样式 [[CornerSkyless](https://github.com/Chanzhaoyu/chatgpt-web/pull/608)]
- 上下文开关改为全局开关,现在记录在本地缓存中
- 配置信息按接口类型显示

## Perf
- 优化函数方法 [[kirklin](https://github.com/Chanzhaoyu/chatgpt-web/pull/583)]
- 字符错误 [[pdsuwwz](https://github.com/Chanzhaoyu/chatgpt-web/pull/585)]
- 文档描述错误 [[lizhongyuan3](https://github.com/Chanzhaoyu/chatgpt-web/pull/636)]

## BugFix
- 修复 `Prompt` 导入、导出兼容性错误
- 修复 `highlight.js` 控制台兼容性警告

## Other
- 依赖更新

## v2.10.5

`2023-03-13`

更新依赖,`access_token` 默认代理为 [acheong08](https://github.com/acheong08)`https://bypass.duti.tech/api/conversation`

## Feature
- `Prompt` 商店在线导入可以导入两种 `recommend.json`里提到的模板 [simonwu53](https://github.com/Chanzhaoyu/chatgpt-web/pull/521)
- 支持 `HTTPS_PROXY` [whatwewant](https://github.com/Chanzhaoyu/chatgpt-web/pull/308)
- `Prompt` 添加查询筛选

## Enhancement
- 调整输入框最大行数 [yi-ge](https://github.com/Chanzhaoyu/chatgpt-web/pull/502)
- 优化 `docker` 打包 [whatwewant](https://github.com/Chanzhaoyu/chatgpt-web/pull/520)
- `Prompt` 添加翻译和优化布局
- 「繁体中文」补全和审阅 [PeterDaveHello](https://github.com/Chanzhaoyu/chatgpt-web/pull/542)
- 语言选择调整为下路框形式
- 权限输入框类型调整为密码形式

## BugFix
- `JSON` 导入检查 [Nothing1024](https://github.com/Chanzhaoyu/chatgpt-web/pull/523)
- 修复 `AUTH_SECRET_KEY` 模式下跨域异常并添加对 `node.js 19` 版本的支持 [yi-ge](https://github.com/Chanzhaoyu/chatgpt-web/pull/499)
- 确定清空上下文时不应该重置会话标题

## Other
- 调整文档
- 更新依赖

## v2.10.4

`2023-03-11`

## Feature
- 感谢 [Nothing1024](https://github.com/Chanzhaoyu/chatgpt-web/pull/268) 添加 `Prompt` 模板和 `Prompt` 商店支持

## Enhancement
- 设置添加关闭按钮[#495]

## Demo

![Prompt](https://camo.githubusercontent.com/6a51af751eb29238cb7ef4f8fbd89f63db837562f97f33273095424e62dc9194/68747470733a2f2f73312e6c6f63696d672e636f6d2f323032332f30332f30342f333036326665633163613562632e676966)

## v2.10.3

`2023-03-10`
Expand Down
56 changes: 42 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
# build front-end
FROM node:lts-alpine AS builder
FROM node:lts-alpine AS frontend

RUN npm install pnpm -g

COPY ./ /app
WORKDIR /app

RUN apk add --no-cache git \
&& npm install pnpm -g \
&& pnpm install \
&& pnpm run build \
&& rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
COPY ./package.json /app

COPY ./pnpm-lock.yaml /app

RUN pnpm install

COPY . /app

RUN pnpm run build

# build backend
FROM node:lts-alpine as backend

RUN npm install pnpm -g

WORKDIR /app

COPY /service/package.json /app

COPY /service/pnpm-lock.yaml /app

RUN pnpm install

COPY /service /app

RUN pnpm build

# service
FROM node:lts-alpine

COPY /service /app
COPY --from=builder /app/dist /app/public
RUN npm install pnpm -g

WORKDIR /app
RUN apk add --no-cache git \
&& npm install pnpm -g \
&& pnpm install --only=production \
&& rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*

COPY /service/package.json /app

COPY /service/pnpm-lock.yaml /app

RUN pnpm install --production && rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*

COPY /service /app

COPY --from=frontend /app/dist /app/public

COPY --from=backend /app/build /app/build

EXPOSE 3002

CMD ["pnpm", "run", "start"]
CMD ["pnpm", "run", "prod"]
14 changes: 10 additions & 4 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ pnpm dev
- `TIMEOUT_MS` timeout, in milliseconds, optional
- `SOCKS_PROXY_HOST` optional, effective with SOCKS_PROXY_PORT
- `SOCKS_PROXY_PORT` optional, effective with SOCKS_PROXY_HOST
- `HTTPS_PROXY` optional, support http,https, socks5
- `ALL_PROXY` optional, support http,https, socks5

![docker](./docs/docker.png)

Expand All @@ -183,10 +185,10 @@ pnpm dev
docker build -t chatgpt-web .

# foreground operation
docker run --name chatgpt-web --rm -it -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
docker run --name chatgpt-web --rm -it -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web

# background operation
docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
docker run --name chatgpt-web -d -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web

# running address
http://localhost:3002/
Expand All @@ -203,7 +205,7 @@ services:
app:
image: chenzhaoyu94/chatgpt-web # always use latest, pull the tag image again when updating
ports:
- 3002:3002
- 127.0.0.1:3002:3002
environment:
# one of two
OPENAI_API_KEY: xxxxxx
Expand All @@ -223,6 +225,8 @@ services:
SOCKS_PROXY_HOST: xxxx
# socks proxy port, optional, effective with SOCKS_PROXY_HOST
SOCKS_PROXY_PORT: xxxx
# HTTPS Proxy,optional, support http, https, socks5
HTTPS_PROXY: http://xxx:7890
```
The `OPENAI_API_BASE_URL` is optional and only used when setting the `OPENAI_API_KEY`.
The `OPENAI_API_MODEL` is optional and only used when setting the `OPENAI_API_KEY`.
Expand All @@ -245,6 +249,8 @@ The `OPENAI_API_MODEL` is optional and only used when setting the `OPENAI_API_KE
| `API_REVERSE_PROXY` | Optional, only for `Web API` | Reverse proxy address for `Web API`. [Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
| `SOCKS_PROXY_HOST` | Optional, effective with `SOCKS_PROXY_PORT` | Socks proxy. |
| `SOCKS_PROXY_PORT` | Optional, effective with `SOCKS_PROXY_HOST` | Socks proxy port. |
| `HTTPS_PROXY` | Optional | HTTPS Proxy. |
| `ALL_PROXY` | Optional | ALL Proxy. |

> Note: Changing environment variables in Railway will cause re-deployment.

Expand All @@ -271,7 +277,7 @@ PS: You can also run `pnpm start` directly on the server without packaging.

#### Frontend webpage

1. Refer to the root directory `.env.example` file content to create `.env` file, modify `VITE_APP_API_BASE_URL` in `.env` at the root directory to your actual backend interface address.
1. Refer to the root directory `.env.example` file content to create `.env` file, modify `VITE_GLOB_API_URL` in `.env` at the root directory to your actual backend interface address.
2. Run the following command in the root directory and then copy the files in the `dist` folder to the root directory of your website service.

[Reference information](https://cn.vitejs.dev/guide/static-deploy.html#building-the-app)
Expand Down
Loading

0 comments on commit 2953435

Please sign in to comment.