@lobehub/chat 1.46.5 → 1.46.7
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 +51 -0
- package/changelog/v1.json +18 -0
- package/netlify.toml +1 -1
- package/package.json +1 -1
- package/src/const/settings/knowledge.ts +1 -1
- package/src/libs/agent-runtime/google/index.ts +12 -5
- package/src/server/globalConfig/parseFilesConfig.test.ts +122 -3
- package/src/server/globalConfig/parseFilesConfig.ts +19 -13
- package/src/server/modules/S3/index.ts +3 -0
- package/src/types/knowledgeBase/index.ts +1 -1
- package/src/types/user/settings/filesConfig.ts +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,57 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.46.7](https://github.com/lobehub/lobe-chat/compare/v1.46.6...v1.46.7)
|
6
|
+
|
7
|
+
<sup>Released on **2025-01-17**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Improve validation for provider and model in parseFilesConfig, temporarily disable S3 client integrity check for Cloudflare R2.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's fixed
|
19
|
+
|
20
|
+
- **misc**: Improve validation for provider and model in parseFilesConfig, closes [#5454](https://github.com/lobehub/lobe-chat/issues/5454) ([b4808f8](https://github.com/lobehub/lobe-chat/commit/b4808f8))
|
21
|
+
- **misc**: Temporarily disable S3 client integrity check for Cloudflare R2, closes [#5479](https://github.com/lobehub/lobe-chat/issues/5479) ([a638238](https://github.com/lobehub/lobe-chat/commit/a638238))
|
22
|
+
|
23
|
+
</details>
|
24
|
+
|
25
|
+
<div align="right">
|
26
|
+
|
27
|
+
[](#readme-top)
|
28
|
+
|
29
|
+
</div>
|
30
|
+
|
31
|
+
### [Version 1.46.6](https://github.com/lobehub/lobe-chat/compare/v1.46.5...v1.46.6)
|
32
|
+
|
33
|
+
<sup>Released on **2025-01-16**</sup>
|
34
|
+
|
35
|
+
#### 🐛 Bug Fixes
|
36
|
+
|
37
|
+
- **misc**: Gemini models HarmBlockThreshold.
|
38
|
+
|
39
|
+
<br/>
|
40
|
+
|
41
|
+
<details>
|
42
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
43
|
+
|
44
|
+
#### What's fixed
|
45
|
+
|
46
|
+
- **misc**: Gemini models HarmBlockThreshold, closes [#5477](https://github.com/lobehub/lobe-chat/issues/5477) ([f98375c](https://github.com/lobehub/lobe-chat/commit/f98375c))
|
47
|
+
|
48
|
+
</details>
|
49
|
+
|
50
|
+
<div align="right">
|
51
|
+
|
52
|
+
[](#readme-top)
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
5
56
|
### [Version 1.46.5](https://github.com/lobehub/lobe-chat/compare/v1.46.4...v1.46.5)
|
6
57
|
|
7
58
|
<sup>Released on **2025-01-16**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"fixes": [
|
5
|
+
"Improve validation for provider and model in parseFilesConfig, temporarily disable S3 client integrity check for Cloudflare R2."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-01-17",
|
9
|
+
"version": "1.46.7"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"fixes": [
|
14
|
+
"Gemini models HarmBlockThreshold."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2025-01-16",
|
18
|
+
"version": "1.46.6"
|
19
|
+
},
|
2
20
|
{
|
3
21
|
"children": {},
|
4
22
|
"date": "2025-01-16",
|
package/netlify.toml
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.46.
|
3
|
+
"version": "1.46.7",
|
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",
|
@@ -20,6 +20,6 @@ export const DEFAULT_FILE_RERANK_MODEL_ITEM: FilesConfigItem = {
|
|
20
20
|
|
21
21
|
export const DEFAULT_FILES_CONFIG: FilesConfig = {
|
22
22
|
embeddingModel: DEFAULT_FILE_EMBEDDING_MODEL_ITEM,
|
23
|
-
|
23
|
+
queryMode: DEFAULT_RERANK_QUERY_MODE,
|
24
24
|
rerankerModel: DEFAULT_FILE_RERANK_MODEL_ITEM,
|
25
25
|
};
|
@@ -36,7 +36,14 @@ enum HarmCategory {
|
|
36
36
|
|
37
37
|
enum HarmBlockThreshold {
|
38
38
|
BLOCK_NONE = 'BLOCK_NONE',
|
39
|
-
|
39
|
+
}
|
40
|
+
|
41
|
+
function getThreshold(model: string): HarmBlockThreshold {
|
42
|
+
const useOFF = ['gemini-2.0-flash-exp'];
|
43
|
+
if (useOFF.includes(model)) {
|
44
|
+
return 'OFF' as HarmBlockThreshold; // https://discuss.ai.google.dev/t/59352
|
45
|
+
}
|
46
|
+
return HarmBlockThreshold.BLOCK_NONE;
|
40
47
|
}
|
41
48
|
|
42
49
|
export class LobeGoogleAI implements LobeRuntimeAI {
|
@@ -71,19 +78,19 @@ export class LobeGoogleAI implements LobeRuntimeAI {
|
|
71
78
|
safetySettings: [
|
72
79
|
{
|
73
80
|
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
|
74
|
-
threshold: model
|
81
|
+
threshold: getThreshold(model),
|
75
82
|
},
|
76
83
|
{
|
77
84
|
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
78
|
-
threshold: model
|
85
|
+
threshold: getThreshold(model),
|
79
86
|
},
|
80
87
|
{
|
81
88
|
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
|
82
|
-
threshold: model
|
89
|
+
threshold: getThreshold(model),
|
83
90
|
},
|
84
91
|
{
|
85
92
|
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
86
|
-
threshold: model
|
93
|
+
threshold: getThreshold(model),
|
87
94
|
},
|
88
95
|
],
|
89
96
|
},
|
@@ -3,15 +3,134 @@ import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { parseFilesConfig } from './parseFilesConfig';
|
4
4
|
|
5
5
|
describe('parseFilesConfig', () => {
|
6
|
+
it('parses full configuration correctly', () => {
|
7
|
+
const envStr =
|
8
|
+
'embedding_model=openai/embedding-text-3-small,reranker_model=cohere/rerank-english-v3.0,query_mode=full_text';
|
9
|
+
const expected = {
|
10
|
+
embeddingModel: { provider: 'openai', model: 'embedding-text-3-small' },
|
11
|
+
rerankerModel: { provider: 'cohere', model: 'rerank-english-v3.0' },
|
12
|
+
queryMode: 'full_text',
|
13
|
+
};
|
14
|
+
expect(parseFilesConfig(envStr)).toEqual(expected);
|
15
|
+
});
|
16
|
+
|
6
17
|
// 测试embeddings配置是否被正确解析
|
7
18
|
it('parses embeddings configuration correctly', () => {
|
8
|
-
const envStr =
|
9
|
-
'embedding_model=openai/embedding-text-3-large,reranker_model=cohere/rerank-english-v3.0,query_model=full_text';
|
19
|
+
const envStr = 'embedding_model=openai/embedding-text-3-large';
|
10
20
|
const expected = {
|
11
21
|
embeddingModel: { provider: 'openai', model: 'embedding-text-3-large' },
|
22
|
+
};
|
23
|
+
expect(parseFilesConfig(envStr)).toEqual(expected);
|
24
|
+
});
|
25
|
+
|
26
|
+
it('parses rerank configuration correctly', () => {
|
27
|
+
const envStr = 'reranker_model=cohere/rerank-english-v3.0';
|
28
|
+
const expected = {
|
29
|
+
rerankerModel: { provider: 'cohere', model: 'rerank-english-v3.0' },
|
30
|
+
};
|
31
|
+
expect(parseFilesConfig(envStr)).toEqual(expected);
|
32
|
+
});
|
33
|
+
|
34
|
+
it('parses queryMode configuration correctly', () => {
|
35
|
+
const envStr = 'query_mode=full_text';
|
36
|
+
const expected = {
|
37
|
+
queryMode: 'full_text',
|
38
|
+
};
|
39
|
+
expect(parseFilesConfig(envStr)).toEqual(expected);
|
40
|
+
});
|
41
|
+
|
42
|
+
it('parses queryMode rerank configuration correctly', () => {
|
43
|
+
const envStr = 'reranker_model=cohere/rerank-english-v3.0,query_mode=full_text';
|
44
|
+
const expected = {
|
45
|
+
queryMode: 'full_text',
|
46
|
+
rerankerModel: { provider: 'cohere', model: 'rerank-english-v3.0' },
|
47
|
+
};
|
48
|
+
expect(parseFilesConfig(envStr)).toEqual(expected);
|
49
|
+
});
|
50
|
+
|
51
|
+
it('parses queryMode embeddings configuration correctly', () => {
|
52
|
+
const envStr = 'embedding_model=openai/embedding-text-3-small,query_mode=full_text';
|
53
|
+
const expected = {
|
54
|
+
queryMode: 'full_text',
|
55
|
+
embeddingModel: { provider: 'openai', model: 'embedding-text-3-small' },
|
56
|
+
};
|
57
|
+
expect(parseFilesConfig(envStr)).toEqual(expected);
|
58
|
+
});
|
59
|
+
|
60
|
+
it('parses rerank embeddings configuration correctly', () => {
|
61
|
+
const envStr =
|
62
|
+
'reranker_model=cohere/rerank-english-v3.0,embedding_model=openai/embedding-text-3-small';
|
63
|
+
const expected = {
|
64
|
+
embeddingModel: { provider: 'openai', model: 'embedding-text-3-small' },
|
12
65
|
rerankerModel: { provider: 'cohere', model: 'rerank-english-v3.0' },
|
13
|
-
queryModel: 'full_text',
|
14
66
|
};
|
15
67
|
expect(parseFilesConfig(envStr)).toEqual(expected);
|
16
68
|
});
|
69
|
+
|
70
|
+
it('should throw an error for invalid embedding_model format', () => {
|
71
|
+
const envStr =
|
72
|
+
'reranker_model=cohere/rerank-english-v3.0,embedding_model=/embedding-text-3-small';
|
73
|
+
expect(() => {
|
74
|
+
parseFilesConfig(envStr);
|
75
|
+
}).toThrow(
|
76
|
+
new Error(
|
77
|
+
'Invalid environment variable format. expected of the form embedding_model=provider/model',
|
78
|
+
),
|
79
|
+
);
|
80
|
+
});
|
81
|
+
|
82
|
+
it('should throw an error for invalid embedding_model format', () => {
|
83
|
+
const envStr = 'reranker_model=cohere/rerank-english-v3.0,embedding_model=openai';
|
84
|
+
expect(() => {
|
85
|
+
parseFilesConfig(envStr);
|
86
|
+
}).toThrow(
|
87
|
+
new Error(
|
88
|
+
'Invalid environment variable format. expected of the form embedding_model=provider/model',
|
89
|
+
),
|
90
|
+
);
|
91
|
+
});
|
92
|
+
|
93
|
+
it('should throw an error for invalid embedding_model format', () => {
|
94
|
+
const envStr = 'reranker_model=cohere/rerank-english-v3.0,embedding_model=';
|
95
|
+
expect(() => {
|
96
|
+
parseFilesConfig(envStr);
|
97
|
+
}).toThrowError(new Error('Invalid environment variable format.'));
|
98
|
+
});
|
99
|
+
|
100
|
+
it('should throw an error for invalid reranker_model format', () => {
|
101
|
+
const envStr =
|
102
|
+
'reranker_model=/rerank-english-v3.0,embedding_model=openai/embedding-text-3-small';
|
103
|
+
expect(() => {
|
104
|
+
parseFilesConfig(envStr);
|
105
|
+
}).toThrow(
|
106
|
+
new Error(
|
107
|
+
'Invalid environment variable format. expected of the form reranker_model=provider/model',
|
108
|
+
),
|
109
|
+
);
|
110
|
+
});
|
111
|
+
|
112
|
+
it('should throw an error for invalid reranker_model format', () => {
|
113
|
+
const envStr = 'reranker_model=cohere/,embedding_model=openai/embedding-text-3-small';
|
114
|
+
expect(() => {
|
115
|
+
parseFilesConfig(envStr);
|
116
|
+
}).toThrow(
|
117
|
+
new Error(
|
118
|
+
'Invalid environment variable format. expected of the form reranker_model=provider/model',
|
119
|
+
),
|
120
|
+
);
|
121
|
+
});
|
122
|
+
|
123
|
+
it('should throw an error for invalid reranker_model format', () => {
|
124
|
+
const envStr = 'reranker_model=,embedding_model=openai/embedding-text-3-small';
|
125
|
+
expect(() => {
|
126
|
+
parseFilesConfig(envStr);
|
127
|
+
}).toThrow(new Error('Invalid environment variable format.'));
|
128
|
+
});
|
129
|
+
|
130
|
+
it('should throw an error for invalid query_mode format', () => {
|
131
|
+
const envStr = 'query_mode=';
|
132
|
+
expect(() => {
|
133
|
+
parseFilesConfig(envStr);
|
134
|
+
}).toThrow(new Error('Invalid environment variable format.'));
|
135
|
+
});
|
17
136
|
});
|
@@ -4,7 +4,7 @@ import { FilesConfig } from '@/types/user/settings/filesConfig';
|
|
4
4
|
|
5
5
|
const protectedKeys = Object.keys({
|
6
6
|
embedding_model: null,
|
7
|
-
|
7
|
+
query_mode: null,
|
8
8
|
reranker_model: null,
|
9
9
|
});
|
10
10
|
|
@@ -24,34 +24,40 @@ export const parseFilesConfig = (envString: string = ''): SystemEmbeddingConfig
|
|
24
24
|
const [provider, ...modelParts] = value.split('/');
|
25
25
|
const model = modelParts.join('/');
|
26
26
|
|
27
|
-
if ((!provider || !model) && key !== 'query_model') {
|
28
|
-
throw new Error('Missing model or provider value');
|
29
|
-
}
|
30
|
-
|
31
|
-
if (key === 'query_model' && value === '') {
|
32
|
-
throw new Error('Missing query mode value');
|
33
|
-
}
|
34
|
-
|
35
27
|
if (protectedKeys.includes(key)) {
|
36
28
|
switch (key) {
|
37
29
|
case 'embedding_model': {
|
30
|
+
if (!provider || !model) {
|
31
|
+
throw new Error(
|
32
|
+
'Invalid environment variable format. expected of the form embedding_model=provider/model',
|
33
|
+
);
|
34
|
+
}
|
38
35
|
config.embeddingModel = { model: model.trim(), provider: provider.trim() };
|
39
36
|
break;
|
40
37
|
}
|
41
38
|
case 'reranker_model': {
|
39
|
+
if (!provider || !model) {
|
40
|
+
throw new Error(
|
41
|
+
'Invalid environment variable format. expected of the form reranker_model=provider/model',
|
42
|
+
);
|
43
|
+
}
|
42
44
|
config.rerankerModel = { model: model.trim(), provider: provider.trim() };
|
43
45
|
break;
|
44
46
|
}
|
45
|
-
case '
|
46
|
-
config.
|
47
|
+
case 'query_mode': {
|
48
|
+
config.queryMode = value;
|
47
49
|
break;
|
48
50
|
}
|
51
|
+
default: {
|
52
|
+
throw new Error(
|
53
|
+
'Invalid environment variable format. expected one of embedding_model, reranker_model, query_mode',
|
54
|
+
);
|
55
|
+
}
|
49
56
|
}
|
50
57
|
}
|
51
58
|
} else {
|
52
|
-
throw new Error('Invalid environment variable format');
|
59
|
+
throw new Error('Invalid environment variable format.');
|
53
60
|
}
|
54
61
|
}
|
55
|
-
|
56
62
|
return config;
|
57
63
|
};
|
@@ -44,6 +44,9 @@ export class S3 {
|
|
44
44
|
endpoint: fileEnv.S3_ENDPOINT,
|
45
45
|
forcePathStyle: fileEnv.S3_ENABLE_PATH_STYLE,
|
46
46
|
region: fileEnv.S3_REGION || DEFAULT_S3_REGION,
|
47
|
+
// refs: https://github.com/lobehub/lobe-chat/pull/5479
|
48
|
+
requestChecksumCalculation: 'WHEN_REQUIRED',
|
49
|
+
responseChecksumValidation: 'WHEN_REQUIRED',
|
47
50
|
});
|
48
51
|
}
|
49
52
|
|