diff --git a/.dockerignore b/.dockerignore index def59e5..b3cea57 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,4 @@ node_modules Dockerfile .* */.* +!.env diff --git a/.env b/.env index 54f675a..9a7a52f 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ # 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 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..101c96b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +docker-compose +kubernetes diff --git a/.github/workflows/issues_close.yml b/.github/workflows/issues_close.yml new file mode 100644 index 0000000..ba60f4a --- /dev/null +++ b/.github/workflows/issues_close.yml @@ -0,0 +1,22 @@ +name: Close inactive issues +on: + schedule: + - cron: '30 1 * * *' + +jobs: + close-issues: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v5 + with: + days-before-issue-stale: 10 + days-before-issue-close: 5 + stale-issue-label: stale + stale-issue-message: This issue is stale because it has been open for 10 days with no activity. + close-issue-message: This issue was closed because it has been inactive for 5 days since being marked as stale. + days-before-pr-stale: -1 + days-before-pr-close: -1 + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 1879753..fc2aace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,33 @@ +## v2.10.9 + +`2023-04-03` + +> 更新默认 `accessToken` 反代地址为 [[acheong08](https://github.com/acheong08)] 的 `https://bypass.churchless.tech/api/conversation` + +## Enhancement +- 添加 `socks5` 代理认证 [[yimiaoxiehou](https://github.com/Chanzhaoyu/chatgpt-web/pull/999)] +- 添加 `socks` 代理用户名密码的配置 [[hank-cp](https://github.com/Chanzhaoyu/chatgpt-web/pull/890)] +- 添加可选日志打印 [[zcong1993](https://github.com/Chanzhaoyu/chatgpt-web/pull/1041)] +- 更新侧边栏按钮本地化[[simonwu53](https://github.com/Chanzhaoyu/chatgpt-web/pull/911)] +- 优化代码块滚动条高度 [[Fog3211](https://github.com/Chanzhaoyu/chatgpt-web/pull/1153)] +## BugFix +- 修复 `PWA` 问题 [[bingo235](https://github.com/Chanzhaoyu/chatgpt-web/pull/807)] +- 修复 `ESM` 错误 [[kidonng](https://github.com/Chanzhaoyu/chatgpt-web/pull/826)] +- 修复反向代理开启时限流失效的问题 [[gitgitgogogo](https://github.com/Chanzhaoyu/chatgpt-web/pull/863)] +- 修复 `docker` 构建时 `.env` 可能被忽略的问题 [[zaiMoe](https://github.com/Chanzhaoyu/chatgpt-web/pull/877)] +- 修复导出异常错误 [[KingTwinkle](https://github.com/Chanzhaoyu/chatgpt-web/pull/938)] +- 修复空值异常 [[vchenpeng](https://github.com/Chanzhaoyu/chatgpt-web/pull/1103)] +- 移动端上的体验问题 + +## Other +- `Docker` 容器名字名义 [[LOVECHEN](https://github.com/Chanzhaoyu/chatgpt-web/pull/1035)] +- `kubernetes` 部署配置 [[CaoYunzhou](https://github.com/Chanzhaoyu/chatgpt-web/pull/1001)] +- 感谢 [[assassinliujie](https://github.com/Chanzhaoyu/chatgpt-web/pull/962)] 和 [[puppywang](https://github.com/Chanzhaoyu/chatgpt-web/pull/1017)] 的某些贡献 +- 更新 `kubernetes/deploy.yaml` [[idawnwon](https://github.com/Chanzhaoyu/chatgpt-web/pull/1085)] +- 文档更新 [[#yi-ge](https://github.com/Chanzhaoyu/chatgpt-web/pull/883)] +- 文档更新 [[weifeng12x](https://github.com/Chanzhaoyu/chatgpt-web/pull/880)] +- 依赖更新 + ## v2.10.8 `2023-03-23` diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 555ec7d..0000000 --- a/README.en.md +++ /dev/null @@ -1,333 +0,0 @@ -# ChatGPT Web - -
- - -> Disclaimer: This project is only released on GitHub, under the MIT License, free and for open-source learning purposes. There will be no account selling, paid services, discussion groups, or forums. Beware of fraud. - -![cover](./docs/c1.png) -![cover2](./docs/c2.png) - -- [ChatGPT Web](#chatgpt-web) - - [Introduction](#introduction) - - [Roadmap](#roadmap) - - [Prerequisites](#prerequisites) - - [Node](#node) - - [PNPM](#pnpm) - - [Fill in the Keys](#fill-in-the-keys) - - [Install Dependencies](#install-dependencies) - - [Backend](#backend) - - [Frontend](#frontend) - - [Run in Test Environment](#run-in-test-environment) - - [Backend Service](#backend-service) - - [Frontend Webpage](#frontend-webpage) - - [Packaging](#packaging) - - [Using Docker](#using-docker) - - [Docker Parameter Example](#docker-parameter-example) - - [Docker Build \& Run](#docker-build--run) - - [Docker Compose](#docker-compose) - - [Deployment with Railway](#deployment-with-railway) - - [Railway Environment Variables](#railway-environment-variables) - - [Manual packaging](#manual-packaging) - - [Backend service](#backend-service-1) - - [Frontend webpage](#frontend-webpage-1) - - [Frequently Asked Questions](#frequently-asked-questions) - - [Contributing](#contributing) - - [Sponsorship](#sponsorship) - - [License](#license) - -## Introduction - -Supports dual models, provides two unofficial `ChatGPT API` methods: - -| Method | Free? | Reliability | Quality | -| --------------------------------------------- | ------ | ----------- | ------- | -| `ChatGPTAPI(gpt-3.5-turbo-0301)` | No | Reliable | Relatively clumsy | -| `ChatGPTUnofficialProxyAPI(Web accessToken)` | Yes | Relatively unreliable | Smart | - -Comparison: -1. `ChatGPTAPI` uses `gpt-3.5-turbo-0301` to simulate `ChatGPT` through the official `OpenAI` completion `API` (the most reliable method, but it is not free and does not use models specifically tuned for chat). -2. `ChatGPTUnofficialProxyAPI` accesses `ChatGPT`'s backend `API` via an unofficial proxy server to bypass `Cloudflare` (uses the real `ChatGPT`, is very lightweight, but depends on third-party servers and has rate limits). - -[Details](https://github.com/Chanzhaoyu/chatgpt-web/issues/138) - -Switching Methods: -1. Go to the `service/.env.example` file and copy the contents to the `service/.env` file. -2. For `OpenAI API Key`, fill in the `OPENAI_API_KEY` field [(Get apiKey)](https://platform.openai.com/overview). -3. For `Web API`, fill in the `OPENAI_ACCESS_TOKEN` field [(Get accessToken)](https://chat.openai.com/api/auth/session). -4. When both are present, `OpenAI API Key` takes precedence. - -Reverse Proxy: - -Available when using `ChatGPTUnofficialProxyAPI`.[Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) - -```shell -# service/.env -API_REVERSE_PROXY= -``` - -Environment Variables: - -For all parameter variables, check [here](#docker-parameter-example) or see: - -``` -/service/.env -``` - -## Roadmap -[✓] Dual models - -[✓] Multiple session storage and context logic - -[✓] Formatting and beautifying code-like message types - -[✓] Access rights control - -[✓] Data import and export - -[✓] Save message to local image - -[✓] Multilingual interface - -[✓] Interface themes - -[✗] More... - -## Prerequisites - -### Node - -`node` requires version `^16 || ^18` (`node >= 14` requires installation of [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)), and multiple local `node` versions can be managed using [nvm](https://github.com/nvm-sh/nvm). - -```shell -node -v -``` - -### PNPM -If you have not installed `pnpm` before: -```shell -npm install pnpm -g -``` - -### Fill in the Keys - -Get `Openai Api Key` or `accessToken` and fill in the local environment variables [jump](#introduction) - -``` -# service/.env file - -# OpenAI API Key - https://platform.openai.com/overview -OPENAI_API_KEY= - -# change this to an `accessToken` extracted from the ChatGPT site's `https://chat.openai.com/api/auth/session` response -OPENAI_ACCESS_TOKEN= -``` - -## Install Dependencies - -> To make it easier for `backend developers` to understand, we did not use the front-end `workspace` mode, but stored it in different folders. If you only need to do secondary development of the front-end page, delete the `service` folder. - -### Backend - -Enter the `/service` folder and run the following command - -```shell -pnpm install -``` - -### Frontend -Run the following command in the root directory -```shell -pnpm bootstrap -``` - -## Run in Test Environment -### Backend Service - -Enter the `/service` folder and run the following command - -```shell -pnpm start -``` - -### Frontend Webpage -Run the following command in the root directory -```shell -pnpm dev -``` - -## Packaging - -### Using Docker - -#### Docker Parameter Example - -- `OPENAI_API_KEY` one of two -- `OPENAI_ACCESS_TOKEN` one of two, `OPENAI_API_KEY` takes precedence when both are present -- `OPENAI_API_BASE_URL` optional, available when `OPENAI_API_KEY` is set -- `OPENAI_API_MODEL` optional, available when `OPENAI_API_KEY` is set -- `API_REVERSE_PROXY` optional, available when `OPENAI_ACCESS_TOKEN` is set [Reference](#introduction) -- `AUTH_SECRET_KEY` Access Password,optional -- `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) - -#### Docker Build & Run - -```bash -docker build -t chatgpt-web . - -# foreground operation -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 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web - -# running address -http://localhost:3002/ -``` - -#### Docker Compose - -[Hub Address](https://hub.docker.com/repository/docker/chenzhaoyu94/chatgpt-web/general) - -```yml -version: '3' - -services: - app: - image: chenzhaoyu94/chatgpt-web # always use latest, pull the tag image again when updating - ports: - - 127.0.0.1:3002:3002 - environment: - # one of two - OPENAI_API_KEY: xxxxxx - # one of two - OPENAI_ACCESS_TOKEN: xxxxxx - # api interface url, optional, available when OPENAI_API_KEY is set - OPENAI_API_BASE_URL: xxxx - # api model, optional, available when OPENAI_API_KEY is set - OPENAI_API_MODEL: xxxx - # reverse proxy, optional - API_REVERSE_PROXY: xxx - # access password,optional - AUTH_SECRET_KEY: xxx - # timeout, in milliseconds, optional - TIMEOUT_MS: 60000 - # socks proxy, optional, effective with SOCKS_PROXY_PORT - 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`. - -### Deployment with Railway - -[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/yytmgc) - -#### Railway Environment Variables - -| Environment Variable | Required | Description | -| -------------------- | -------- | ------------------------------------------------------------------------------------------------- | -| `PORT` | Required | Default: `3002` | -| `AUTH_SECRET_KEY` | Optional | access password | -| `TIMEOUT_MS` | Optional | Timeout in milliseconds | -| `OPENAI_API_KEY` | Optional | Required for `OpenAI API`. `apiKey` can be obtained from [here](https://platform.openai.com/overview). | -| `OPENAI_ACCESS_TOKEN`| Optional | Required for `Web API`. `accessToken` can be obtained from [here](https://chat.openai.com/api/auth/session).| -| `OPENAI_API_BASE_URL` | Optional, only for `OpenAI API` | API endpoint. | -| `OPENAI_API_MODEL` | Optional, only for `OpenAI API` | API model. | -| `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. - -### Manual packaging - -#### Backend service - -> If you don't need the `node` interface of this project, you can skip the following steps. - -Copy the `service` folder to a server that has a `node` service environment. - -```shell -# Install -pnpm install - -# Build -pnpm build - -# Run -pnpm prod -``` - -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_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) - -```shell -pnpm build -``` - -## Frequently Asked Questions - -Q: Why does Git always report an error when committing? - -A: Because there is submission information verification, please follow the [Commit Guidelines](./CONTRIBUTING.en.md). - -Q: Where to change the request interface if only the frontend page is used? - -A: The `VITE_GLOB_API_URL` field in the `.env` file at the root directory. - -Q: All red when saving the file? - -A: For `vscode`, please install the recommended plug-in of the project or manually install the `Eslint` plug-in. - -Q: Why doesn't the frontend have a typewriter effect? - -A: One possible reason is that after Nginx reverse proxying, buffering is turned on, and Nginx will try to buffer a certain amount of data from the backend before sending it to the browser. Please try adding `proxy_buffering off;` after the reverse proxy parameter and then reloading Nginx. Other web server configurations are similar. - -## Contributing - -Please read the [Contributing Guidelines](./CONTRIBUTING.en.md) before contributing. - -Thanks to all the contributors! - - - - - -## Sponsorship - -If you find this project helpful and circumstances permit, you can give me a little support. Thank you very much for your support~ - -WeChat Pay
-Alipay
-{{ $t("setting.api") }}:{{ config?.apiModel ?? '-' }}
{{ $t("setting.balance") }}:{{ config?.balance ?? '-' }} + ({{ $t('setting.monthlyUsage') }})
{{ $t("setting.reverseProxy") }}:{{ config?.reverseProxy ?? '-' }} diff --git a/src/components/common/Setting/Advanced.vue b/src/components/common/Setting/Advanced.vue index 62c5851..9f255ff 100644 --- a/src/components/common/Setting/Advanced.vue +++ b/src/components/common/Setting/Advanced.vue @@ -29,7 +29,7 @@ function handleReset() {