@lobehub/lobehub 2.0.0-next.114 → 2.0.0-next.116
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 +50 -0
- package/changelog/v1.json +18 -0
- package/package.json +1 -1
- package/packages/const/src/models.ts +6 -0
- package/packages/context-engine/src/processors/MessageContent.ts +100 -6
- package/packages/context-engine/src/processors/__tests__/MessageContent.test.ts +239 -0
- package/packages/fetch-sse/src/fetchSSE.ts +30 -0
- package/packages/model-bank/src/aiModels/aihubmix.ts +35 -1
- package/packages/model-bank/src/aiModels/anthropic.ts +37 -2
- package/packages/model-bank/src/aiModels/bedrock.ts +26 -11
- package/packages/model-bank/src/aiModels/openrouter.ts +28 -1
- package/packages/model-bank/src/aiModels/zenmux.ts +30 -1
- package/packages/model-runtime/src/core/contextBuilders/google.test.ts +78 -24
- package/packages/model-runtime/src/core/contextBuilders/google.ts +10 -2
- package/packages/model-runtime/src/core/parameterResolver.ts +3 -0
- package/packages/model-runtime/src/core/streams/google/google-ai.test.ts +451 -20
- package/packages/model-runtime/src/core/streams/google/index.ts +113 -3
- package/packages/model-runtime/src/core/streams/protocol.ts +19 -0
- package/packages/types/src/message/common/base.ts +26 -0
- package/packages/types/src/message/common/metadata.ts +7 -0
- package/packages/utils/src/index.ts +1 -0
- package/packages/utils/src/multimodalContent.ts +25 -0
- package/src/components/Thinking/index.tsx +3 -3
- package/src/features/ChatList/Messages/Assistant/DisplayContent.tsx +44 -0
- package/src/features/ChatList/Messages/Assistant/MessageBody.tsx +96 -0
- package/src/features/ChatList/Messages/Assistant/Reasoning/index.tsx +26 -13
- package/src/features/ChatList/Messages/Assistant/index.tsx +8 -6
- package/src/features/ChatList/Messages/Default.tsx +4 -7
- package/src/features/ChatList/components/RichContentRenderer.tsx +35 -0
- package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +244 -17
- package/src/features/ChatList/Messages/Assistant/MessageContent.tsx +0 -78
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { AIChatModelCard } from '../types/aiModel';
|
|
2
2
|
|
|
3
3
|
const bedrockChatModels: AIChatModelCard[] = [
|
|
4
|
+
{
|
|
5
|
+
abilities: {
|
|
6
|
+
functionCall: true,
|
|
7
|
+
reasoning: true,
|
|
8
|
+
structuredOutput: true,
|
|
9
|
+
vision: true,
|
|
10
|
+
},
|
|
11
|
+
contextWindowTokens: 200_000,
|
|
12
|
+
description:
|
|
13
|
+
'Claude Opus 4.5 是 Anthropic 的旗舰模型,结合了卓越的智能与可扩展性能,适合需要最高质量回应和推理能力的复杂任务。',
|
|
14
|
+
displayName: 'Claude Opus 4.5',
|
|
15
|
+
enabled: true,
|
|
16
|
+
id: 'us.anthropic.claude-opus-4-5-20251101-v1:0',
|
|
17
|
+
maxOutput: 64_000,
|
|
18
|
+
pricing: {
|
|
19
|
+
units: [
|
|
20
|
+
{ name: 'textInput_cacheRead', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },
|
|
21
|
+
{ name: 'textInput', rate: 5, strategy: 'fixed', unit: 'millionTokens' },
|
|
22
|
+
{ name: 'textOutput', rate: 25, strategy: 'fixed', unit: 'millionTokens' },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
releasedAt: '2025-11-24',
|
|
26
|
+
type: 'chat',
|
|
27
|
+
},
|
|
4
28
|
{
|
|
5
29
|
abilities: {
|
|
6
30
|
functionCall: true,
|
|
@@ -31,7 +55,8 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
31
55
|
vision: true,
|
|
32
56
|
},
|
|
33
57
|
contextWindowTokens: 200_000,
|
|
34
|
-
description:
|
|
58
|
+
description:
|
|
59
|
+
'Claude Haiku 4.5 是 Anthropic 最快且最智能的 Haiku 模型,具有闪电般的速度和扩展思考能力。',
|
|
35
60
|
displayName: 'Claude Haiku 4.5',
|
|
36
61
|
enabled: true,
|
|
37
62
|
id: 'us.anthropic.claude-haiku-4-5-20251001-v1:0',
|
|
@@ -77,7 +102,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
77
102
|
description:
|
|
78
103
|
'Claude 3.7 sonnet 是 Anthropic 最快的下一代模型。与 Claude 3 Haiku 相比,Claude 3.7 Sonnet 在各项技能上都有所提升,并在许多智力基准测试中超越了上一代最大的模型 Claude 3 Opus。',
|
|
79
104
|
displayName: 'Claude 3.7 Sonnet',
|
|
80
|
-
enabled: true,
|
|
81
105
|
id: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
|
|
82
106
|
maxOutput: 8192,
|
|
83
107
|
pricing: {
|
|
@@ -98,7 +122,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
98
122
|
description:
|
|
99
123
|
'Claude 3.5 Sonnet 提升了行业标准,性能超过竞争对手模型和 Claude 3 Opus,在广泛的评估中表现出色,同时具有我们中等层级模型的速度和成本。',
|
|
100
124
|
displayName: 'Claude 3.5 Sonnet',
|
|
101
|
-
enabled: true,
|
|
102
125
|
id: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
|
|
103
126
|
maxOutput: 8192,
|
|
104
127
|
pricing: {
|
|
@@ -119,7 +142,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
119
142
|
description:
|
|
120
143
|
'Claude 3.5 Sonnet 提升了行业标准,性能超过竞争对手模型和 Claude 3 Opus,在广泛的评估中表现出色,同时具有我们中等层级模型的速度和成本。',
|
|
121
144
|
displayName: 'Claude 3.5 Sonnet v2 (Inference profile)',
|
|
122
|
-
enabled: true,
|
|
123
145
|
id: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
|
|
124
146
|
maxOutput: 8192,
|
|
125
147
|
pricing: {
|
|
@@ -140,7 +162,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
140
162
|
description:
|
|
141
163
|
'Claude 3.5 Sonnet 提升了行业标准,性能超过竞争对手模型和 Claude 3 Opus,在广泛的评估中表现出色,同时具有我们中等层级模型的速度和成本。',
|
|
142
164
|
displayName: 'Claude 3.5 Sonnet 0620',
|
|
143
|
-
enabled: true,
|
|
144
165
|
id: 'anthropic.claude-3-5-sonnet-20240620-v1:0',
|
|
145
166
|
maxOutput: 8192,
|
|
146
167
|
pricing: {
|
|
@@ -161,7 +182,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
161
182
|
description:
|
|
162
183
|
'Claude 3 Haiku 是 Anthropic 最快、最紧凑的模型,提供近乎即时的响应速度。它可以快速回答简单的查询和请求。客户将能够构建模仿人类互动的无缝 AI 体验。Claude 3 Haiku 可以处理图像并返回文本输出,具有 200K 的上下文窗口。',
|
|
163
184
|
displayName: 'Claude 3 Haiku',
|
|
164
|
-
enabled: true,
|
|
165
185
|
id: 'anthropic.claude-3-haiku-20240307-v1:0',
|
|
166
186
|
maxOutput: 4096,
|
|
167
187
|
pricing: {
|
|
@@ -182,7 +202,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
182
202
|
description:
|
|
183
203
|
'Anthropic 的 Claude 3 Sonnet 在智能和速度之间达到了理想的平衡——特别适合企业工作负载。它以低于竞争对手的价格提供最大的效用,并被设计成为可靠的、高耐用的主力机,适用于规模化的 AI 部署。Claude 3 Sonnet 可以处理图像并返回文本输出,具有 200K 的上下文窗口。',
|
|
184
204
|
displayName: 'Claude 3 Sonnet',
|
|
185
|
-
enabled: true,
|
|
186
205
|
id: 'anthropic.claude-3-sonnet-20240229-v1:0',
|
|
187
206
|
pricing: {
|
|
188
207
|
units: [
|
|
@@ -200,7 +219,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
200
219
|
description:
|
|
201
220
|
'Claude 3 Opus 是 Anthropic 最强大的 AI 模型,具有在高度复杂任务上的最先进性能。它可以处理开放式提示和未见过的场景,具有出色的流畅性和类人的理解能力。Claude 3 Opus 展示了生成 AI 可能性的前沿。Claude 3 Opus 可以处理图像并返回文本输出,具有 200K 的上下文窗口。',
|
|
202
221
|
displayName: 'Claude 3 Opus',
|
|
203
|
-
enabled: true,
|
|
204
222
|
id: 'anthropic.claude-3-opus-20240229-v1:0',
|
|
205
223
|
maxOutput: 4096,
|
|
206
224
|
pricing: {
|
|
@@ -262,7 +280,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
262
280
|
description:
|
|
263
281
|
'Meta Llama 3.1 8B Instruct 的更新版,包括扩展的 128K 上下文长度、多语言性和改进的推理能力。Llama 3.1 提供的多语言大型语言模型 (LLMs) 是一组预训练的、指令调整的生成模型,包括 8B、70B 和 405B 大小 (文本输入/输出)。Llama 3.1 指令调整的文本模型 (8B、70B、405B) 专为多语言对话用例进行了优化,并在常见的行业基准测试中超过了许多可用的开源聊天模型。Llama 3.1 旨在用于多种语言的商业和研究用途。指令调整的文本模型适用于类似助手的聊天,而预训练模型可以适应各种自然语言生成任务。Llama 3.1 模型还支持利用其模型的输出来改进其他模型,包括合成数据生成和精炼。Llama 3.1 是使用优化的变压器架构的自回归语言模型。调整版本使用监督微调 (SFT) 和带有人类反馈的强化学习 (RLHF) 来符合人类对帮助性和安全性的偏好。',
|
|
264
282
|
displayName: 'Llama 3.1 8B Instruct',
|
|
265
|
-
enabled: true,
|
|
266
283
|
id: 'meta.llama3-1-8b-instruct-v1:0',
|
|
267
284
|
pricing: {
|
|
268
285
|
units: [
|
|
@@ -280,7 +297,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
280
297
|
description:
|
|
281
298
|
'Meta Llama 3.1 70B Instruct 的更新版,包括扩展的 128K 上下文长度、多语言性和改进的推理能力。Llama 3.1 提供的多语言大型语言模型 (LLMs) 是一组预训练的、指令调整的生成模型,包括 8B、70B 和 405B 大小 (文本输入/输出)。Llama 3.1 指令调整的文本模型 (8B、70B、405B) 专为多语言对话用例进行了优化,并在常见的行业基准测试中超过了许多可用的开源聊天模型。Llama 3.1 旨在用于多种语言的商业和研究用途。指令调整的文本模型适用于类似助手的聊天,而预训练模型可以适应各种自然语言生成任务。Llama 3.1 模型还支持利用其模型的输出来改进其他模型,包括合成数据生成和精炼。Llama 3.1 是使用优化的变压器架构的自回归语言模型。调整版本使用监督微调 (SFT) 和带有人类反馈的强化学习 (RLHF) 来符合人类对帮助性和安全性的偏好。',
|
|
282
299
|
displayName: 'Llama 3.1 70B Instruct',
|
|
283
|
-
enabled: true,
|
|
284
300
|
id: 'meta.llama3-1-70b-instruct-v1:0',
|
|
285
301
|
pricing: {
|
|
286
302
|
units: [
|
|
@@ -298,7 +314,6 @@ const bedrockChatModels: AIChatModelCard[] = [
|
|
|
298
314
|
description:
|
|
299
315
|
'Meta Llama 3.1 405B Instruct 是 Llama 3.1 Instruct 模型中最大、最强大的模型,是一款高度先进的对话推理和合成数据生成模型,也可以用作在特定领域进行专业持续预训练或微调的基础。Llama 3.1 提供的多语言大型语言模型 (LLMs) 是一组预训练的、指令调整的生成模型,包括 8B、70B 和 405B 大小 (文本输入/输出)。Llama 3.1 指令调整的文本模型 (8B、70B、405B) 专为多语言对话用例进行了优化,并在常见的行业基准测试中超过了许多可用的开源聊天模型。Llama 3.1 旨在用于多种语言的商业和研究用途。指令调整的文本模型适用于类似助手的聊天,而预训练模型可以适应各种自然语言生成任务。Llama 3.1 模型还支持利用其模型的输出来改进其他模型,包括合成数据生成和精炼。Llama 3.1 是使用优化的变压器架构的自回归语言模型。调整版本使用监督微调 (SFT) 和带有人类反馈的强化学习 (RLHF) 来符合人类对帮助性和安全性的偏好。',
|
|
300
316
|
displayName: 'Llama 3.1 405B Instruct',
|
|
301
|
-
enabled: true,
|
|
302
317
|
id: 'meta.llama3-1-405b-instruct-v1:0',
|
|
303
318
|
pricing: {
|
|
304
319
|
units: [
|
|
@@ -695,6 +695,34 @@ const openrouterChatModels: AIChatModelCard[] = [
|
|
|
695
695
|
id: 'deepseek/deepseek-chat-v3-0324:free',
|
|
696
696
|
type: 'chat',
|
|
697
697
|
},
|
|
698
|
+
{
|
|
699
|
+
abilities: {
|
|
700
|
+
functionCall: true,
|
|
701
|
+
reasoning: true,
|
|
702
|
+
search: true,
|
|
703
|
+
vision: true,
|
|
704
|
+
},
|
|
705
|
+
contextWindowTokens: 200_000,
|
|
706
|
+
description:
|
|
707
|
+
'Claude Opus 4.5 是 Anthropic 的旗舰模型,结合了卓越的智能与可扩展性能,适合需要最高质量回应和推理能力的复杂任务。',
|
|
708
|
+
displayName: 'Claude Opus 4.5',
|
|
709
|
+
id: 'anthropic/claude-opus-4.5',
|
|
710
|
+
maxOutput: 64_000,
|
|
711
|
+
pricing: {
|
|
712
|
+
units: [
|
|
713
|
+
{ name: 'textInput_cacheRead', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },
|
|
714
|
+
{ name: 'textInput', rate: 5, strategy: 'fixed', unit: 'millionTokens' },
|
|
715
|
+
{ name: 'textOutput', rate: 25, strategy: 'fixed', unit: 'millionTokens' },
|
|
716
|
+
{ name: 'textInput_cacheWrite', rate: 6.25, strategy: 'fixed', unit: 'millionTokens' },
|
|
717
|
+
],
|
|
718
|
+
},
|
|
719
|
+
releasedAt: '2025-11-24',
|
|
720
|
+
settings: {
|
|
721
|
+
extendParams: ['disableContextCaching', 'enableReasoning', 'reasoningBudgetToken'],
|
|
722
|
+
searchImpl: 'params',
|
|
723
|
+
},
|
|
724
|
+
type: 'chat',
|
|
725
|
+
},
|
|
698
726
|
{
|
|
699
727
|
abilities: {
|
|
700
728
|
functionCall: true,
|
|
@@ -705,7 +733,6 @@ const openrouterChatModels: AIChatModelCard[] = [
|
|
|
705
733
|
contextWindowTokens: 200_000,
|
|
706
734
|
description: 'Claude Sonnet 4.5 是 Anthropic 迄今为止最智能的模型。',
|
|
707
735
|
displayName: 'Claude Sonnet 4.5',
|
|
708
|
-
enabled: true,
|
|
709
736
|
id: 'anthropic/claude-sonnet-4.5',
|
|
710
737
|
maxOutput: 64_000,
|
|
711
738
|
pricing: {
|
|
@@ -19,7 +19,6 @@ const zenmuxChatModels: AIChatModelCard[] = [
|
|
|
19
19
|
description:
|
|
20
20
|
'Gemini 3 Pro Image(Nano Banana Pro)是 Google 的图像生成模型,同时支持多模态对话。',
|
|
21
21
|
displayName: 'Gemini 3 Pro Image (Nano Banana Pro)',
|
|
22
|
-
enabled: true,
|
|
23
22
|
id: 'google/gemini-3-pro-image-preview',
|
|
24
23
|
maxOutput: 32_768,
|
|
25
24
|
pricing: {
|
|
@@ -42,6 +41,7 @@ const zenmuxChatModels: AIChatModelCard[] = [
|
|
|
42
41
|
contextWindowTokens: 65_536,
|
|
43
42
|
description: 'Gemini 3 Pro Image 免费版,支持受限额度的多模态生成。',
|
|
44
43
|
displayName: 'Gemini 3 Pro Image (Nano Banana) Free',
|
|
44
|
+
enabled: true,
|
|
45
45
|
id: 'google/gemini-3-pro-image-preview-free',
|
|
46
46
|
maxOutput: 32_768,
|
|
47
47
|
pricing: {
|
|
@@ -84,6 +84,7 @@ const zenmuxChatModels: AIChatModelCard[] = [
|
|
|
84
84
|
description:
|
|
85
85
|
'Gemini 3 Pro 免费预览版,具备与标准版相同的多模态理解与推理能力,但受免费额度与速率限制影响,更适合作为体验与低频使用。',
|
|
86
86
|
displayName: 'Gemini 3 Pro Preview Free',
|
|
87
|
+
enabled: true,
|
|
87
88
|
id: 'google/gemini-3-pro-preview-free',
|
|
88
89
|
maxOutput: 65_530,
|
|
89
90
|
pricing: {
|
|
@@ -991,6 +992,34 @@ const zenmuxChatModels: AIChatModelCard[] = [
|
|
|
991
992
|
},
|
|
992
993
|
type: 'chat',
|
|
993
994
|
},
|
|
995
|
+
{
|
|
996
|
+
abilities: {
|
|
997
|
+
functionCall: true,
|
|
998
|
+
reasoning: true,
|
|
999
|
+
search: true,
|
|
1000
|
+
structuredOutput: true,
|
|
1001
|
+
vision: true,
|
|
1002
|
+
},
|
|
1003
|
+
contextWindowTokens: 200_000,
|
|
1004
|
+
description:
|
|
1005
|
+
'Claude Opus 4.5 是 Anthropic 的旗舰模型,结合了卓越的智能与可扩展性能,适合需要最高质量回应和推理能力的复杂任务。',
|
|
1006
|
+
displayName: 'Claude Opus 4.5',
|
|
1007
|
+
id: 'claude-opus-4-5-20251101',
|
|
1008
|
+
maxOutput: 64_000,
|
|
1009
|
+
pricing: {
|
|
1010
|
+
units: [
|
|
1011
|
+
{ name: 'textInput_cacheRead', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },
|
|
1012
|
+
{ name: 'textInput', rate: 5, strategy: 'fixed', unit: 'millionTokens' },
|
|
1013
|
+
{ name: 'textOutput', rate: 25, strategy: 'fixed', unit: 'millionTokens' },
|
|
1014
|
+
],
|
|
1015
|
+
},
|
|
1016
|
+
releasedAt: '2025-11-24',
|
|
1017
|
+
settings: {
|
|
1018
|
+
extendParams: ['enableReasoning', 'reasoningBudgetToken'],
|
|
1019
|
+
searchImpl: 'params',
|
|
1020
|
+
},
|
|
1021
|
+
type: 'chat',
|
|
1022
|
+
},
|
|
994
1023
|
{
|
|
995
1024
|
abilities: {
|
|
996
1025
|
functionCall: true,
|
|
@@ -33,7 +33,7 @@ describe('google contextBuilders', () => {
|
|
|
33
33
|
|
|
34
34
|
const result = await buildGooglePart(content);
|
|
35
35
|
|
|
36
|
-
expect(result).toEqual({ text: 'Hello' });
|
|
36
|
+
expect(result).toEqual({ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE });
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it('should handle thinking type messages', async () => {
|
|
@@ -71,6 +71,7 @@ describe('google contextBuilders', () => {
|
|
|
71
71
|
data: 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
|
|
72
72
|
mimeType: 'image/png',
|
|
73
73
|
},
|
|
74
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
74
75
|
});
|
|
75
76
|
});
|
|
76
77
|
|
|
@@ -101,6 +102,7 @@ describe('google contextBuilders', () => {
|
|
|
101
102
|
data: mockBase64,
|
|
102
103
|
mimeType: 'image/png',
|
|
103
104
|
},
|
|
105
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
104
106
|
});
|
|
105
107
|
|
|
106
108
|
expect(imageToBase64Module.imageUrlToBase64).toHaveBeenCalledWith(imageUrl);
|
|
@@ -144,6 +146,7 @@ describe('google contextBuilders', () => {
|
|
|
144
146
|
data: 'mockVideoBase64Data',
|
|
145
147
|
mimeType: 'video/mp4',
|
|
146
148
|
},
|
|
149
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
147
150
|
});
|
|
148
151
|
});
|
|
149
152
|
});
|
|
@@ -158,7 +161,7 @@ describe('google contextBuilders', () => {
|
|
|
158
161
|
const converted = await buildGoogleMessage(message);
|
|
159
162
|
|
|
160
163
|
expect(converted).toEqual({
|
|
161
|
-
parts: [{ text: 'Hello' }],
|
|
164
|
+
parts: [{ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
162
165
|
role: 'model',
|
|
163
166
|
});
|
|
164
167
|
});
|
|
@@ -172,7 +175,7 @@ describe('google contextBuilders', () => {
|
|
|
172
175
|
const converted = await buildGoogleMessage(message);
|
|
173
176
|
|
|
174
177
|
expect(converted).toEqual({
|
|
175
|
-
parts: [{ text: 'Hi' }],
|
|
178
|
+
parts: [{ text: 'Hi', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
176
179
|
role: 'user',
|
|
177
180
|
});
|
|
178
181
|
});
|
|
@@ -196,8 +199,11 @@ describe('google contextBuilders', () => {
|
|
|
196
199
|
|
|
197
200
|
expect(converted).toEqual({
|
|
198
201
|
parts: [
|
|
199
|
-
{ text: 'Check this image:' },
|
|
200
|
-
{
|
|
202
|
+
{ text: 'Check this image:', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE },
|
|
203
|
+
{
|
|
204
|
+
inlineData: { data: '...', mimeType: 'image/png' },
|
|
205
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
206
|
+
},
|
|
201
207
|
],
|
|
202
208
|
role: 'user',
|
|
203
209
|
});
|
|
@@ -334,10 +340,18 @@ describe('google contextBuilders', () => {
|
|
|
334
340
|
|
|
335
341
|
expect(contents).toEqual([
|
|
336
342
|
{
|
|
337
|
-
parts: [
|
|
343
|
+
parts: [
|
|
344
|
+
{
|
|
345
|
+
text: '<plugins>Web Browsing plugin available</plugins>',
|
|
346
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
role: 'user',
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
parts: [{ text: '杭州天气如何', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
338
353
|
role: 'user',
|
|
339
354
|
},
|
|
340
|
-
{ parts: [{ text: '杭州天气如何' }], role: 'user' },
|
|
341
355
|
{
|
|
342
356
|
parts: [
|
|
343
357
|
{
|
|
@@ -421,7 +435,7 @@ describe('google contextBuilders', () => {
|
|
|
421
435
|
|
|
422
436
|
expect(contents).toEqual([
|
|
423
437
|
{
|
|
424
|
-
parts: [{ text: '杭州天气如何' }],
|
|
438
|
+
parts: [{ text: '杭州天气如何', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
425
439
|
role: 'user',
|
|
426
440
|
},
|
|
427
441
|
{
|
|
@@ -507,7 +521,7 @@ describe('google contextBuilders', () => {
|
|
|
507
521
|
|
|
508
522
|
expect(contents).toEqual([
|
|
509
523
|
{
|
|
510
|
-
parts: [{ text: 'First question' }],
|
|
524
|
+
parts: [{ text: 'First question', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
511
525
|
role: 'user',
|
|
512
526
|
},
|
|
513
527
|
{
|
|
@@ -534,7 +548,7 @@ describe('google contextBuilders', () => {
|
|
|
534
548
|
role: 'user',
|
|
535
549
|
},
|
|
536
550
|
{
|
|
537
|
-
parts: [{ text: 'Second question' }],
|
|
551
|
+
parts: [{ text: 'Second question', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
538
552
|
role: 'user',
|
|
539
553
|
},
|
|
540
554
|
{
|
|
@@ -604,11 +618,16 @@ describe('google contextBuilders', () => {
|
|
|
604
618
|
|
|
605
619
|
expect(contents).toEqual([
|
|
606
620
|
{
|
|
607
|
-
parts: [
|
|
621
|
+
parts: [
|
|
622
|
+
{
|
|
623
|
+
text: '<plugins>Web Browsing plugin available</plugins>',
|
|
624
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
625
|
+
},
|
|
626
|
+
],
|
|
608
627
|
role: 'user',
|
|
609
628
|
},
|
|
610
629
|
{
|
|
611
|
-
parts: [{ text: '杭州天气如何' }],
|
|
630
|
+
parts: [{ text: '杭州天气如何', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
612
631
|
role: 'user',
|
|
613
632
|
},
|
|
614
633
|
{
|
|
@@ -635,7 +654,7 @@ describe('google contextBuilders', () => {
|
|
|
635
654
|
role: 'user',
|
|
636
655
|
},
|
|
637
656
|
{
|
|
638
|
-
parts: [{ text: 'Please try again' }],
|
|
657
|
+
parts: [{ text: 'Please try again', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
639
658
|
role: 'user',
|
|
640
659
|
},
|
|
641
660
|
]);
|
|
@@ -651,7 +670,7 @@ describe('google contextBuilders', () => {
|
|
|
651
670
|
const converted = await buildGoogleMessage(message);
|
|
652
671
|
|
|
653
672
|
expect(converted).toEqual({
|
|
654
|
-
parts: [{ text: '' }],
|
|
673
|
+
parts: [{ text: '', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
655
674
|
role: 'user',
|
|
656
675
|
});
|
|
657
676
|
});
|
|
@@ -690,7 +709,12 @@ describe('google contextBuilders', () => {
|
|
|
690
709
|
const contents = await buildGoogleMessages(messages);
|
|
691
710
|
|
|
692
711
|
expect(contents).toHaveLength(1);
|
|
693
|
-
expect(contents).toEqual([
|
|
712
|
+
expect(contents).toEqual([
|
|
713
|
+
{
|
|
714
|
+
parts: [{ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
715
|
+
role: 'user',
|
|
716
|
+
},
|
|
717
|
+
]);
|
|
694
718
|
});
|
|
695
719
|
|
|
696
720
|
it('should not modify the length if model is gemini-1.5-pro', async () => {
|
|
@@ -703,8 +727,14 @@ describe('google contextBuilders', () => {
|
|
|
703
727
|
|
|
704
728
|
expect(contents).toHaveLength(2);
|
|
705
729
|
expect(contents).toEqual([
|
|
706
|
-
{
|
|
707
|
-
|
|
730
|
+
{
|
|
731
|
+
parts: [{ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
732
|
+
role: 'user',
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
parts: [{ text: 'Hi', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
736
|
+
role: 'model',
|
|
737
|
+
},
|
|
708
738
|
]);
|
|
709
739
|
});
|
|
710
740
|
|
|
@@ -730,7 +760,13 @@ describe('google contextBuilders', () => {
|
|
|
730
760
|
expect(contents).toHaveLength(1);
|
|
731
761
|
expect(contents).toEqual([
|
|
732
762
|
{
|
|
733
|
-
parts: [
|
|
763
|
+
parts: [
|
|
764
|
+
{ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE },
|
|
765
|
+
{
|
|
766
|
+
inlineData: { data: '...', mimeType: 'image/png' },
|
|
767
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
768
|
+
},
|
|
769
|
+
],
|
|
734
770
|
role: 'user',
|
|
735
771
|
},
|
|
736
772
|
]);
|
|
@@ -801,8 +837,14 @@ describe('google contextBuilders', () => {
|
|
|
801
837
|
|
|
802
838
|
expect(contents).toHaveLength(2);
|
|
803
839
|
expect(contents).toEqual([
|
|
804
|
-
{
|
|
805
|
-
|
|
840
|
+
{
|
|
841
|
+
parts: [{ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
842
|
+
role: 'user',
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
parts: [{ text: 'Hi', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
846
|
+
role: 'model',
|
|
847
|
+
},
|
|
806
848
|
]);
|
|
807
849
|
});
|
|
808
850
|
|
|
@@ -817,8 +859,14 @@ describe('google contextBuilders', () => {
|
|
|
817
859
|
|
|
818
860
|
expect(contents).toHaveLength(2);
|
|
819
861
|
expect(contents).toEqual([
|
|
820
|
-
{
|
|
821
|
-
|
|
862
|
+
{
|
|
863
|
+
parts: [{ text: 'Hello', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
864
|
+
role: 'user',
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
parts: [{ text: 'Hi', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
868
|
+
role: 'model',
|
|
869
|
+
},
|
|
822
870
|
]);
|
|
823
871
|
});
|
|
824
872
|
|
|
@@ -857,8 +905,14 @@ describe('google contextBuilders', () => {
|
|
|
857
905
|
const contents = await buildGoogleMessages(messages);
|
|
858
906
|
|
|
859
907
|
expect(contents).toEqual([
|
|
860
|
-
{
|
|
861
|
-
|
|
908
|
+
{
|
|
909
|
+
parts: [{ text: 'system prompt', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
910
|
+
role: 'user',
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
parts: [{ text: 'LobeChat 最新版本', thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }],
|
|
914
|
+
role: 'user',
|
|
915
|
+
},
|
|
862
916
|
{
|
|
863
917
|
parts: [
|
|
864
918
|
{
|
|
@@ -29,7 +29,10 @@ export const buildGooglePart = async (
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
case 'text': {
|
|
32
|
-
return {
|
|
32
|
+
return {
|
|
33
|
+
text: content.text,
|
|
34
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
35
|
+
};
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
case 'image_url': {
|
|
@@ -42,6 +45,7 @@ export const buildGooglePart = async (
|
|
|
42
45
|
|
|
43
46
|
return {
|
|
44
47
|
inlineData: { data: base64, mimeType: mimeType || 'image/png' },
|
|
48
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
45
49
|
};
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -50,6 +54,7 @@ export const buildGooglePart = async (
|
|
|
50
54
|
|
|
51
55
|
return {
|
|
52
56
|
inlineData: { data: base64, mimeType },
|
|
57
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -66,6 +71,7 @@ export const buildGooglePart = async (
|
|
|
66
71
|
|
|
67
72
|
return {
|
|
68
73
|
inlineData: { data: base64, mimeType: mimeType || 'video/mp4' },
|
|
74
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
77
|
|
|
@@ -76,6 +82,7 @@ export const buildGooglePart = async (
|
|
|
76
82
|
|
|
77
83
|
return {
|
|
78
84
|
inlineData: { data: base64, mimeType },
|
|
85
|
+
thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE,
|
|
79
86
|
};
|
|
80
87
|
}
|
|
81
88
|
|
|
@@ -126,7 +133,8 @@ export const buildGoogleMessage = async (
|
|
|
126
133
|
}
|
|
127
134
|
|
|
128
135
|
const getParts = async () => {
|
|
129
|
-
if (typeof content === 'string')
|
|
136
|
+
if (typeof content === 'string')
|
|
137
|
+
return [{ text: content, thoughtSignature: GEMINI_MAGIC_THOUGHT_SIGNATURE }];
|
|
130
138
|
|
|
131
139
|
const parts = await Promise.all(content.map(async (c) => await buildGooglePart(c)));
|
|
132
140
|
return parts.filter(Boolean) as Part[];
|
|
@@ -252,6 +252,7 @@ export const MODEL_PARAMETER_CONFLICTS = {
|
|
|
252
252
|
'claude-opus-4-1-20250805',
|
|
253
253
|
'claude-sonnet-4-5-20250929',
|
|
254
254
|
'claude-haiku-4-5-20251001',
|
|
255
|
+
'claude-opus-4-5-20251101',
|
|
255
256
|
]),
|
|
256
257
|
|
|
257
258
|
/**
|
|
@@ -275,5 +276,7 @@ export const MODEL_PARAMETER_CONFLICTS = {
|
|
|
275
276
|
'us.anthropic.claude-sonnet-4-5-20250929-v1:0',
|
|
276
277
|
'anthropic.claude-haiku-4-5-20251001-v1:0',
|
|
277
278
|
'us.anthropic.claude-haiku-4-5-20251001-v1:0',
|
|
279
|
+
'global.anthropic.claude-opus-4-5-20251101-v1:0',
|
|
280
|
+
'anthropic.claude-opus-4-5-20251101-v1:0',
|
|
278
281
|
]),
|
|
279
282
|
};
|