Skip to content

Commit

Permalink
docs: 减少初始环境变量
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin committed Jun 24, 2023
1 parent 378dac7 commit 7bd68a3
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 206 deletions.
62 changes: 4 additions & 58 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,57 +240,19 @@ services:
- database
environment:
TZ: Asia/Shanghai
# 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
# ChatGPTAPI 或者 ChatGPTUnofficialProxyAPI
OPENAI_API_MODEL: xxxx
# reverse proxy, optional
API_REVERSE_PROXY: xxx
# timeout, in milliseconds, optional
TIMEOUT_MS: 600000
# 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
# socks proxy, optional, effective with SOCKS_PROXY_HOST and SOCKS_PROXY_PORT
SOCKS_PROXY_USERNAME: xxxx
# socks proxy port, optional, effective with SOCKS_PROXY_HOST and SOCKS_PROXY_PORT
SOCKS_PROXY_PASSWORD: xxxx
# HTTPS Proxy,optional, support http, https, socks5
HTTPS_PROXY: http://xxx:7890
# Title for site
SITE_TITLE: ChatGpt Web
# access salt,optional Allow login if not empty.
AUTH_SECRET_KEY: xxx
# mongodb's connection string
MONGODB_URL: 'mongodb://chatgpt:xxxx@database:27017'
# Register enabled
REGISTER_ENABLED: true
# After register enabled, Allowed mailbox suffixes for website registration. If empty, any suffix is allowed
REGISTER_MAILS: '@qq.com,@sina.com,@163.com'
# After register enabled, Salt for password encryption
PASSWORD_MD5_SALT: xxx
# After register enabled, super administrator
ROOT_USER: [email protected]
# After register enabled, The website's domain ending without /
SITE_DOMAIN: http://127.0.0.1:3002
# After register enabled, The smtp settings
SMTP_HOST: smtp.exmail.qq.com
SMTP_PORT: 465
SMTP_TSL: true
SMTP_USERNAME: [email protected]
SMTP_PASSWORD: xxx
# Enable sensitive word review, because the response result is streaming, so there is currently no review.
AUDIT_ENABLED: false
# https://ai.baidu.com/ai-doc/ANTIPORN/Vk3h6xaga
AUDIT_PROVIDER: baidu
AUDIT_API_KEY: xxx
AUDIT_API_SECRET: xxx
AUDIT_TEXT_LABEL: xxx
# Allow anyone register, Must be turned on, otherwise administrators cannot register, can be turned off later.
REGISTER_ENABLED: true
# More configurations, register an administrator after running and set it in the administrator page.
links:
- database

Expand Down Expand Up @@ -318,23 +280,7 @@ The `OPENAI_API_BASE_URL` is optional and only used when setting the `OPENAI_API

[![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` | `ChatGPTAPI` OR `ChatGPTUnofficialProxyAPI` | 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. |
| `SOCKS_PROXY_USERNAME` | Optional, effective with `SOCKS_PROXY_HOST` & `SOCKS_PROXY_PORT` | Socks proxy username. |
| `SOCKS_PROXY_PASSWORD` | Optional, effective with `SOCKS_PROXY_HOST` & `SOCKS_PROXY_PORT` | Socks proxy password. |
| `HTTPS_PROXY` | Optional | HTTPS Proxy. |
> Refer to this issue https://github.com/Kerwin1202/chatgpt-web/issues/266

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

