@lobehub/chat 1.12.0 → 1.12.2

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.12.2](https://github.com/lobehub/lobe-chat/compare/v1.12.1...v1.12.2)
6
+
7
+ <sup>Released on **2024-08-22**</sup>
8
+
9
+ <br/>
10
+
11
+ <details>
12
+ <summary><kbd>Improvements and Fixes</kbd></summary>
13
+
14
+ </details>
15
+
16
+ <div align="right">
17
+
18
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
19
+
20
+ </div>
21
+
22
+ ### [Version 1.12.1](https://github.com/lobehub/lobe-chat/compare/v1.12.0...v1.12.1)
23
+
24
+ <sup>Released on **2024-08-21**</sup>
25
+
26
+ #### 🐛 Bug Fixes
27
+
28
+ - **misc**: Fix embeddings multi-insert when there is issues with async task.
29
+
30
+ <br/>
31
+
32
+ <details>
33
+ <summary><kbd>Improvements and Fixes</kbd></summary>
34
+
35
+ #### What's fixed
36
+
37
+ - **misc**: Fix embeddings multi-insert when there is issues with async task, closes [#3530](https://github.com/lobehub/lobe-chat/issues/3530) ([e2cfff7](https://github.com/lobehub/lobe-chat/commit/e2cfff7))
38
+
39
+ </details>
40
+
41
+ <div align="right">
42
+
43
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
44
+
45
+ </div>
46
+
5
47
  ## [Version 1.12.0](https://github.com/lobehub/lobe-chat/compare/v1.11.9...v1.12.0)
6
48
 
7
49
  <sup>Released on **2024-08-21**</sup>
@@ -218,5 +218,7 @@ CMD \
218
218
  fi; \
219
219
  # Run migration
220
220
  node "/app/docker.cjs"; \
221
- # Run the server
222
- ${PROXYCHAINS} node "/app/server.js";
221
+ if [ "$?" -eq "0" ]; then \
222
+ # Run the server
223
+ ${PROXYCHAINS} node "/app/server.js"; \
224
+ fi;
package/README.md CHANGED
@@ -266,14 +266,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
266
266
 
267
267
  <!-- AGENT LIST -->
268
268
 
269
- | Recent Submits | Description |
270
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
271
- | [RO-SCIRAW Prompt Word Expert](https://chat-preview.lobehub.com/market?agent=rosciraw)<br/><sup>By **[kirklin](https://github.com/kirklin)** on **2024-08-06**</sup> | The RO-SCIRAW framework, created by Kirk Lin, is a methodology for prompt words that provides a new paradigm for building highly precise and efficient prompt words. Please enter the information for the persona you want to create.<br/>`prompt-word-framework` |
272
- | [Social Media Sage](https://chat-preview.lobehub.com/market?agent=social-media-sage)<br/><sup>By **[thedivergentai](https://github.com/thedivergentai)** on **2024-08-06**</sup> | Social Media Marketing expert crafting winning strategies for brands and empowering businesses to thrive online<br/>`social-media-marketing` `branding` `growth-strategies` |
273
- | [Omnipedia](https://chat-preview.lobehub.com/market?agent=omnipedia)<br/><sup>By **[thedivergentai](https://github.com/thedivergentai)** on **2024-08-02**</sup> | Expert in providing high-quality, well-researched information on various topics, including history, science, literature, art, and more. Skilled in summarizing complex topics, assisting with research tasks, and offering creative prompts<br/>`artificial-intelligence` `information` `education` `communication` |
274
- | [Code Snark Master](https://chat-preview.lobehub.com/market?agent=code-snark-master)<br/><sup>By **[leter](https://github.com/leter)** on **2024-07-29**</sup> | Specializes in sharp criticism of code, sarcastically pointing out inefficiencies and readability issues<br/>`tech-leadership` `code-review` `sarcastic-style` `programming-consultation` |
275
-
276
- > 📊 Total agents: [<kbd>**312**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
269
+ | Recent Submits | Description |
270
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
271
+ | [Variable Name Conversion Expert](https://chat-preview.lobehub.com/market?agent=variable-name-conversion)<br/><sup>By **[zengyishou](https://github.com/zengyishou)** on **2024-08-21**</sup> | In software development, naming variables is a common yet relatively time-consuming task. This assistant can automatically convert Chinese variable names into English variable names that conform to camelCase, PascalCase, snake_case, kebab-case, and constant naming conventions based on specific naming rules. This not only improves code readability but also alleviates the frustration of variable naming.<br/>`software-development` `variable-naming` `chinese-to-english` `code-standards` `automatic-conversion` |
272
+ | [Commit Message Generator](https://chat-preview.lobehub.com/market?agent=commit-assistant)<br/><sup>By **[cyicz123](https://github.com/cyicz123)** on **2024-08-12**</sup> | Expert at generating precise Git commit messages<br/>`programming` `git` `commit-message` `code-review` |
273
+ | [RO-SCIRAW Prompt Word Expert](https://chat-preview.lobehub.com/market?agent=rosciraw)<br/><sup>By **[kirklin](https://github.com/kirklin)** on **2024-08-06**</sup> | The RO-SCIRAW framework, created by Kirk Lin, is a methodology for prompt words that provides a new paradigm for building highly precise and efficient prompt words. Please enter the information for the persona you want to create.<br/>`prompt-word-framework` |
274
+ | [Social Media Sage](https://chat-preview.lobehub.com/market?agent=social-media-sage)<br/><sup>By **[thedivergentai](https://github.com/thedivergentai)** on **2024-08-06**</sup> | Social Media Marketing expert crafting winning strategies for brands and empowering businesses to thrive online<br/>`social-media-marketing` `branding` `growth-strategies` |
275
+
276
+ > 📊 Total agents: [<kbd>**314**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
277
277
 
278
278
  <!-- AGENT LIST -->
279
279
 
package/README.zh-CN.md CHANGED
@@ -254,14 +254,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
254
254
 
255
255
  <!-- AGENT LIST -->
256
256
 
257
- | 最近新增 | 助手说明 |
258
- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
259
- | [RO-SCIRAW 提示词专家](https://chat-preview.lobehub.com/market?agent=rosciraw)<br/><sup>By **[kirklin](https://github.com/kirklin)** on **2024-08-06**</sup> | RO-SCIRAW 框架是由 Kirk Lin 开创的提示词方法论,为构建高度精确和高效的提示词提供了一个全新的范式。请输入你要创建的分身信息。<br/>`提示词框架` |
260
- | [社交媒体专家](https://chat-preview.lobehub.com/market?agent=social-media-sage)<br/><sup>By **[thedivergentai](https://github.com/thedivergentai)** on **2024-08-06**</sup> | 社交媒体营销专家,为品牌制定成功策略,帮助企业在线蓬勃发展<br/>`社交媒体营销` `品牌塑造` `增长策略` |
261
- | [Omnipedia](https://chat-preview.lobehub.com/market?agent=omnipedia)<br/><sup>By **[thedivergentai](https://github.com/thedivergentai)** on **2024-08-02**</sup> | 专业提供高质量、深入研究的各种主题信息,包括历史、科学、文学、艺术等。擅长总结复杂主题,协助研究任务,并提供创意启示。<br/>`artificial-intelligence` `information` `education` `communication` |
262
- | [代码毒舌大师](https://chat-preview.lobehub.com/market?agent=code-snark-master)<br/><sup>By **[leter](https://github.com/leter)** on **2024-07-29**</sup> | 擅长尖刻批评代码,讽刺性地指出低效和可读性问题<br/>`技术领导` `代码审查` `讽刺风格` `编程咨询` |
263
-
264
- > 📊 Total agents: [<kbd>**312**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
257
+ | 最近新增 | 助手说明 |
258
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
259
+ | [开发变量名转换专家](https://chat-preview.lobehub.com/market?agent=variable-name-conversion)<br/><sup>By **[zengyishou](https://github.com/zengyishou)** on **2024-08-21**</sup> | 在软件开发过程中,命名变量是一项常见却相对耗时的任务。本助手能够根据特定的命名规则自动将中文变量名转换为符合小驼峰、大驼峰、下划线、横线以及常量命名规范的英文变量名。这不仅提高了代码的可读性,还解决了变量命名的苦恼。<br/>`软件开发` `变量命名` `中文转英文` `代码规范` `自动转换` |
260
+ | [提交信息生成器](https://chat-preview.lobehub.com/market?agent=commit-assistant)<br/><sup>By **[cyicz123](https://github.com/cyicz123)** on **2024-08-12**</sup> | 擅长生成精准的 Git 提交信息<br/>`编程` `git` `提交信息` `代码审查` |
261
+ | [RO-SCIRAW 提示词专家](https://chat-preview.lobehub.com/market?agent=rosciraw)<br/><sup>By **[kirklin](https://github.com/kirklin)** on **2024-08-06**</sup> | RO-SCIRAW 框架是由 Kirk Lin 开创的提示词方法论,为构建高度精确和高效的提示词提供了一个全新的范式。请输入你要创建的分身信息。<br/>`提示词框架` |
262
+ | [社交媒体专家](https://chat-preview.lobehub.com/market?agent=social-media-sage)<br/><sup>By **[thedivergentai](https://github.com/thedivergentai)** on **2024-08-06**</sup> | 社交媒体营销专家,为品牌制定成功策略,帮助企业在线蓬勃发展<br/>`社交媒体营销` `品牌塑造` `增长策略` |
263
+
264
+ > 📊 Total agents: [<kbd>**314**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
265
265
 
266
266
  <!-- AGENT LIST -->
267
267
 
@@ -30,8 +30,7 @@ Before using NextAuth, please set the following variables in LobeChat's environm
30
30
  | Environment Variable | Type | Description |
31
31
  | --- | --- | --- |
32
32
  | `NEXT_AUTH_SECRET` | Required | The key used to encrypt Auth.js session tokens. You can use the following command: `openssl rand -base64 32`, or visit `https://generate-secret.vercel.app/32` to generate the key. |
33
- | `ACCESS_CODE` | Required | Add a password to access this service. You can set a sufficiently long random password to "disable" access code authorization. |
34
- | `NEXTAUTH_URL` | Optional | This URL specifies the callback address for Auth.js when performing OAuth verification. Set this only if the default generated redirect address is incorrect. `https://example.com/api/auth` |
33
+ | `NEXTAUTH_URL` | Required | This URL specifies the callback address for Auth.js when performing OAuth verification. Set this only if the default generated redirect address is incorrect. `https://example.com/api/auth` |
35
34
  | `NEXT_AUTH_SSO_PROVIDERS` | Optional | This environment variable is used to enable multiple identity verification sources simultaneously, separated by commas, for example, `auth0,azure-ad,authentik`. |
36
35
 
37
36
  Currently supported identity verification services include:
@@ -27,8 +27,7 @@ LobeChat 与 Clerk 做了深度集成,能够为用户提供一个更加安全
27
27
  | 环境变量 | 类型 | 描述 |
28
28
  | --- | --- | --- |
29
29
  | `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令: `openssl rand -base64 32`,或者访问 `https://generate-secret.vercel.app/32` 生成秘钥。 |
30
- | `ACCESS_CODE` | 必选 | 添加访问此服务的密码,你可以设置一个足够长的随机密码以 “禁用” 访问码授权 |
31
- | `NEXTAUTH_URL` | 可选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://example.com/api/auth` |
30
+ | `NEXTAUTH_URL` | 必选 | URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://example.com/api/auth` |
32
31
  | `NEXT_AUTH_SSO_PROVIDERS` | 可选 | 该环境变量用于同时启用多个身份验证源,以逗号 `,` 分割,例如 `auth0,azure-ad,authentik`。 |
33
32
 
34
33
  目前支持的身份验证服务有:
@@ -44,22 +44,4 @@ Unstructured.io 是一个强大的文档处理工具。
44
44
  - **应用场景**:处理 PDF、Word 等非纯文本格式的文档
45
45
  - **注意事项**:评估处理需求,根据文档复杂度决定是否部署
46
46
 
47
- ## 部署注意事项
48
-
49
- 1. **数据安全**:确保所有组件都有适当的安全措施,特别是涉及敏感数据时。
50
-
51
- 2. **性能优化**:
52
-
53
- - 为 PostgreSQL 和 PGVector 配置足够的计算资源
54
- - 优化 S3 存储的访问策略和缓存机制
55
-
56
- 3. **可扩展性**:设计架构时考虑未来可能的数据增长和用户增加。
57
-
58
- 4. **监控与维护**:
59
-
60
- - 实施日志记录和监控系统
61
- - 定期备份数据库和对象存储
62
-
63
- 5. **合规性**:确保部署符合相关的数据保护法规和隐私政策。
64
-
65
47
  通过正确配置和集成这些核心组件,您可以为 LobeChat 构建一个强大、高效的知识库系统。每个组件都在整体架构中扮演着关键角色,共同支持高级的文档管理和智能检索功能。
@@ -7,21 +7,62 @@ tags:
7
7
  - 图片上传
8
8
  - 文件存储
9
9
  ---
10
+
10
11
  # 配置 S3 存储服务
11
12
 
12
- LobeChat 在 [很早以前](https://x.com/lobehub/status/1724289575672291782) 就支持了多模态的 AI 会话,其中涉及到图片上传给 AI 的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 IndexedDB 数据库,但在服务端数据库中这个方案并不可行,在 Postgres 中直接存储文件类数据会大大浪费数据库存储空间,并拖慢计算性能。
13
+ LobeChat 在 [很早以前](https://x.com/lobehub/status/1724289575672291782) 就支持了多模态的 AI 会话,其中涉及到图片上传给大模型的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 IndexedDB 数据库,但在服务端数据库中这个方案并不可行。因为在 Postgres 中直接存储文件类二进制数据会大大浪费宝贵的数据库存储空间,并拖慢计算性能。
13
14
 
14
- 这块最佳实践是使用文件存储服务(S3)来存储图片文件,同时 S3 也是文件上传/知识库功能所依赖的存储方案。
15
+ 这块最佳实践是使用文件存储服务(S3)来存储图片文件,同时 S3 也是文件上传/知识库功能所依赖的大容量静态文件存储方案。
15
16
 
16
17
  <Callout type={'info'}>
17
18
  在本文档库中,S3 所指代的是指兼容 S3 存储方案,即支持 Amazon S3 API 的对象存储系统,常见例如
18
19
  Cloudflare R2 、阿里云 OSS,可以自部署的 minio 等均支持 S3 兼容 API。
19
20
  </Callout>
20
21
 
21
- 目前文档中包含的 S3 配置教程有:
22
+ ## 核心环境变量
23
+
24
+ <Steps>
25
+ ### `S3_ACCESS_KEY_ID` 与 `S3_SECRET_ACCESS_KEY`
26
+
27
+ 所有 S3 兼容存储服务都需要的两个密钥,用于访问 S3 存储服务,不详细展开。
28
+
29
+ ### `S3_ENDPOINT`
30
+
31
+ 存储桶的请求端点, 注意此处链接不应该包含存储桶的名称。
32
+
33
+ <Callout type={'warning'}>`S3_ENDPOINT`必须删除后缀路径,否则会无法访问所上传文件</Callout>
34
+
35
+ 例如 Cloudflare 为:
36
+
37
+ ```shell
38
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
39
+ ```
40
+
41
+ ### `S3_BUCKET` 和 `S3_REGION`
42
+
43
+ 存储桶的名称和区域,`S3_BUCKET` 是必须的,用于指定存储桶的名称。 `S3_REGION` 是可选的,用于指定存储桶的区域,一般来说不需要添加,但某些服务商则需要配置。
44
+
45
+ ### `S3_SET_ACL`
46
+
47
+ 是否在上传文件时设置 ACL 为 `public-read`。该选项默认启用。如果服务商不支持为文件设置单独的 ACL(即所有文件继承存储桶的 ACL),启用此选项可能会导致请求错误,将 `S3_SET_ACL` 设置为 `0` 即可关闭。
48
+
49
+ ### `NEXT_PUBLIC_S3_DOMAIN`
50
+
51
+ 存储桶对外的访问域名,用于访问存储桶中的文件,这个地址需要**允许互联网可读**。 原因是 OpenAI 的 gpt-4o 等视觉模型识别图片时,OpenAI 会尝试在他们的服务器中下载这个图片链接,因此这个链接必须是公开可访问的,如果是私有的链接,OpenAI 将无法访问到这个图片,进而无法正常识别到图片内容。
52
+
53
+ <Callout type={'warning'}>
54
+ 此外,由于该访问域名往往是一个独立的网址,因此需要配置允许站点的跨域访问,否则会在浏览器中出现跨域问题。
55
+
56
+ </Callout>
57
+
58
+ </Steps>
59
+
60
+ ## S3 配置指南
61
+
62
+ 目前文档中包含的 S3 配置指南如下:
22
63
 
23
64
  <Cards>
24
65
  <Card href={'/zh/docs/self-hosting/advanced/s3/cloudflare-r2'} title={'Cloudflare R2'} />
25
66
  </Cards>
26
67
 
27
- 点击即可查看对应平台的教程,如果上述教程中不包含你所使用的 S3 服务商,欢迎提交 Pull Request ,将共同完善 S3 对象存储的指南。
68
+ 点击即可查看对应 S3 服务的部署指南,如果上述指南中不包含你所使用的 S3 服务商,欢迎提交 PR ,将共同完善 S3 对象存储的指南。
@@ -7,6 +7,7 @@ tags:
7
7
  - 数据库部署
8
8
  - Postgres
9
9
  ---
10
+
10
11
  # 使用 Docker 部署服务端数据库版
11
12
 
12
13
  <div style={{display:"flex", gap: 4}}>
@@ -19,37 +20,49 @@ tags:
19
20
  </div>
20
21
 
21
22
  <Callout type="info">
22
- 本文已经假定你了解了 LobeChat 服务端数据库版本的部署基本原理和流程,因此只包含核心环境变量配置的内容。如果你还不了解 LobeChat 服务端数据库版本的部署原理,请先查阅 [使用服务端数据库部署](/zh/docs/self-hosting/server-database) 。
23
+ 本文已经假定你了解了 LobeChat 服务端数据库版本(下简称 DB
24
+ 版)的部署基本原理和流程,因此只包含核心环境变量配置的内容。如果你还不了解 LobeChat DB
25
+ 版的部署原理,请先查阅 [使用服务端数据库部署](/zh/docs/self-hosting/server-database) 。
23
26
  </Callout>
24
27
 
25
28
  ## 在 Linux 服务器上部署
26
29
 
27
- 以下是在 Linux 服务器上部署 LobeChat 服务端数据库版本的流程:
30
+ 以下是在 Linux 服务器上部署 LobeChat DB 版的流程:
28
31
 
29
32
  <Steps>
30
33
 
31
34
  ### 创建 Postgres 数据库实例
32
35
 
33
- 请按照你自己的诉求创建一个 Postgres 数据库实例,例如:
36
+ 请按照你自己的诉求创建一个带有 PGVector 插件的 Postgres 数据库实例,例如:
34
37
 
35
38
  ```sh
36
- docker run --name my-postgres --network pg -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
39
+ docker network create pg
40
+
41
+ docker run --name my-postgres --network pg -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d pgvector/pgvector:pg16
37
42
  ```
38
43
 
39
- <Callout type="warning">
40
- 以上命令仅用于测试/演示,因为这个 pg 实例并没有包含持久化部分。
44
+ 上述指令会创建一个名为 `my-postgres`,并且网络为 `pg` 的 PG 实例,其中 `pgvector/pgvector:pg16` 是一个 Postgres 16 的镜像,且默认安装了 pgvector 插件。
45
+
46
+ <Callout type="info">
47
+ pgvector 插件为 Postgres 提供了向量搜索的能力,是 LobeChat 实现 RAG 的重要构件之一。
41
48
  </Callout>
42
49
 
43
- 上述指令会创建一个名为 `my-postgres`,并且网络为 `pg` 的 PG 实例。
50
+ <Callout type="warning">
51
+ 以上指令得到的 pg
52
+ 实例并没有指定持久化存储位置,因此仅用于测试/演示,生产环境请自行配置持久化存储。
53
+ </Callout>
44
54
 
45
55
  ### 创建名为 `lobe-chat.env` 文件用于存放环境变量:
46
56
 
47
57
  ```shell
48
- # DB 必须
58
+ #网站域名
59
+ APP_URL=https://your-prod-domain.com
60
+
61
+ # DB 必须的环境变量
49
62
  KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
50
63
  DATABASE_URL=postgres://postgres:mysecretpassword@my-postgres:5432/postgres
51
64
 
52
- # NEXT_AUTH 相关
65
+ # NEXT_AUTH 相关,可以使用 auth0、Azure AD、GitHub、Authentik、zitadel 等,如有其他接入诉求欢迎提 PR
53
66
  NEXT_AUTH_SECRET=3904039cd41ea1bdf6c93db0db96e250
54
67
  NEXT_AUTH_SSO_PROVIDERS=auth0
55
68
  NEXTAUTH_URL=https://your-prod-domain.com/api/auth
@@ -88,12 +101,15 @@ docker run -it -d -p 3210:3210 --network pg --env-file lobe-chat.env --name lobe
88
101
  </Steps>
89
102
 
90
103
  <Callout type="tip">
91
- 在我们官方的 Docker 镜像中,会在启动镜像前自动执行数据库 schema 的 migration ,我们会确保从一个空数据库到所有表正式可用的稳定性。因此我们建议你的数据库实例使用一个空表实例,进而省去手动维护表结构 migration 的成本。
104
+ 在我们官方的 Docker 镜像中,会在启动镜像前自动执行数据库 schema 的 migration
105
+ ,我们的官方镜像承诺「空数据库 ->
106
+ 完整表」这一段自动建表的稳定性。因此我们建议你的数据库实例使用一个空表实例,进而省去手动维护表结构或者
107
+ migration 的麻烦。
92
108
  </Callout>
93
109
 
94
110
  ## 在本地(Mac / Windows) 上使用
95
111
 
96
- LobeChat 的数据版本也支持直接在本地的 Mac/Windows 本地使用。
112
+ LobeChat DB 版也支持直接在本地的 Mac/Windows 本地使用。
97
113
 
98
114
  在此我们已假设你的本地有一个 5432 端口可用,账号为 `postgres` ,密码是 `mysecretpassword` 的 pg 实例,它在 `localhost:5432` 可用。
99
115
 
@@ -101,24 +117,26 @@ LobeChat 的数据版本也支持直接在本地的 Mac/Windows 本地使用。
101
117
 
102
118
  ```shell
103
119
  $ docker run -it -d --name lobe-chat-database -p 3210:3210 \
104
- -e DATABASE_URL=postgres://postgres:mysecretpassword@host.docker.internal:5432/postgres \
105
- -e KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk= \
106
- -e NEXT_AUTH_SECRET=3904039cd41ea1bdf6c93db0db96e250 \
107
- -e NEXT_AUTH_SSO_PROVIDERS=auth0 \
108
- -e AUTH0_CLIENT_ID=xxxxxx \
109
- -e AUTH0_CLIENT_SECRET=cSX_xxxxx \
110
- -e AUTH0_ISSUER=https://lobe-chat-demo.us.auth0.com \
111
- -e NEXTAUTH_URL=http://localhost:3210/api/auth \
112
- -e S3_ACCESS_KEY_ID=xxxxxxxxxx \
113
- -e S3_SECRET_ACCESS_KEY=xxxxxxxxxx \
114
- -e S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com \
115
- -e S3_BUCKET=lobechat \
116
- -e NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com \
117
- lobehub/lobe-chat-database
120
+ -e DATABASE_URL=postgres://postgres:mysecretpassword@host.docker.internal:5432/postgres \
121
+ -e KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk= \
122
+ -e NEXT_AUTH_SECRET=3904039cd41ea1bdf6c93db0db96e250 \
123
+ -e NEXT_AUTH_SSO_PROVIDERS=auth0 \
124
+ -e AUTH0_CLIENT_ID=xxxxxx \
125
+ -e AUTH0_CLIENT_SECRET=cSX_xxxxx \
126
+ -e AUTH0_ISSUER=https://lobe-chat-demo.us.auth0.com \
127
+ -e APP_URL=http://localhost:3210 \
128
+ -e NEXTAUTH_URL=http://localhost:3210/api/auth \
129
+ -e S3_ACCESS_KEY_ID=xxxxxxxxxx \
130
+ -e S3_SECRET_ACCESS_KEY=xxxxxxxxxx \
131
+ -e S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com \
132
+ -e S3_BUCKET=lobechat \
133
+ -e NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com \
134
+ lobehub/lobe-chat-database
118
135
  ```
119
136
 
120
137
  <Callout type="tip">
121
- `Docker` 在 `Windows` 和 `macOS` 上走的是虚拟机方案,如果使用 `localhost` / `127.0.0.1` ,将会走到自身容器的 `localhost`,此时请尝试用 `host.docker.internal` 替代 `localhost`
138
+ `Docker` 在 `Windows` 和 `macOS` 上走的是虚拟机方案,如果使用 `localhost` / `127.0.0.1`
139
+ ,将会走到自身容器的 `localhost`,此时请尝试用 `host.docker.internal` 替代 `localhost`
122
140
  </Callout>
123
141
 
124
142
  [docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  title: Deploy LobeChat with database on Vercel
3
3
  description: >-
4
- Learn how to deploy LobeChat with database on Vercel with ease, including: database, authentication and S3 storage service.
4
+ Learn how to deploy LobeChat with database on Vercel with ease, including:
5
+ database, authentication and S3 storage service.
5
6
  tags:
6
7
  - Deploy LobeChat
7
8
  - Vercel Deployment
@@ -9,15 +9,16 @@ tags:
9
9
  - 自定义域名
10
10
  ---
11
11
 
12
- # 使用 Zeabur 部署 LobeChat 数据库版
12
+ # 使用 Zeabur 部署 LobeChat 数据库版
13
13
 
14
14
  <Callout type="info">
15
- 本文假设你已经熟悉 LobeChat 服务器数据库版的部署基本原理和流程,因此只包含与核心环境变量配置相关的内容。如果你对 LobeChat 服务器数据库版的部署原理不熟悉,请先参考[部署服务器数据库](/en/docs/self-hosting/server-database)。
15
+ 本文假设你已经熟悉 LobeChat
16
+ 服务器数据库版的部署基本原理和流程,因此只包含与核心环境变量配置相关的内容。如果你对 LobeChat
17
+ 服务器数据库版的部署原理不熟悉,请先参考[部署服务器数据库](/en/docs/self-hosting/server-database)。
16
18
  </Callout>
17
19
 
18
20
  如果你想在 Zeabur 上部署 LobeChat 数据库版,可以按照以下步骤操作:
19
21
 
20
- ## Create an Auth0 Account for Authentication
21
22
  ## 创建 Auth0 账户以进行身份验证
22
23
 
23
24
  [在 Zeabur 上的 LobeChat 数据库模板](https://zeabur.com/templates/RRSPSD) 使用 NextAuth 和 Auth0 作为身份验证提供者,因此你需要创建一个 Auth0 账户以获取所需的凭证。
@@ -12,13 +12,13 @@ tags:
12
12
 
13
13
  # 使用服务端数据库部署
14
14
 
15
- LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用服务端数据库。LobeChat 采用了 Postgres 作为后端存储数据库。
15
+ LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用服务端数据库(下简称 DB 版)。LobeChat 采用了 Postgres 作为后端存储数据库。
16
16
 
17
17
  <Callout>
18
18
  PostgreSQL是一种强大的开源关系型数据库管理系统,具备高度扩展性和标准SQL支持。它提供了丰富的数据类型、并发处理、数据完整性、安全性及可编程性,适用于复杂应用和大规模数据管理。
19
19
  </Callout>
20
20
 
21
- 本文将从框架角度介绍在任何一个平台中部署服务端数据库版 LobeChat 的流程和原理,让你知其然也知其所以然,最后可以根据自己的实际情况进行部署。
21
+ 本文将从框架角度介绍在任何一个平台中部署 DB 版 LobeChat 的流程和原理,让你知其然也知其所以然,最后可以根据自己的实际情况进行部署。
22
22
 
23
23
  如你已经熟悉完整原理,可以查看各个平台的部署指南快速开始:
24
24
 
@@ -26,7 +26,7 @@ LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用
26
26
 
27
27
  ---
28
28
 
29
- 对于 LobeChat 的服务端数据库版,正常的部署流程都需要包含三个模块的配置:
29
+ 对于 LobeChat 的 DB 版,正常的部署流程都需要包含三个模块的配置:
30
30
 
31
31
  1. 数据库配置;
32
32
  2. 身份验证服务配置;
@@ -39,9 +39,12 @@ LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用
39
39
  - `A.` 使用 Vercel / Neon 等 Serverless Postgres 实例;
40
40
  - `B.` 使用 Docker / Railway / Zeabur 等自部署 Postgres 实例,下统称 Node Postgres 实例;
41
41
 
42
- 两者的配置方式在环境变量的取值上会略有一点区别。
42
+ <Callout>两者的配置方式在环境变量的取值上会略有一点区别,其他方面是一样的。</Callout>
43
+
44
+ 同时,由于我们支持了文件对话/知识库对话的能力,因此我们需要为 Postgres 安装 `pgvector` 插件,该插件提供了向量搜索的能力,是 LobeChat 实现 RAG 的重要构件之一。
43
45
 
44
46
  <Steps>
47
+
45
48
  ### `NEXT_PUBLIC_SERVICE_MODE`
46
49
 
47
50
  LobeChat 同时支持了客户端数据库和服务端数据库,因此我们提供了一个环境变量用于切换模式,这个变量为 `NEXT_PUBLIC_SERVICE_MODE`,该值默认为 `client`。
@@ -53,6 +56,13 @@ LobeChat 同时支持了客户端数据库和服务端数据库,因此我们
53
56
  Docker 镜像部署,则无需再配置该环境变量。
54
57
  </Callout>
55
58
 
59
+ <Callout type={'tip'}>
60
+ 由于 `NEXT_PUBLIC` 开头的环境变量是在前端代码中生效的,而因此无法通过容器运行时注入进行修改。 (`next.js`的参考文档 [Configuring: Environment Variables | Next.js (nextjs.org)](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables) ) 这也是为什么我们选择再打一个 DB 版镜像的原因。
61
+
62
+ 如果你需要在 Docker 部署中修改 `NEXT_PUBLIC` 前缀的变量,你必须自行构建镜像,在 build 时就把自己的 `NEXT_PUBLIC` 开头的环境变量打进去。
63
+
64
+ </Callout>
65
+
56
66
  ### `DATABASE_URL`
57
67
 
58
68
  配置数据库,核心是添加 `DATABASE_URL` 环境变量,将你准备好的 Postgres 数据库连接 URL 填入其中。数据库连接 URL 的通常格式为 `postgres://username:password@host:port/database`。
@@ -120,49 +130,15 @@ NextAuth 是一个开源的身份验证库,支持多种身份验证提供商
120
130
 
121
131
  ## 配置 S3 存储服务
122
132
 
123
- LobeChat 在 [很早以前](https://x.com/lobehub/status/1724289575672291782) 就支持了多模态的 AI 会话,其中涉及到图片上传给大模型的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 IndexedDB 数据库,但在服务端数据库中这个方案并不可行。因为在 Postgres 中直接存储文件类数据会大大浪费宝贵的数据库存储空间,并拖慢计算性能。
133
+ LobeChat 在 [很早以前](https://x.com/lobehub/status/1724289575672291782) 就支持了多模态的 AI 会话,其中涉及到图片上传给大模型的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 IndexedDB 数据库,但在服务端数据库中这个方案并不可行。因为在 Postgres 中直接存储文件类二进制数据会大大浪费宝贵的数据库存储空间,并拖慢计算性能。
124
134
 
125
- 这块最佳实践是使用文件存储服务(S3)来存储图片文件,同时 S3 也是后续文件上传/知识库功能所依赖的存储方案。
135
+ 这块最佳实践是使用文件存储服务(S3)来存储图片文件,同时 S3 也是文件上传/知识库功能所依赖的大容量静态文件存储方案。
126
136
 
127
137
  <Callout type={'info'}>
128
138
  在本文档库中,S3 所指代的是指兼容 S3 存储方案,即支持 Amazon S3 API 的对象存储系统,常见例如
129
139
  Cloudflare R2 、阿里云 OSS,可以自部署的 minio 等均支持 S3 兼容 API。
130
140
  </Callout>
131
141
 
132
- <Steps>
133
- ### `S3_ACCESS_KEY_ID` 与 `S3_SECRET_ACCESS_KEY`
134
-
135
- 所有 S3 兼容存储服务都需要的两个密钥,用于访问 S3 存储服务,不详细展开。
136
-
137
- ### `S3_ENDPOINT`
138
-
139
- 存储桶的请求端点, 注意此处链接不应该包含存储桶的名称。
140
-
141
- <Callout type={'warning'}>`S3_ENDPOINT`必须删除后缀路径,否则会无法访问所上传文件</Callout>
142
-
143
- 例如 Cloudflare 为:
144
-
145
- ```shell
146
- S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
147
- ```
148
-
149
- ### `S3_BUCKET` 和 `S3_REGION`
150
-
151
- 存储桶的名称和区域,`S3_BUCKET` 是必须的,用于指定存储桶的名称。 `S3_REGION` 是可选的,用于指定存储桶的区域,一般来说不需要添加,但某些服务商则需要配置。
152
-
153
- ### `S3_SET_ACL`
154
- 是否在上传文件时设置 ACL 为 `public-read`。该选项默认启用。如果服务商不支持为文件设置单独的 ACL(即所有文件继承存储桶的 ACL),启用此选项可能会导致请求错误,将 `S3_SET_ACL` 设置为 `0` 即可关闭。
155
-
156
- ### `NEXT_PUBLIC_S3_DOMAIN`
157
-
158
- 存储桶对外的访问域名,用于访问存储桶中的文件,这个地址需要**允许互联网可读**。 原因是 OpenAI 的 gpt-4o 等视觉模型识别图片时,OpenAI 会尝试在他们的服务器中下载这个图片链接,因此这个链接必须是公开可访问的,如果是私有的链接,OpenAI 将无法访问到这个图片,进而无法正常识别到图片内容。
159
-
160
- <Callout type={'warning'}>
161
- 此外,由于该访问域名往往是一个独立的网址,因此需要配置允许站点的跨域访问,否则会在浏览器中出现跨域问题。
162
- </Callout>
163
-
164
- </Steps>
165
-
166
142
  关于 S3 的详细配置指南,请参阅 [S3 对象存储](/zh/docs/self-hosting/advanced/s3) 了解详情。
167
143
 
168
144
  ## 开始部署
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -0,0 +1,18 @@
1
+ -- step 1: create a temporary table to store the rows we want to keep
2
+ CREATE TEMP TABLE embeddings_temp AS
3
+ SELECT DISTINCT ON (chunk_id) *
4
+ FROM embeddings
5
+ ORDER BY chunk_id, random();
6
+
7
+ -- step 2: delete all rows from the original table
8
+ DELETE FROM embeddings;
9
+
10
+ -- step 3: insert the rows we want to keep back into the original table
11
+ INSERT INTO embeddings
12
+ SELECT * FROM embeddings_temp;
13
+
14
+ -- step 4: drop the temporary table
15
+ DROP TABLE embeddings_temp;
16
+
17
+ -- step 5: now it's safe to add the unique constraint
18
+ ALTER TABLE "embeddings" ADD CONSTRAINT "embeddings_chunk_id_unique" UNIQUE("chunk_id");