@lobehub/chat 1.12.5 → 1.12.6
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/.env.example +1 -1
- package/CHANGELOG.md +25 -0
- package/Dockerfile.database +1 -0
- package/docs/self-hosting/advanced/s3/cloudflare-r2.mdx +2 -2
- package/docs/self-hosting/advanced/s3/cloudflare-r2.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/s3.mdx +1 -1
- package/docs/self-hosting/advanced/s3.zh-CN.mdx +1 -1
- package/docs/self-hosting/server-database/docker.mdx +2 -2
- package/docs/self-hosting/server-database/docker.zh-CN.mdx +2 -2
- package/docs/self-hosting/server-database/vercel.mdx +4 -4
- package/docs/self-hosting/server-database/vercel.zh-CN.mdx +6 -6
- package/package.json +1 -1
- package/src/config/file.ts +16 -1
- package/src/server/modules/S3/index.ts +1 -0
- package/src/server/routers/lambda/file.ts +1 -3
- package/src/server/utils/files.ts +1 -1
- package/src/services/file/server.ts +4 -0
package/.env.example
CHANGED
|
@@ -150,7 +150,7 @@ OPENAI_API_KEY=sk-xxxxxxxxx
|
|
|
150
150
|
#S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
151
151
|
|
|
152
152
|
# Public access domain for the bucket
|
|
153
|
-
#
|
|
153
|
+
#S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
154
154
|
|
|
155
155
|
# Bucket region, such as us-west-1, generally not needed to add
|
|
156
156
|
# but some service providers may require configuration
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 1.12.6](https://github.com/lobehub/lobe-chat/compare/v1.12.5...v1.12.6)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-08-22**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor s3 env and support path-style for minio.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Refactor s3 env and support path-style for minio, closes [#3559](https://github.com/lobehub/lobe-chat/issues/3559) ([1658403](https://github.com/lobehub/lobe-chat/commit/1658403))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 1.12.5](https://github.com/lobehub/lobe-chat/compare/v1.12.4...v1.12.5)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-08-22**</sup>
|
package/Dockerfile.database
CHANGED
|
@@ -48,7 +48,7 @@ S3_BUCKET=lobechat
|
|
|
48
48
|
# Request endpoint of the bucket (note that the path in this link includes the bucket name, which must be removed, or use the link provided on the page for applying S3 API token)
|
|
49
49
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
50
50
|
# Access domain of the bucket
|
|
51
|
-
|
|
51
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
<Callout type={'warning'}>`S3_ENDPOINT` must have its path removed, otherwise uploaded files cannot be accessed.</Callout>
|
|
@@ -138,7 +138,7 @@ S3_BUCKET=lobechat
|
|
|
138
138
|
# Bucket Request Endpoint
|
|
139
139
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
140
140
|
# Public Access Domain for the Bucket
|
|
141
|
-
|
|
141
|
+
S3_PUBLIC_DOMAIN=https://s3-dev.your-domain.com
|
|
142
142
|
|
|
143
143
|
# Bucket Region, such as us-west-1. Generally not required, but some service providers may need it.
|
|
144
144
|
# S3_REGION=us-west-1
|
|
@@ -49,7 +49,7 @@ S3_BUCKET=lobechat
|
|
|
49
49
|
# 存储桶的请求端点(注意此处链接的路径带存储桶名称,必须删除该路径,或使用申请 S3 API token 页面所提供的链接)
|
|
50
50
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
51
51
|
# 存储桶对外的访问域名
|
|
52
|
-
|
|
52
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
<Callout type={'warning'}>`S3_ENDPOINT`必须删除其路径,否则会无法访问所上传文件</Callout>
|
|
@@ -139,7 +139,7 @@ S3_BUCKET=lobechat
|
|
|
139
139
|
# 存储桶的请求端点
|
|
140
140
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
141
141
|
# 存储桶对外的访问域名
|
|
142
|
-
|
|
142
|
+
S3_PUBLIC_DOMAIN=https://s3-dev.your-domain.com
|
|
143
143
|
|
|
144
144
|
# 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
|
|
145
145
|
# S3_REGION=us-west-1
|
|
@@ -45,7 +45,7 @@ In this documentation, S3 refers to a compatible S3 storage solution, which supp
|
|
|
45
45
|
|
|
46
46
|
Whether to set the ACL to `public-read` when uploading files. This option is enabled by default. If the service provider does not support setting individual ACLs for files (i.e., all files inherit the ACL of the storage bucket), enabling this option may cause request errors. Set `S3_SET_ACL` to `0` to disable it.
|
|
47
47
|
|
|
48
|
-
### `
|
|
48
|
+
### `S3_PUBLIC_DOMAIN`
|
|
49
49
|
|
|
50
50
|
The public access domain of the storage bucket, used to access files in the storage bucket. This address needs to be **publicly readable**. The reason is that when OpenAI's gpt-4o and other vision models recognize images, OpenAI will try to download this image link on their servers. Therefore, this link must be publicly accessible. If it is a private link, OpenAI will not be able to access the image and thus will not be able to recognize the image content properly.
|
|
51
51
|
|
|
@@ -46,7 +46,7 @@ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
|
46
46
|
|
|
47
47
|
是否在上传文件时设置 ACL 为 `public-read`。该选项默认启用。如果服务商不支持为文件设置单独的 ACL(即所有文件继承存储桶的 ACL),启用此选项可能会导致请求错误,将 `S3_SET_ACL` 设置为 `0` 即可关闭。
|
|
48
48
|
|
|
49
|
-
### `
|
|
49
|
+
### `S3_PUBLIC_DOMAIN`
|
|
50
50
|
|
|
51
51
|
存储桶对外的访问域名,用于访问存储桶中的文件,这个地址需要**允许互联网可读**。 原因是 OpenAI 的 gpt-4o 等视觉模型识别图片时,OpenAI 会尝试在他们的服务器中下载这个图片链接,因此这个链接必须是公开可访问的,如果是私有的链接,OpenAI 将无法访问到这个图片,进而无法正常识别到图片内容。
|
|
52
52
|
|
|
@@ -73,7 +73,7 @@ S3_ACCESS_KEY_ID=xxxxxxxxxx
|
|
|
73
73
|
S3_SECRET_ACCESS_KEY=xxxxxxxxxx
|
|
74
74
|
S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com
|
|
75
75
|
S3_BUCKET=lobechat
|
|
76
|
-
|
|
76
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Start the lobe-chat-database Docker image
|
|
@@ -125,7 +125,7 @@ $ docker run -it -d --name lobe-chat-database -p 3210:3210 \
|
|
|
125
125
|
-e S3_SECRET_ACCESS_KEY=xxxxxxxxxx \
|
|
126
126
|
-e S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com \
|
|
127
127
|
-e S3_BUCKET=lobechat \
|
|
128
|
-
-e
|
|
128
|
+
-e S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com \
|
|
129
129
|
lobehub/lobe-chat-database
|
|
130
130
|
```
|
|
131
131
|
|
|
@@ -75,7 +75,7 @@ S3_ACCESS_KEY_ID=xxxxxxxxxx
|
|
|
75
75
|
S3_SECRET_ACCESS_KEY=xxxxxxxxxx
|
|
76
76
|
S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com
|
|
77
77
|
S3_BUCKET=lobechat
|
|
78
|
-
|
|
78
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
### 启动 lobe-chat-database docker 镜像
|
|
@@ -130,7 +130,7 @@ $ docker run -it -d --name lobe-chat-database -p 3210:3210 \
|
|
|
130
130
|
-e S3_SECRET_ACCESS_KEY=xxxxxxxxxx \
|
|
131
131
|
-e S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com \
|
|
132
132
|
-e S3_BUCKET=lobechat \
|
|
133
|
-
-e
|
|
133
|
+
-e S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com \
|
|
134
134
|
lobehub/lobe-chat-database
|
|
135
135
|
```
|
|
136
136
|
|
|
@@ -250,7 +250,7 @@ S3_BUCKET=lobechat
|
|
|
250
250
|
# Storage bucket request endpoint (note that the path in this link includes the bucket name, which must be removed, or use the link provided on the S3 API token application page)
|
|
251
251
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
252
252
|
# Public access domain for the storage bucket
|
|
253
|
-
|
|
253
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
254
254
|
```
|
|
255
255
|
|
|
256
256
|
<Callout type={'warning'}>
|
|
@@ -312,7 +312,7 @@ S3_BUCKET=lobechat
|
|
|
312
312
|
# Bucket request endpoint
|
|
313
313
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
314
314
|
# Public domain for bucket access
|
|
315
|
-
|
|
315
|
+
S3_PUBLIC_DOMAIN=https://s3-dev.your-domain.com
|
|
316
316
|
|
|
317
317
|
# Bucket region, such as us-west-1, generally not required, but some providers may need to configure
|
|
318
318
|
# S3_REGION=us-west-1
|
|
@@ -384,7 +384,7 @@ src={'https://github.com/lobehub/lobe-chat/assets/28616219/da84edc3-46f7-4e2b-a0
|
|
|
384
384
|
<Image
|
|
385
385
|
alt={'Login successful state'}
|
|
386
386
|
src={'https://github.com/lobehub/lobe-chat/assets/28616219/9cb5150d-6e1e-4c59-9a18-4e418dce1a5d'}/>
|
|
387
|
-
|
|
387
|
+
|
|
388
388
|
</Steps>
|
|
389
389
|
|
|
390
390
|
## Appendix
|
|
@@ -416,7 +416,7 @@ S3_BUCKET=lobechat
|
|
|
416
416
|
# Bucket request endpoint
|
|
417
417
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
418
418
|
# Public access domain for the bucket
|
|
419
|
-
|
|
419
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
420
420
|
# Bucket region, such as us-west-1, generally not needed to add, but some service providers may require configuration
|
|
421
421
|
# S3_REGION=us-west-1
|
|
422
422
|
```
|
|
@@ -18,8 +18,8 @@ tags:
|
|
|
18
18
|
|
|
19
19
|
<Callout type={'warning'}>
|
|
20
20
|
进行后续操作前,请务必确认以下事项:
|
|
21
|
-
- 导出所有数据,部署服务端数据库后,原有用户数据无法自动迁移,只能提前备份后进行手动导入!
|
|
22
|
-
- 环境变量中的`ACCESS_CODE`未设置或已清除!
|
|
21
|
+
- 导出所有数据,部署服务端数据库后,原有用户数据无法自动迁移,只能提前备份后进行手动导入!
|
|
22
|
+
- 环境变量中的`ACCESS_CODE`未设置或已清除!
|
|
23
23
|
- 配置服务端数据库所需要的环境变量时,需全部填入后再进行部署,否则可能遭遇数据库迁移问题!
|
|
24
24
|
</Callout>
|
|
25
25
|
|
|
@@ -46,7 +46,7 @@ tags:
|
|
|
46
46
|
|
|
47
47
|
<Callout type={'warning'}>
|
|
48
48
|
请确认您的供应商所提供的 `Postgres` 类型,若为 `Node Postgres`,请切换到 `Node Postgres` Tab 。
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
</Callout>
|
|
51
51
|
|
|
52
52
|
Serverless Postgres 需要填写的变量如下:
|
|
@@ -233,7 +233,7 @@ S3_BUCKET=lobechat
|
|
|
233
233
|
# 存储桶的请求端点(注意此处链接的路径带存储桶名称,必须删除该路径,或使用申请 S3 API token 页面所提供的链接)
|
|
234
234
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
235
235
|
# 存储桶对外的访问域名
|
|
236
|
-
|
|
236
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
237
237
|
```
|
|
238
238
|
|
|
239
239
|
<Callout type={'warning'}>`S3_ENDPOINT`必须删除其路径,否则会无法访问所上传文件</Callout>
|
|
@@ -291,7 +291,7 @@ S3_BUCKET=lobechat
|
|
|
291
291
|
# 存储桶的请求端点
|
|
292
292
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
293
293
|
# 存储桶对外的访问域名
|
|
294
|
-
|
|
294
|
+
S3_PUBLIC_DOMAIN=https://s3-dev.your-domain.com
|
|
295
295
|
|
|
296
296
|
# 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
|
|
297
297
|
# S3_REGION=us-west-1
|
|
@@ -397,7 +397,7 @@ S3_BUCKET=lobechat
|
|
|
397
397
|
# 存储桶的请求端点
|
|
398
398
|
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
|
|
399
399
|
# 存储桶对外的访问域名
|
|
400
|
-
|
|
400
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
401
401
|
# 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
|
|
402
402
|
# S3_REGION=us-west-1
|
|
403
403
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.6",
|
|
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",
|
package/src/config/file.ts
CHANGED
|
@@ -4,8 +4,19 @@ import { z } from 'zod';
|
|
|
4
4
|
const DEFAULT_S3_FILE_PATH = 'files';
|
|
5
5
|
|
|
6
6
|
export const getFileConfig = () => {
|
|
7
|
+
if (!!process.env.NEXT_PUBLIC_S3_DOMAIN) {
|
|
8
|
+
console.warn(
|
|
9
|
+
'⚠️ `NEXT_PUBLIC_S3_DOMAIN` will be de deprecated in the next major version, please replace it with `S3_PUBLIC_DOMAIN` in your env',
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const S3_PUBLIC_DOMAIN = process.env.S3_PUBLIC_DOMAIN || process.env.NEXT_PUBLIC_S3_DOMAIN;
|
|
14
|
+
|
|
7
15
|
return createEnv({
|
|
8
16
|
client: {
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
*/
|
|
9
20
|
NEXT_PUBLIC_S3_DOMAIN: z.string().url().optional(),
|
|
10
21
|
NEXT_PUBLIC_S3_FILE_PATH: z.string().optional(),
|
|
11
22
|
},
|
|
@@ -18,7 +29,9 @@ export const getFileConfig = () => {
|
|
|
18
29
|
|
|
19
30
|
S3_ACCESS_KEY_ID: process.env.S3_ACCESS_KEY_ID,
|
|
20
31
|
S3_BUCKET: process.env.S3_BUCKET,
|
|
32
|
+
S3_ENABLE_PATH_STYLE: process.env.S3_ENABLE_PATH_STYLE === '1',
|
|
21
33
|
S3_ENDPOINT: process.env.S3_ENDPOINT,
|
|
34
|
+
S3_PUBLIC_DOMAIN,
|
|
22
35
|
S3_REGION: process.env.S3_REGION,
|
|
23
36
|
S3_SECRET_ACCESS_KEY: process.env.S3_SECRET_ACCESS_KEY,
|
|
24
37
|
S3_SET_ACL: process.env.S3_SET_ACL !== '0',
|
|
@@ -30,8 +43,10 @@ export const getFileConfig = () => {
|
|
|
30
43
|
// S3
|
|
31
44
|
S3_ACCESS_KEY_ID: z.string().optional(),
|
|
32
45
|
S3_BUCKET: z.string().optional(),
|
|
33
|
-
|
|
46
|
+
S3_ENABLE_PATH_STYLE: z.boolean(),
|
|
34
47
|
|
|
48
|
+
S3_ENDPOINT: z.string().url().optional(),
|
|
49
|
+
S3_PUBLIC_DOMAIN: z.string().url().optional(),
|
|
35
50
|
S3_REGION: z.string().optional(),
|
|
36
51
|
S3_SECRET_ACCESS_KEY: z.string().optional(),
|
|
37
52
|
S3_SET_ACL: z.boolean(),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { TRPCError } from '@trpc/server';
|
|
2
|
-
import urlJoin from 'url-join';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
|
|
5
|
-
import { fileEnv } from '@/config/file';
|
|
6
4
|
import { AsyncTaskModel } from '@/database/server/models/asyncTask';
|
|
7
5
|
import { ChunkModel } from '@/database/server/models/chunk';
|
|
8
6
|
import { FileModel } from '@/database/server/models/file';
|
|
@@ -137,7 +135,7 @@ export const fileRouter = router({
|
|
|
137
135
|
embeddingError: embeddingTask?.error ?? null,
|
|
138
136
|
embeddingStatus: embeddingTask?.status as AsyncTaskStatus,
|
|
139
137
|
finishEmbedding: embeddingTask?.status === AsyncTaskStatus.Success,
|
|
140
|
-
url:
|
|
138
|
+
url: getFullFileUrl(item.url!),
|
|
141
139
|
};
|
|
142
140
|
});
|
|
143
141
|
}),
|
|
@@ -21,6 +21,10 @@ export class ServerService implements IFileService {
|
|
|
21
21
|
return lambdaClient.file.createFile.mutate({ ...params, knowledgeBaseId } as CreateFileParams);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated
|
|
26
|
+
* @param id
|
|
27
|
+
*/
|
|
24
28
|
async getFile(id: string): Promise<FilePreview> {
|
|
25
29
|
if (!fileEnv.NEXT_PUBLIC_S3_DOMAIN) {
|
|
26
30
|
throw new Error('fileEnv.NEXT_PUBLIC_S3_DOMAIN is not set while enable server upload');
|