Expand Down
59 changes: 4 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,55 +244,21 @@ services:
- database
environment:
TZ: Asia/Shanghai
# 二选一
OPENAI_API_KEY: sk-xxx
# 二选一
OPENAI_ACCESS_TOKEN: xxx
# API接口地址,可选,设置 OPENAI_API_KEY 时可用
OPENAI_API_BASE_URL: xxx
# ChatGPTAPI ChatGPTUnofficialProxyAPI
OPENAI_API_MODEL: ChatGPTAPI
# 反向代理,可选
API_REVERSE_PROXY: xxx
# 每小时最大请求次数,可选,默认无限
MAX_REQUEST_PER_HOUR: 0
# 超时,单位毫秒,可选
TIMEOUT_MS: 600000
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
SOCKS_PROXY_HOST: xxx
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
SOCKS_PROXY_PORT: xxx
# HTTPS 代理,可选,支持 http,https,socks5
HTTPS_PROXY: http://xxx:7890
# 访问jwt加密参数,可选 不为空则允许登录 同时需要设置 MONGODB_URL
AUTH_SECRET_KEY: xxx
# 网站名称
SITE_TITLE: ChatGpt Web
# mongodb 的连接字符串
MONGODB_URL: 'mongodb://chatgpt:xxxx@database:27017'
# 网站是否开启注册
REGISTER_ENABLED: 'true'
# 开启注册之后 网站注册允许的邮箱后缀 如果空 则允许任意后缀
REGISTER_MAILS: '@qq.com,@sina.com,@163.com'
# 开启注册之后 密码加密的盐
PASSWORD_MD5_SALT: xxx
# 开启注册之后 超级管理邮箱
ROOT_USER: [email protected]
# 开启注册之后 网站域名 不含 / 注册的时候发送验证邮箱使用
SITE_DOMAIN: http://127.0.0.1:3002
# 开启注册之后 发送验证邮箱配置
SMTP_HOST: smtp.exmail.qq.com
SMTP_PORT: 465
SMTP_TSL: 'true'
SMTP_USERNAME: [email protected]
SMTP_PASSWORD: xxx
# 是否开启敏感词审核, 因为响应结果是流式 所以暂时没审核
AUDIT_ENABLED: 'false'
# https://ai.baidu.com/ai-doc/ANTIPORN/Vk3h6xaga
AUDIT_PROVIDER: baidu
AUDIT_API_KEY: xxx
AUDIT_API_SECRET: xxx
AUDIT_TEXT_LABEL: xxx
# 网站是否开启注册 必须开启, 否则管理员都没法注册, 可后续关闭
REGISTER_ENABLED: true
# 更多配置, 在运行后, 注册管理员, 在管理员页面中设置
links:
- database

