Skip to content

Commit c3e8c6e

Browse files
committed
doc: update chinese readme
1 parent 041d96e commit c3e8c6e

2 files changed

Lines changed: 54 additions & 44 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ If you just want to run for your own use, supply the following options:
5858
docker run --name sqlchat --platform linux/amd64 --env NEXTAUTH_SECRET="$(openssl rand -hex 5)" --env OPENAI_API_KEY=<<YOUR OPENAI KEY>> -p 3000:3000 --hostname localhost sqlchat/sqlchat
5959
```
6060
61-
- Pass an arbitrary string to NEXTAUTH_SECRET otherwise next-auth will complain. It doesn't matter
62-
if you don't enable login.
61+
- Pass an arbitrary string to NEXTAUTH_SECRET otherwise next-auth will complain.
6362
- If you chat to the database on the same host, you need to use `host.docker.internal` as the host in
6463
the database connection setting.
6564

README.zh-CN.md

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,57 @@ SQL Chat 是由 [Next.js](https://nextjs.org/) 构建的,它支持以下数据
3131
- MSSQL
3232
- TiDB Cloud
3333

34-
## 数据保密
34+
## [sqlchat.ai](https://sqlchat.ai)
3535

36-
- 所有数据库连接配置都本地存储在浏览器中,您也可以访问设置到清除数据。
36+
## IP 白名单
3737

38-
- 只有数据库模式提供给 OpenAI API,表数据不会提供给 OpenAI API
38+
如果使用 [sqlchat.ai](https://sqlchat.ai) 连接数据库,则需要在数据库白名单 I P 中添加 0.0.0.0(允许所有连接)。因为 sqlchat.ai 托管在 [Vercel](https://vercel.com/)[使用动态 IP](https://vercel.com/guides/how-to-allowlist-deployment-ip-address)。如果这是一个问题,请考虑下面的自主机选项
3939

40-
- 如果使用 [sqlchat.ai](https://sqlchat.ai), 它会记录下这些匿名对话。
40+
## 数据保密
4141

42-
## IP 白名单
42+
请读 [SQL Chat 隐私政策](https://sqlchat.ai/privacy).
4343

44-
如果使用 [sqlchat.ai](https://sqlchat.ai) 连接数据库,则需要在数据库白名单 I P 中添加 0.0.0.0(允许所有连接)。因为 sqlchat.ai 托管在 [Vercel](https://vercel.com/)[使用动态 IP](https://vercel.com/guides/how-to-allowlist-deployment-ip-address)。如果这是一个问题,请考虑下面的自主机选项。
44+
## 自托管
45+
46+
### Docker
4547

46-
## 使用 Docker 自托管
48+
如果是自用,启动时提供下面两个参数即可:
49+
50+
- `NEXTAUTH_SECRET`
51+
- `OPENAI_API_KEY`
4752

4853
```bash
49-
docker run --name sqlchat --platform linux/amd64 -env NEXTAUTH_SECRET=xxx -p 3000:3000 sqlchat/sqlchat
54+
docker run --name sqlchat --platform linux/amd64 --env NEXTAUTH_SECRET="$(openssl rand -hex 5)" --env OPENAI_API_KEY=<<YOUR OPENAI KEY>> -p 3000:3000 --hostname localhost sqlchat/sqlchat
5055
```
5156
52-
### OpenAI 相关变量:
57+
- 传一个任意值给 NEXTAUTH_SECRET 否则 next-auth 会抱怨。
58+
- 如果您连接同一个 host 上的数据库,在数据库连接配置中,需要使用 `host.docker.internal` 作为 host。
59+
60+
<img src="https://raw.githubusercontent.com/sqlchat/sqlchat/main/docs/docker-connection-setting.webp" />
61+
62+
## 启动参数
63+
64+
## TL;DR
65+
66+
- 如果是自用,选择不需要数据库的配置,参阅 [.env.nodb](https://github.com/sqlchat/sqlchat/blob/main/.env.nodb).
67+
- 如果是希望提供类似于 [sqlchat.ai](https://sqlchat.ai) 的服务供多人使用, 那么需要数据库,参阅 [.env.usedb](https://github.com/sqlchat/sqlchat/blob/main/.env.usedb)。数据库用来保存用户以及使用信息。
68+
69+
### OpenAI 相关
5370
54-
- `NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY`: 设置为 `true` 如果你允许用户提供自己的 OpenAI API key.
55-
- `OPENAI_API_KEY`: OpenAI API Key,通过[这里](https://beta.openai.com/docs/developer-quickstart/api-keys)申请。
56-
- `OPENAI_API_ENDPOINT`: OpenAI API 端点,默认为 `https://api.openai.com`
71+
- `OPENAI_API_KEY`: OpenAI API key. 您能从 [这里](https://beta.openai.com/docs/developer-quickstart/api-keys) 获得。
5772
58-
### 数据库相关变量:
73+
- `OPENAI_API_ENDPOINT`: OpenAI API endpoint. 默认 `https://api.openai.com`
5974
60-
- `NEXT_PUBLIC_USE_DATABASE`: 设置为 `true` 如果你启动 SQL Chat 时使用了数据库。这会开启如下功能:
61-
1. 账户系统。
62-
1. 用户额度控制。
75+
- `NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY`: 置为 `true` 以允许 SQL Chat 服务的用户使用自己的 key。
76+
77+
### 数据库相关
78+
79+
- `NEXT_PUBLIC_USE_DATABASE`: 置为 `true` 使得 SQL Chat 启动时使用数据库,这会开启如下功能:
80+
1. 账号系统。
81+
1. 用户额度。
6382
1. 支付。
6483
1. 使用数据收集。
65-
- `DATABASE_URL`: 只有在 `NEXT_PUBLIC_USE_DATABASE``true` 时有效。Postgres 数据库连接串 e.g. `postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat`.
66-
67-
```bash
68-
docker run --name sqlchat --platform linux/amd64 --env NEXTAUTH_SECRET=xxx --env OPENAI_API_KEY=yyy --env OPENAI_API_ENDPOINT=zzz -p 3000:3000 sqlchat/sqlchat
69-
```
84+
- `DATABASE_URL`: 当 `NEXT_PUBLIC_USE_DATABASE``true` 时有效。用于保存数据的 Postgres 连接串 e.g. `postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat`.
7085
7186
## 本地开发环境
7287
@@ -76,16 +91,16 @@ docker run --name sqlchat --platform linux/amd64 --env NEXTAUTH_SECRET=xxx --env
7691
pnpm i
7792
```
7893
79-
1. 复制示例环境变量文件;
94+
1. 生成 `prisma` 客户端
8095
8196
```bash
82-
cp .env.usedb .env
97+
pnpm prisma generate
8398
```
8499
85-
1. 生成 `prisma` 客户端
100+
1. 复制示例环境变量文件;
86101
87102
```bash
88-
pnpm prisma generate
103+
cp .env.usedb .env
89104
```
90105
91106
1. 将您的 [API 密钥](https://platform.openai.com/account/api-keys) 和 `OpenAI API` 端点(可选)添加到新创建的 `.env` 文件;
@@ -140,6 +155,15 @@ pnpm prisma db seed
140155
141156
## 常见问题
142157
158+
<details><summary>为什么要我 sign up to get quota when self-hosted </summary>
159+
<p>
160+
161+
看这个 [issue](https://github.com/sqlchat/sqlchat/issues/141).
162+
163+
</p>
164+
</details>
165+
166+
143167
<details><summary>如何自托管 SQL Chat?</summary>
144168
<p>
145169
@@ -156,20 +180,17 @@ pnpm prisma db seed
156180
</p>
157181
</details>
158182
159-
<details><summary>如何使用我的 OpenAI API 密钥?</summary>
183+
<details><summary>You exceeded your current quota, please check your plan and billing details</summary>
160184
<p>
161185
162-
- 您可以在环境变量中设置 `OPENAI_API_KEY`
163-
164-
```bash
165-
docker run --name sqlchat --platform linux/amd64 --env OPENAI_API_KEY=xxx -p 3000:3000 sqlchat/sqlchat
166-
```
186+
![openai quota](https://raw.githubusercontent.com/sqlchat/sqlchat/main/public/error-exceed-openai-quota.webp)
167187
168-
- 您可以在设置对话框中设置 `OPENAI_API_KEY`
188+
这个表示你自己提供的 OpenAI Key 的 Quota 没有了。请查看自己的 [OpenAI 账号](https://platform.openai.com/account/api-keys)
169189
170190
</p>
171191
</details>
172192
193+
173194
<details><summary>它总是说我有网络连接问题?</summary>
174195
<p>
175196
@@ -185,13 +206,3 @@ ping api.openai.com
185206
186207
</p>
187208
</details>
188-
189-
<details><summary>You exceeded your current quota, please check your plan and billing details</summary>
190-
<p>
191-
192-
![openai quota](https://raw.githubusercontent.com/sqlchat/sqlchat/main/public/error-exceed-openai-quota.webp)
193-
194-
这个表示你自己提供的 OpenAI Key 的 Quota 没有了。请查看自己的 [OpenAI 账号](https://platform.openai.com/account/api-keys)
195-
196-
</p>
197-
</details>

0 commit comments

Comments
 (0)