@lobehub/chat 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.env.example +52 -0
  2. package/CHANGELOG.md +58 -0
  3. package/README.md +51 -10
  4. package/README.zh-CN.md +51 -10
  5. package/docs/self-hosting/advanced/feature-flags.mdx +13 -11
  6. package/docs/self-hosting/advanced/feature-flags.zh-CN.mdx +1 -1
  7. package/docs/self-hosting/advanced/server-database.mdx +401 -0
  8. package/docs/self-hosting/advanced/server-database.zh-CN.mdx +389 -0
  9. package/docs/self-hosting/advanced/settings-url-share.mdx +14 -0
  10. package/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx +13 -0
  11. package/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx +15 -15
  12. package/docs/usage/features/auth.mdx +60 -0
  13. package/docs/usage/features/auth.zh-CN.mdx +58 -0
  14. package/docs/usage/features/database.mdx +54 -0
  15. package/docs/usage/features/database.zh-CN.mdx +54 -0
  16. package/locales/ar/common.json +1 -1
  17. package/locales/bg-BG/common.json +1 -1
  18. package/locales/de-DE/common.json +1 -1
  19. package/locales/en-US/chat.json +14 -14
  20. package/locales/en-US/common.json +12 -12
  21. package/locales/en-US/market.json +6 -6
  22. package/locales/en-US/metadata.json +2 -2
  23. package/locales/en-US/setting.json +16 -16
  24. package/locales/en-US/welcome.json +2 -2
  25. package/locales/es-ES/common.json +1 -1
  26. package/locales/fr-FR/common.json +1 -1
  27. package/locales/it-IT/common.json +1 -1
  28. package/locales/ja-JP/common.json +1 -1
  29. package/locales/ko-KR/common.json +1 -1
  30. package/locales/nl-NL/common.json +1 -1
  31. package/locales/pl-PL/common.json +1 -1
  32. package/locales/pt-BR/common.json +1 -1
  33. package/locales/ru-RU/common.json +1 -1
  34. package/locales/tr-TR/common.json +1 -1
  35. package/locales/vi-VN/common.json +1 -1
  36. package/locales/zh-CN/common.json +1 -1
  37. package/locales/zh-TW/common.json +1 -1
  38. package/package.json +3 -3
  39. package/scripts/i18nWorkflow/utils.ts +1 -4
  40. package/scripts/migrateServerDB/index.ts +2 -0
  41. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/SendMore.tsx +3 -5
  42. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/index.tsx +15 -6
  43. package/src/app/(main)/chat/(workspace)/features/ShareButton/Preview.tsx +3 -2
  44. package/src/app/(main)/chat/@session/_layout/Desktop/SessionHeader.tsx +3 -2
  45. package/src/app/(main)/chat/@session/_layout/Mobile/SessionHeader.tsx +3 -2
  46. package/src/app/(main)/market/_layout/Desktop/Header.tsx +3 -2
  47. package/src/app/(main)/market/_layout/Desktop/Hero.tsx +1 -1
  48. package/src/app/(main)/welcome/_layout/Desktop.tsx +3 -2
  49. package/src/app/layout.tsx +2 -1
  50. package/src/components/BrandWatermark/index.tsx +2 -2
  51. package/src/components/FullscreenLoading/index.tsx +3 -2
  52. package/src/config/featureFlags/schema.ts +1 -1
  53. package/src/config/file.ts +2 -2
  54. package/src/config/modelProviders/deepseek.ts +2 -2
  55. package/src/locales/default/common.ts +1 -1
  56. package/src/store/serverConfig/selectors.test.ts +1 -1