Expand Down Expand Up @@ -333,24 +299,7 @@ volumes:
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/yytmgc)
#### Railway 环境变量
| 环境变量名称 | 必填 | 备注 |
| --------------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
| `PORT` | 必填 | 默认 `3002`
| `AUTH_SECRET_KEY` | 可选 | 访问权限密钥 |
| `MAX_REQUEST_PER_HOUR` | 可选 | 每小时最大请求次数,可选,默认无限 |
| `TIMEOUT_MS` | 可选 | 超时时间,单位毫秒 |
| `OPENAI_API_KEY` | `OpenAI API` 二选一 | 使用 `OpenAI API` 所需的 `apiKey` [(获取 apiKey)](https://platform.openai.com/overview) |
| `OPENAI_ACCESS_TOKEN` | `Web API` 二选一 | 使用 `Web API` 所需的 `accessToken` [(获取 accessToken)](https://chat.openai.com/api/auth/session) |
| `OPENAI_API_BASE_URL` | 可选,`OpenAI API` 时可用 | `API`接口地址 |
| `OPENAI_API_MODEL` | ChatGPTAPI OR ChatGPTUnofficialProxyAPI | `API`模型 |
| `API_REVERSE_PROXY` | 可选,`Web API` 时可用 | `Web API` 反向代理地址 [详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
| `SOCKS_PROXY_HOST` | 可选,和 `SOCKS_PROXY_PORT` 一起时生效 | Socks代理 |
| `SOCKS_PROXY_PORT` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理端口 |
| `SOCKS_PROXY_USERNAME` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理用户名 |
| `SOCKS_PROXY_PASSWORD` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理密码 |
| `HTTPS_PROXY` | 可选 | HTTPS 代理,支持 http,https, socks5 |
> 参考这个 issue 详细教程 https://github.com/Kerwin1202/chatgpt-web/issues/266
> 注意: `Railway` 修改环境变量会重新 `Deploy`
Expand Down
32 changes: 3 additions & 29 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,17 @@ services:
AUTH_SECRET_KEY:
# 每小时最大请求次数,可选,默认无限
MAX_REQUEST_PER_HOUR: 0
# 超时,单位毫秒,可选
TIMEOUT_MS: 600000
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
SOCKS_PROXY_HOST:
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
SOCKS_PROXY_PORT:
# Socks代理用户名,可选,和 SOCKS_PROXY_HOST & SOCKS_PROXY_PORT 一起时生效
SOCKS_PROXY_USERNAME:
# Socks代理密码,可选,和 SOCKS_PROXY_HOST & SOCKS_PROXY_PORT 一起时生效
SOCKS_PROXY_PASSWORD:
# 网站名称
SITE_TITLE: ChatGpt Web
# mongodb 的连接字符串
MONGODB_URL: 'mongodb://chatgpt:xxxx@database:27017'
# 网站是否开启注册
REGISTER_ENABLED: false
# 开启注册之后 网站注册允许的邮箱后缀 如果空 则允许任意后缀
REGISTER_MAILS: '@qq.com,@sina.com,@163.com'
# 开启注册之后 密码加密的盐
PASSWORD_MD5_SALT: anysalt
# 开启注册之后 超级管理邮箱
ROOT_USER: [email protected]
# 开启注册之后 网站域名 不含 / 注册的时候发送验证邮箱使用
SITE_DOMAIN: http://127.0.0.1:1002
# 开启注册之后 发送验证邮箱配置
SMTP_HOST: smtp.exmail.qq.com
SMTP_PORT: 465
SMTP_TSL: true
SMTP_USERNAME: ${SMTP_USERNAME}
SMTP_PASSWORD: ${SMTP_PASSWORD}
# 是否开启敏感词审核, 因为响应结果是流式 所以暂时没审核
AUDIT_ENABLED: false
# https://ai.baidu.com/ai-doc/ANTIPORN/Vk3h6xaga
AUDIT_PROVIDER: baidu
AUDIT_API_KEY:
AUDIT_API_SECRET:
AUDIT_TEXT_LABEL:
# 网站是否开启注册 必须开启, 否则管理员都没法注册, 可后续关闭
REGISTER_ENABLED: true
# 更多配置, 在运行后, 注册管理员, 在管理员页面中设置
links:
- database

Expand Down
61 changes: 6 additions & 55 deletions service/.env.example
Original file line number Diff line number Diff line change
@@ -1,47 +1,12 @@
# 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=

# OpenAI API Base URL - https://api.openai.com
OPENAI_API_BASE_URL=

# ChatGPTAPI 或者 ChatGPTUnofficialProxyAPI
OPENAI_API_MODEL:

# set `true` to disable OpenAI API debug log
OPENAI_API_DISABLE_DEBUG=

# Reverse Proxy - Available on accessToken
# Default: https://ai.fakeopen.com/api/conversation
# More: https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy
API_REVERSE_PROXY=

# timeout
TIMEOUT_MS=100000

# Rate Limit
MAX_REQUEST_PER_HOUR=

# Auth Rate Limit
AUTH_MAX_REQUEST_PER_MINUTE=5

# Socks Proxy Host
SOCKS_PROXY_HOST=

# Socks Proxy Port
SOCKS_PROXY_PORT=

# Socks Proxy Username
SOCKS_PROXY_USERNAME=

# Socks Proxy Password
SOCKS_PROXY_PASSWORD=

# HTTPS PROXY
HTTPS_PROXY=

# Title for site
SITE_TITLE="ChatGpt Web"

Expand All @@ -55,31 +20,17 @@ AUTH_SECRET_KEY=

# ----- Only valid after setting AUTH_SECRET_KEY begin ----

# Allow anyone register
REGISTER_ENABLED=false

# Enable register application review
REGISTER_REVIEW=false

# The site domain, Only for registration account verification
# without end /
SITE_DOMAIN=http://127.0.0.1:1002

# Allowed Email Providers, If it is empty, any mailbox is allowed
# [email protected],@sina.com,@163.com
REGISTER_MAILS=@qq.com,@sina.com,@163.com

# The roon user only email
ROOT_USER=

# Password salt
PASSWORD_MD5_SALT=anysalt

# User register email verify
SMTP_HOST=smtp.exmail.qq.com
SMTP_PORT=465
SMTP_TSL=true
SMTP_USERNAME=[email protected]
SMTP_PASSWORD=yourpassword
# Allow anyone register, Must be turned on, otherwise administrators cannot register, can be turned off later.
REGISTER_ENABLED=true

# ----- Only valid after setting AUTH_SECRET_KEY end ----


# 更多配置, 在运行后, 注册管理员, 在管理员页面中设置
# More configurations, register an administrator after running and set it in the administrator page.
4 changes: 2 additions & 2 deletions service/src/storage/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export async function getOriginConfig() {
let config = await getConfig()
if (config == null) {
config = new Config(new ObjectId(),
!isNaN(+process.env.TIMEOUT_MS) ? +process.env.TIMEOUT_MS : 30 * 1000,
!isNaN(+process.env.TIMEOUT_MS) ? +process.env.TIMEOUT_MS : 600 * 1000,
process.env.OPENAI_API_KEY,
process.env.OPENAI_API_DISABLE_DEBUG === 'true',
process.env.OPENAI_ACCESS_TOKEN,
process.env.OPENAI_API_BASE_URL,
process.env.OPENAI_API_MODEL || 'ChatGPTAPI',
process.env.OPENAI_API_MODEL === 'ChatGPTUnofficialProxyAPI' ? 'ChatGPTUnofficialProxyAPI' : 'ChatGPTAPI',
process.env.API_REVERSE_PROXY,
(process.env.SOCKS_PROXY_HOST && process.env.SOCKS_PROXY_PORT)
? (`${process.env.SOCKS_PROXY_HOST}:${process.env.SOCKS_PROXY_PORT}`)
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Setting/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ onMounted(() => {
<div class="flex items-center space-x-4">
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.socks') }}</span>
<div class="flex-1">
<NInput :value="config.socksProxy" placeholder="" @input="(val) => { config.socksProxy = val }" />
<NInput :value="config.socksProxy" placeholder="ip:port" @input="(val) => { config.socksProxy = val }" />
</div>
</div>
<div class="flex items-center space-x-4">
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Setting/Keys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const columns = [
type: 'info',
onClick: () => handleEditKey(row),
},
{ default: () => t('chat.editKeyButton') },
{ default: () => t('common.edit') },
))
actions.push(h(
NButton,
Expand All @@ -114,7 +114,7 @@ const columns = [
type: 'error',
onClick: () => handleUpdateApiKeyStatus(row._id as string, Status.Disabled),
},
{ default: () => t('chat.deleteKey') },
{ default: () => t('common.delete') },
))
}
return actions
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Setting/Site.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ onMounted(() => {
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.registerMails') }}</span>
<div class="flex-1">
<NInput
:value="config && config.registerMails" placeholder=""
:value="config && config.registerMails" :placeholder="$t('setting.registerReviewTip')"
@input="(val) => { if (config) config.registerMails = val }"
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Setting/User.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const columns = [
},
onClick: () => handleUpdateUserStatus(row._id, Status.Deleted),
},
{ default: () => t('chat.deleteUser') },
{ default: () => t('common.delete') },
))
if (row.status === Status.Normal) {
actions.push(h(
Expand All @@ -90,7 +90,7 @@ const columns = [
size: 'small',
type: 'primary',
style: {
marginRight: '6px',
marginRight: '8px',
},
onClick: () => handleEditUser(row),
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default {
registerEnabled: 'Register Enabled',
registerReview: 'Register Review',
registerMails: 'Register Mails',
registerReviewTip: 'Only email addresses with these suffixes are allowed to register on this website.',
apiBaseUrl: 'Api Base Url',
apiModel: 'Api Model',
accessToken: 'Access Token',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default {
registerEnabled: '등록 활성화',
registerReview: '등록 리뷰',
registerMails: '메일 등록',
registerReviewTip: 'Only email addresses with these suffixes are allowed to register on this website.',
apiBaseUrl: 'API 베이스 URL',
apiModel: '인터페이스 유형',
accessToken: '액세스 토큰',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default {
registerEnabled: '新用户',
registerReview: '新用户审核',
registerMails: '邮箱后缀',
registerReviewTip: '仅允许这些邮箱的后缀注册本网站',
apiBaseUrl: '接口地址',
apiModel: '接口类型',
accessToken: 'Access Token',
Expand Down
Loading

0 comments on commit 7bd68a3

Please sign in to comment.