@@ -0,0 +1,389 @@
1
+ ---
2
+ title: 使用服务端数据库部署 - 配置 Postgres、Clerk 和 S3 存储服务
3
+ description: 本文详细介绍如何在 Vercel 中部署服务端数据库版 LobeChat,包括数据库配置、身份验证服务配置和 S3 存储服务的设置步骤。
4
+ tags:
5
+ - 服务端数据库
6
+ - Postgres
7
+ - Clerk
8
+ - S3存储服务
9
+ - Vercel部署
10
+ - 数据库配置
11
+ - 身份验证服务
12
+ - 环境变量配置
13
+ ---
14
+ # 使用服务端数据库部署
15
+
16
+ LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用服务端数据库。LobeChat 采用了 Postgres 作为后端存储数据库。PostgreSQL是一种强大的开源关系型数据库管理系统,具备高度扩展性和标准SQL支持。它提供了丰富的数据类型、并发处理、数据完整性、安全性及可编程性,适用于复杂应用和大规模数据管理。
17
+
18
+ 本文将详细介绍如何在 Vercel 中部署服务端数据库版 LobeChat,包括: 1)数据库配置;2)身份验证服务配置;3) S3 存储服务的设置步骤。
19
+
20
+ <Callout type={'info'}>
21
+ 限于工作量原因,目前仅支持在 Vercel 中部署使用服务端数据库版本,Docker 版本将会在后续迭代中支持。
22
+ </Callout>
23
+
24
+ ## 一、 配置数据库
25
+
26
+ <Steps>
27
+
28
+ ### 准备服务端数据库实例,获取连接 URL
29
+
30
+ 在部署之前,请确保你已经准备好 Postgres 数据库实例,你可以选择以下任一方式:
31
+
32
+ - `A.` 使用 Vercel / Neon 等 Serverless Postgres 实例;
33
+ - `B.` 使用 Docker 等自部署 Postgres 实例。
34
+
35
+ 两者的配置方式略有不同,在下一步会有所区分。
36
+
37
+ ### 在 Vercel 中添加环境变量
38
+
39
+ 在 Vercel 的部署环境变量中,添加 `DATABASE_URL` 等环境变量,将上一步准备好的 Postgres 数据库连接 URL 填入其中。数据库连接 URL 的通常格式为 `postgres://username:password@host:port/database`。
40
+
41
+ <Tabs items={['Serverless Postgres', 'Node Postgres']}>
42
+
43
+ <Tab>
44
+
45
+ Serverless Postgres 需要填写的变量如下:
46
+
47
+ ```shell
48
+ # Serverless Postgres DB Url
49
+ DATABASE_URL=
50
+
51
+ # 指定 service mode 为 server,否则不会进入服务端数据库
52
+ NEXT_PUBLIC_SERVICE_MODE=server
53
+ ```
54
+
55
+ 在 Vercel 中填写的示例如下:
56
+
57
+ <Image alt={'添加 Serverless Postgres DATABASE_URL'} src={'https://github.com/lobehub/lobe-chat/assets/28616219/d4a710cd-6404-4196-90d0-cd08ca385074'}></Image>
58
+
59
+ </Tab>
60
+
61
+ <Tab>
62
+ Node Postgres 需要填写的变量如下:
63
+
64
+ ```shell
65
+ # Node Postgres DB Url
66
+ DATABASE_URL=
67
+
68
+ # 指定 Postgres database driver 为 node
69
+ DATABASE_DRIVER=node
70
+
71
+ # 指定 service mode 为 server,否则不会进入服务端数据库
72
+ NEXT_PUBLIC_SERVICE_MODE=server
73
+ ```
74
+
75
+ 在 Vercel 中填写的示例如下:
76
+
77
+ <Image alt={'添加 Node Postgres DATABASE_URL'} src={'https://github.com/lobehub/lobe-chat/assets/28616219/1c689738-809b-4199-b305-ba5770d39da7'}></Image>
78
+
79
+ </Tab>
80
+
81
+ </Tabs>
82
+
83
+ ### 添加 `KEY_VAULTS_SECRET` 环境变量
84
+
85
+ 在完成数据库 DATABASE_URL 环境变量添加后,需要添加一个 `KEY_VAULTS_SECRET` 环境变量。该变量用于加密用户存储的 apikey 等敏感信息。你可以使用 `openssl rand -base64 32` 生成一个随机的 32 位字符串作为密钥。
86
+
87
+ ```shell
88
+ KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
89
+ ```
90
+
91
+ 同样需要将其添加到 Vercel 环境变量中。
92
+
93
+ </Steps>
94
+
95
+ ## 二、 配置身份验证服务
96
+
97
+ 服务端数据库需要搭配用户身份验证服务才可以正常使用。因此需要配置对应的身份验证服务。
98
+
99
+ <Callout type={'warning'}>
100
+ 同样由于工作量原因,目前仅支持 Clerk 作为身份验证服务方案, Next-Auth 的服务端数据库集成有待开发
101
+ </Callout>
102
+
103
+ <Steps>
104
+
105
+ ### 准备 Clerk 身份验证服务
106
+
107
+ 前往 [Clerk](https://clerk.com?utm_source=lobehub&utm_medium=docs) 注册并创建应用,获取相应的 Public Key 和 Secret Key。
108
+
109
+ <Callout type={'info'}>
110
+ 如果对 Clerk 不太了解,可以查阅
111
+ [身份验证服务-Clerk](/zh/docs/self-hosting/advanced/authentication#clerk) 了解 Clerk 的使用详情。
112
+ </Callout>
113
+
114
+ ### 在 Vercel 中添加公、私钥环境变量
115
+
116
+ 在 Vercel 的部署环境变量中,添加 `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` 和 `CLERK_SECRET_KEY` 环境变量。你可以在菜单中点击「API Keys」,然后复制对应的值填入 Vercel 的环境变量中。
117
+
118
+ <Image
119
+ alt={'在 Clerk 中找到对应的公私钥环境变量'}
120
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/89883703-7a1a-4a11-b944-5d804544e57c'}
121
+ ></Image>
122
+
123
+ 此步骤所需的环境变量如下:
124
+
125
+ ```shell
126
+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
127
+ CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
128
+ ```
129
+
130
+ 添加上述变量到 Vercel 中:
131
+
132
+ <Image
133
+ alt={'在 Vercel 中添加 Clerk 公私钥环境变量'}
134
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/2bfa13df-6e20-4768-97c0-4dad06c85a2f'}
135
+ ></Image>
136
+
137
+ ### 在 Clerk 中创建并配置 Webhook
138
+
139
+ 由于我们让 Clerk 完全接管用户鉴权与管理,因此我们需要在 Clerk 用户生命周期变更时(创建、更新、删除)中通知我们的应用并存储落库。我们通过 Clerk 提供的 Webhook 来实现这一诉求。
140
+
141
+ 我们需要在 Clerk 的 Webhooks 中添加一个端点(Endpoint),告诉 Clerk 当用户发生变更时,向这个端点发送通知。
142
+
143
+ <Image
144
+ alt={'Clerk 添加 Webhooks 端点'}
145
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/f50f47fb-5e8e-4930-bf4e-8cf6f5b8afb9'}
146
+ ></Image>
147
+
148
+ 在 endppint 中填写你的 Vercel 项目的 URL,如 `https://your-project.vercel.app/api/webhooks/clerk`。然后在订阅事件(Subscribe to events)中,勾选 user 的三个事件(`user.created` 、`user.deleted`、`user.updated`),然后点击创建。
149
+
150
+ <Image
151
+ alt={'添加 Clerk Webhooks 时,配置 URL 和用户事件'}
152
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/0249ea56-ab17-4aa9-a56c-9ebd556c2645'}
153
+ ></Image>
154
+
155
+ ### 将 Webhook 秘钥添加到 Vercel 环境变量
156
+
157
+ 创建完毕后,可以在右下角找到该 Webhook 的秘钥:
158
+
159
+ <Image
160
+ alt={'查看 Clerk Webhooks 秘钥'}
161
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/fab4abb2-584b-49de-9340-813382951635'}
162
+ ></Image>
163
+
164
+ 这个秘钥所对应的环境变量名为 `CLERK_WEBHOOK_SECRET`:
165
+
166
+ ```shell
167
+ CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
168
+ ```
169
+
170
+ 将其添加到 Vercel 的环境变量中:
171
+
172
+ <Image
173
+ alt={'在 Vercel 中 添加 Clerk Webhooks 秘钥'}
174
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/5fdc9479-007f-46ab-9d6e-a9603e949116'}
175
+ ></Image>
176
+
177
+ </Steps>
178
+
179
+ 这样,你已经成功配置了 Clerk 身份验证服务。接下来我们将配置 S3 存储服务。
180
+
181
+ ## 三、 配置 S3 存储服务
182
+
183
+ LobeChat 在很早以前就支持了多模态 的 AI 会话,其中涉及到图片上传给 AI 的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 indexedDB 数据库,但在服务端数据库中这个方案并不可行。我们需要配置 S3 存储服务来存储大量的图片文件,同时 S3 也可以作为文件上传的存储方案。
184
+
185
+ <Callout type={'info'}>
186
+ 在本文,S3所指代的是指兼容 S3 存储方案,即支持 Amazon S3 API 的对象存储系统,常见例如 Cloudflare
187
+ R2 、阿里云 OSS 等均支持 S3 兼容 API。
188
+ </Callout>
189
+
190
+ <Steps>
191
+
192
+ ### 配置并获取 S3 存储桶
193
+
194
+ 你需要前往你的 S3 服务提供商(如 AWS S3、Cloudflare R2 等)并创建一个新的存储桶(Bucket)。接下来以 Cloudflare R2 为例,介绍创建流程。
195
+
196
+ 下图是 Cloudflare R2 的界面:
197
+
198
+ <Image
199
+ alt={'Cloudflare R2 存储界面'}
200
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/41f7f677-0153-4a96-b849-5ac9b7ebefee'}
201
+ ></Image>
202
+
203
+ 创建存储桶时将指定其名称,然后点击创建。
204
+ <Image
205
+ alt={'R2 创建存储桶'}
206
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/9c0d184c-3169-40fa-9115-011cfffb9ca7'}
207
+ ></Image>
208
+
209
+ ### 获取存储桶相关环境变量
210
+
211
+ 在 R2 存储桶的设置中,可以看到桶配置的信息:
212
+
213
+ <Image
214
+ alt={'查看存储桶的相关信息'}
215
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/2ceb210c-eca0-4439-ba27-8734d4ebb3ee'}
216
+ ></Image>
217
+
218
+ 其对应的环境变量为:
219
+
220
+ ```shell
221
+ # 存储桶的名称
222
+ S3_BUCKET=lobechat
223
+ # 存储桶的请求端点
224
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
225
+ # 存储桶对外的访问域名
226
+ NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com
227
+ ```
228
+
229
+ ### 获取 S3 密钥环境变量
230
+
231
+ 你需要获取 S3 的访问密钥,以便 LobeChat 的服务端有权限访问 S3 存储服务。在 R2 中,你可以在账户详情中配置访问密钥:
232
+
233
+ <Image
234
+ alt={'查看存储桶的访问秘钥'}
235
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/be0c95c0-6693-44ee-a490-7e8dfaa8b34d'}
236
+ ></Image>
237
+
238
+ 点击右上角按钮创建 API token,进入创建 API Token 页面
239
+
240
+ <Image
241
+ alt={'创建对应 API token'}
242
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/7b0ea46c-5157-40a8-888f-f47664a4884f'}
243
+ ></Image>
244
+
245
+ 鉴于我们的服务端数据库需要读写 S3 存储服务,因此权限需要选择读与写,并只选择我们所创建的存储桶,然后点击创建。
246
+
247
+ <Image
248
+ alt={'配置 API token 权限'}
249
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/d6f5a918-7b50-4d6e-83a6-3894ab930ddf'}
250
+ ></Image>
251
+
252
+ 创建完成后,就可以看到对应的 S3 API token
253
+
254
+ <Image
255
+ alt={'复制 API token'}
256
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/763b18f9-2b5f-44bb-a479-9b56d46f7397'}
257
+ ></Image>
258
+
259
+ 其对应的环境变量为:
260
+
261
+ ```shell
262
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
263
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
264
+ ```
265
+
266
+ ### 在 Vercel 中添加对应的环境变量
267
+
268
+ 不同 S3 服务商获取所需环境变量的步骤可能有所不同,但最终获得到的环境变量应该都是一致的:
269
+
270
+ ```shell
271
+ # S3 秘钥
272
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
273
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
274
+
275
+ # 存储桶的名称
276
+ S3_BUCKET=lobechat
277
+ # 存储桶的请求端点
278
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
279
+ # 存储桶对外的访问域名
280
+ NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
281
+
282
+ # 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
283
+ # S3_REGION=us-west-1
284
+ ```
285
+
286
+ 然后将上述环境变量填入 Vercel 的环境变量中:
287
+
288
+ <Image
289
+ alt={'在 Vercel 中添加 S3 的环境变量'}
290
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/cd74152d-0ae8-44fd-b815-3307c56a3c18'}
291
+ ></Image>
292
+
293
+ ### 配置跨域
294
+
295
+ 由于 S3 存储服务往往是一个独立的网址,因此需要配置跨域访问。
296
+
297
+ 在 R2 中,你可以在存储桶的设置中找到跨域配置:
298
+
299
+ <Image
300
+ alt={'Cloudflare R2 的跨域设置'}
301
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/ab008be7-26b2-4b78-8bd9-24301bf34d23'}
302
+ ></Image>
303
+
304
+ 添加跨域规则,允许你的域名(在上文是 `https://your-project.vercel.app`)来源的请求:
305
+
306
+ <Image
307
+ alt={'配置允许你的站点域名'}
308
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/dfcc2cb3-2958-4498-a8a4-51bec584fe7d'}
309
+ ></Image>
310
+
311
+ 示例配置如下:
312
+
313
+ ```json
314
+ [
315
+ {
316
+ "AllowedOrigins": ["https://your-project.vercel.app"],
317
+ "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
318
+ "AllowedHeaders": ["*"]
319
+ }
320
+ ]
321
+ ```
322
+
323
+ 配置后点击保存即可。
324
+
325
+ </Steps>
326
+
327
+ ## 四、部署并验证
328
+
329
+ 通过上述步骤之后,我们应该就完成了服务端数据库的配置。接下来我们可以将 LobeChat 部署到 Vercel 上,然后访问你的 Vercel 链接,验证服务端数据库是否正常工作。
330
+
331
+ <Steps>
332
+ ### 重新部署最新的 commit
333
+
334
+ 配置好环境变量后,你需要重新部署最新的 commit,并等待部署完成。
335
+
336
+ <Image
337
+ alt={'重新部署最新的 commit'}
338
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/b3a78112-adc8-4837-b4e3-48f67058f16e'}
339
+ ></Image>
340
+
341
+ ### 检查功能是否正常
342
+
343
+ 如果你点击左上角登录,可以正常显示登录弹窗,那么说明你已经配置成功了,尽情享用吧~
344
+
345
+ <Image
346
+ alt={'用户登录弹窗'}
347
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/da84edc3-46f7-4e2b-a0cd-dc33a98bf5cb'}
348
+ ></Image>
349
+
350
+ <Image
351
+ alt={'登录成功状态'}
352
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/9cb5150d-6e1e-4c59-9a18-4e418dce1a5d'}
353
+ ></Image>
354
+
355
+ </Steps>
356
+
357
+ ## 附录
358
+
359
+ ### 服务端数据库环境变量一览
360
+
361
+ 为方便一键复制,在此汇总配置服务端数据所需要的环境变量:
362
+
363
+ ```shell
364
+ # 指定服务模式为 server
365
+ NEXT_PUBLIC_SERVICE_MODE=server
366
+
367
+ # Postgres 数据库 URL
368
+ DATABASE_URL=
369
+ KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
370
+
371
+ # Clerk 相关配置
372
+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
373
+ CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
374
+ CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
375
+
376
+ # S3 相关配置
377
+ # S3 秘钥
378
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
379
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
380
+
381
+ # 存储桶的名称
382
+ S3_BUCKET=lobechat
383
+ # 存储桶的请求端点
384
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
385
+ # 存储桶对外的访问域名
386
+ NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com
387
+ # 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
388
+ # S3_REGION=us-west-1
389
+ ```
@@ -1,3 +1,17 @@
1
+ ---
2
+ title: Share Settings via URL - Import and Export Configuration Settings
3
+ description: >-
4
+ Learn how to import and export configuration settings for LobeChat via URL.
5
+ Understand the supported settings, URL format, and parameter schema for
6
+ keyVaults and languageModel.
7
+ tags:
8
+ - Share Settings
9
+ - URL Import
10
+ - URL Export
11
+ - Configuration Settings
12
+ - LobeChat
13
+ - Parameter Schema
14
+ ---
1
15
  # Share settings via URL
2
16
 
3
17
  LobeChat support import settings from external URL to quickly set up LobeChat configuration.
@@ -1,3 +1,16 @@
1
+ ---
2
+ title: URL 分享设置参数 - LobeChat 配置快速设置
3
+ description: 了解如何从外部 URL 导入和导出 LobeChat 的设置参数,包括 keyVaults 和 languageModel,以及参数格式和类型。
4
+ tags:
5
+ - URL 分享
6
+ - 设置参数
7
+ - LobeChat
8
+ - keyVaults
9
+ - languageModel
10
+ - JSON 格式
11
+ - URL 导入
12
+ - URL 导出
13
+ ---
1
14
  # URL 分享设置参数
2
15
 
3
16
  LobeChat 支持从外部 URL 导入设置参数,以便于快速设置 LobeChat 的配置。
@@ -101,38 +101,38 @@ OPENAI_MODEL_LIST=-gpt-4,-gpt-4-32k,-gpt-3.5-turbo-16k,gpt-3.5-turbo-1106=gpt-3.
101
101
  ```bash
102
102
  #!/bin/bash
103
103
  # auto-update-lobe-chat.sh
104
-
104
+
105
105
  # 设置代理(可选)
106
- export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
107
-
106
+ # export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
107
+
108
108
  # 拉取最新的镜像并将输出存储在变量中
109
109
  output=$(docker pull lobehub/lobe-chat:latest 2>&1)
110
-
110
+
111
111
  # 检查拉取命令是否成功执行
112
112
  if [ $? -ne 0 ]; then
113
113
  exit 1
114
114
  fi
115
-
115
+
116
116
  # 检查输出中是否包含特定的字符串
117
117
  echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
118
-
118
+
119
119
  # 如果镜像已经是最新的,则不执行任何操作
120
120
  if [ $? -eq 0 ]; then
121
121
  exit 0
122
122
  fi
123
-
124
- echo "Detected Lobe-Chat update"
125
-
123
+
124
+ echo "Detected lobe-chat update"
125
+
126
126
  # 删除旧的容器
127
- echo "Removed: $(docker rm -f Lobe-Chat)"
128
-
129
- # 运行新的容器
130
- echo "Started: $(docker run -d --network=host --env-file /path/to/lobe.env --name=Lobe-Chat --restart=always lobehub/lobe-chat)"
131
-
127
+ echo "Removed: $(docker rm -f lobe-chat)"
128
+
129
+ # 运行新的容器(请将env配置文件地址改为你的实际地址)
130
+ echo "Started: $(docker run -d --network=host --env-file path/to/lobe.env --name=lobe-chat --restart=always lobehub/lobe-chat)"
131
+
132
132
  # 打印更新的时间和版本
133
133
  echo "Update time: $(date)"
134
134
  echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
135
-
135
+
136
136
  # 清理不再使用的镜像
137
137
  docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
138
138
  echo "Removed old images."
@@ -0,0 +1,60 @@
1
+ ---
2
+ title: Support Multi-User Management - Identity Verification Solutions
3
+ description: >-
4
+ Explore LobeChat's user authentication solutions with next-auth and Clerk for
5
+ flexible and secure user management. Learn about features like user
6
+ registration, session management, multi-factor authentication, and more.
7
+ tags:
8
+ - Multi-User Management
9
+ - Identity Verification
10
+ - next-auth
11
+ - Clerk
12
+ - User Authentication
13
+ - Session Management
14
+ - Multi-Factor Authentication
15
+ - User Management
16
+ ---
17
+ # Support Multi-User Management
18
+
19
+ <Image
20
+ alt={'Identity Verification System'}
21
+ cover
22
+ src={'https://github.com/lobehub/lobe-chat/assets/17870709/8ce70e15-40df-451e-b700-66090fe5b8c2'}
23
+ />
24
+
25
+ In modern applications, user management and identity verification are essential functions. To meet the diverse needs of different users, LobeChat provides two main user authentication and management solutions: `next-auth` and `Clerk`. Whether you are looking for simple user registration and login or need advanced multi-factor authentication and user management, LobeChat can flexibly accommodate your requirements.
26
+
27
+ ## next-auth: Flexible and Powerful Identity Verification Library
28
+
29
+ LobeChat integrates `next-auth`, a flexible and powerful identity verification library that supports various authentication methods, including OAuth, email login, and credential login. With `next-auth`, you can easily achieve the following functions:
30
+
31
+ - **User Registration and Login**: Support various authentication methods to meet different user needs.
32
+ - **Session Management**: Efficiently manage user sessions to ensure security.
33
+ - **Social Login**: Support quick login via various social platforms.
34
+ - **Data Security**: Ensure the security and privacy of user data.
35
+
36
+ <Callout type={'warning'}>
37
+ Due to workload constraints, integration of next-auth with a server-side database has not been implemented yet. If you need to use a server-side database, please use Clerk.
38
+ </Callout>
39
+
40
+ <Callout type={'info'}>
41
+ For information on using Next-Auth, you can refer to [Authentication Services - Next Auth](/docs/self-hosting/advanced/authentication#next-auth).
42
+ </Callout>
43
+
44
+ ## Clerk: Modern User Management Platform
45
+
46
+ For users requiring advanced user management features, LobeChat also supports [Clerk](https://clerk.com), a modern user management platform. Clerk offers richer functionality to help you achieve higher security and flexibility:
47
+
48
+ - **Multi-Factor Authentication (MFA)**: Provides higher security protection.
49
+ - **User Profile Management**: Conveniently manage user information and configurations.
50
+ - **Login Activity Monitoring**: Real-time monitoring of user login activities to ensure account security.
51
+ - **Scalability**: Supports complex user management requirements.
52
+
53
+ <Callout type={'info'}>
54
+ For information on using Clerk, you can refer to [Authentication Services - Clerk](/docs/self-hosting/advanced/authentication#clerk) .
55
+ </Callout>
56
+
57
+ <Callout type={'tip'}>
58
+ If you need to use Clerk in conjunction with a server-side database, you can refer to the "Configuring Authentication Services" section in [Deploying with a Server-Side Database](/docs/self-hosting/advanced/server-database).
59
+ </Callout>
60
+
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: 多用户管理支持
3
+ description: LobeChat 提供了多种用户认证和管理方案,以满足不同用户的需求。
4
+ tags:
5
+ - LobeChat
6
+ - 用户管理
7
+ - next-auth
8
+ - Clerk
9
+ - 身份验证
10
+ - 多因素认证
11
+ ---
12
+
13
+ # 身份验证系统 / 多用户管理支持
14
+
15
+ <Image
16
+ alt={'身份验证系统'}
17
+ cover
18
+ src={'https://github.com/lobehub/lobe-chat/assets/17870709/8ce70e15-40df-451e-b700-66090fe5b8c2'}
19
+ />
20
+
21
+ 在现代应用中,用户管理和身份验证是至关重要的功能。为满足不同用户的多样化需求,LobeChat 提供了两种主要的用户认证和管理方案:`next-auth` 和 `Clerk`。无论您是追求简便的用户注册登录,还是需要更高级的多因素认证和用户管理,LobeChat 都可以灵活实现。
22
+
23
+ ## next-auth:灵活且强大的身份验证库
24
+
25
+ LobeChat 集成了 `next-auth`,一个灵活且强大的身份验证库,支持多种身份验证方式,包括 OAuth、邮件登录、凭证登录等。通过 `next-auth`,您可以轻松实现以下功能:
26
+
27
+ - **用户注册和登录**:支持多种认证方式,满足不同用户的需求。
28
+ - **会话管理**:高效管理用户会话,确保安全性。
29
+ - **社交登录**:支持多种社交平台的快捷登录。
30
+ - **数据安全**:保障用户数据的安全性和隐私性。
31
+
32
+ <Callout type={'warning'}>
33
+ 由于工作量原因,目前还没有实现 next-auth 与服务端数据库的集成,如果需要使用服务端数据库,请使用
34
+ Clerk 。
35
+ </Callout>
36
+
37
+ <Callout type={'info'}>
38
+ 关于 Next-Auth 的使用,可以查阅 [身份验证服务 - Next
39
+ Auth](/zh/docs/self-hosting/advanced/authentication#next-auth)。
40
+ </Callout>
41
+
42
+ ## Clerk:现代化用户管理平台
43
+
44
+ 对于需要更高级用户管理功能的用户,LobeChat 还支持 [Clerk](https://clerk.com) ,一个现代化的用户管理平台。Clerk 提供了更丰富的功能,帮助您实现更高的安全性和灵活性:
45
+
46
+ - **多因素认证 (MFA)**:提供更高的安全保障。
47
+ - **用户配置文件管理**:便捷管理用户信息和配置。
48
+ - **登录活动监控**:实时监控用户登录活动,确保账户安全。
49
+ - **扩展性**:支持复杂的用户管理需求。
50
+
51
+ <Callout type={'info'}>
52
+ 关于 Clerk 的使用,可以查阅 [身份验证服务 - Clerk](/zh/docs/self-hosting/advanced/authentication#clerk)。
53
+ </Callout>
54
+
55
+ <Callout type={'tip'}>
56
+ 如果需要在服务端数据库中搭配使用 Clerk 的使用,可以查阅 [使用服务端数据库部署](/zh/docs/self-hosting/advanced/server-database) 中的「配置身份验证服务」部分。
57
+ </Callout>
58
+
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: LobeChat 支持本地 / 云端数据库存储
3
+ description: LobeChat 支持本地 / 云端数据存储,既能实现 Local First,同时支持数据云同步。
4
+ tags:
5
+ - LobeChat
6
+ - IndexedDB
7
+ - Postgres
8
+ - Local First
9
+ - 数据云同步
10
+ - 数据库
11
+ ---
12
+ # Local / Cloud Data Storage
13
+
14
+ <Image
15
+ alt={'Local / Cloud Data Storage'}
16
+ cover
17
+ src={'https://github.com/lobehub/lobe-chat/assets/17870709/acf39ea2-74b3-46ae-8eb8-54a51f7f1d36'}
18
+ />
19
+
20
+ In modern application development, the choice of data storage solution is crucial. To meet the needs of different users, LobeChat offers flexible configurations that support both local and server-side databases. Whether you prioritize data privacy and control or seek a convenient user experience, LobeChat can provide excellent solutions for you.
21
+
22
+ ## Local Database: Data Control and Privacy Protection
23
+
24
+ For users who prefer more control over their data and value privacy protection, LobeChat offers support for local databases. By using IndexedDB as the storage solution and combining it with dexie as an Object-Relational Mapping (ORM) tool, LobeChat achieves efficient data management.
25
+
26
+ Additionally, we have introduced Conflict-Free Replicated Data Type (CRDT) technology to ensure a seamless multi-device synchronization experience. This experimental feature aims to provide users with greater autonomy and data security.
27
+
28
+ <Callout type={'info'}>LobeChat defaults to the local database solution to reduce the onboarding cost for new users.</Callout>
29
+
30
+ Furthermore, we have attempted to introduce CRDT technology to achieve cross-device synchronization based on the local database. This experimental feature aims to provide users with greater autonomy and data security.
31
+
32
+ ## Server-Side Database: Convenient and Efficient User Experience
33
+
34
+ For users who seek a convenient user experience, LobeChat supports PostgreSQL as the server-side database. By managing data with Dirzzle ORM and combining it with Clerk for authentication, LobeChat can offer users an efficient and reliable server-side data management solution.
35
+
36
+ ### Server-Side Database Technology Stack
37
+
38
+ - **DB**: PostgreSQL (Neon is the default)
39
+ - **ORM**: Dirzzle ORM
40
+ - **Auth**: Clerk
41
+ - **Server Router**: tRPC
42
+
43
+ ## Deployment Solution Selection Guide
44
+
45
+ ### 1. Local Database
46
+
47
+ The local database solution is suitable for users who wish to have strict control over their data. With LobeChat's support for local databases, you can securely store and manage data without relying on external servers. This solution is particularly suitable for users with high requirements for data privacy.
48
+
49
+ ### 2. Server-Side Database
50
+
51
+ The server-side database solution is ideal for users who want to simplify data management processes and enjoy a convenient user experience. Through server-side databases and user authentication, LobeChat can ensure the security and efficiency of data. If you want to learn how to configure a server-side database, please refer to our [detailed documentation](/docs/self-hosting/advanced/server-database).
52
+
53
+ Whether you choose a local database or a server-side database, LobeChat can provide you with an excellent user experience.
54
+