@lobehub/chat 1.129.0 → 1.129.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/changelog/v1.json +21 -0
  3. package/docs/development/database-schema.dbml +9 -0
  4. package/locales/ar/models.json +248 -23
  5. package/locales/ar/providers.json +3 -0
  6. package/locales/bg-BG/models.json +248 -23
  7. package/locales/bg-BG/providers.json +3 -0
  8. package/locales/de-DE/models.json +248 -23
  9. package/locales/de-DE/providers.json +3 -0
  10. package/locales/en-US/models.json +248 -23
  11. package/locales/en-US/providers.json +3 -0
  12. package/locales/es-ES/models.json +248 -23
  13. package/locales/es-ES/providers.json +3 -0
  14. package/locales/fa-IR/models.json +248 -23
  15. package/locales/fa-IR/providers.json +3 -0
  16. package/locales/fr-FR/models.json +248 -23
  17. package/locales/fr-FR/providers.json +3 -0
  18. package/locales/it-IT/models.json +248 -23
  19. package/locales/it-IT/providers.json +3 -0
  20. package/locales/ja-JP/models.json +248 -23
  21. package/locales/ja-JP/providers.json +3 -0
  22. package/locales/ko-KR/models.json +248 -23
  23. package/locales/ko-KR/providers.json +3 -0
  24. package/locales/nl-NL/models.json +248 -23
  25. package/locales/nl-NL/providers.json +3 -0
  26. package/locales/pl-PL/models.json +248 -23
  27. package/locales/pl-PL/providers.json +3 -0
  28. package/locales/pt-BR/models.json +248 -23
  29. package/locales/pt-BR/providers.json +3 -0
  30. package/locales/ru-RU/models.json +248 -23
  31. package/locales/ru-RU/providers.json +3 -0
  32. package/locales/tr-TR/models.json +248 -23
  33. package/locales/tr-TR/providers.json +3 -0
  34. package/locales/vi-VN/models.json +248 -23
  35. package/locales/vi-VN/providers.json +3 -0
  36. package/locales/zh-CN/models.json +248 -23
  37. package/locales/zh-CN/providers.json +3 -0
  38. package/locales/zh-TW/models.json +248 -23
  39. package/locales/zh-TW/providers.json +3 -0
  40. package/package.json +1 -1
  41. package/packages/database/migrations/0031_add_agent_index.sql +9 -3
  42. package/packages/database/migrations/0032_improve_agents_field.sql +0 -4
  43. package/packages/database/migrations/0033_modern_mercury.sql +18 -0
  44. package/packages/database/migrations/meta/0033_snapshot.json +6594 -0
  45. package/packages/database/migrations/meta/_journal.json +7 -0
  46. package/packages/database/src/core/migrations.json +23 -6
  47. package/packages/database/src/schemas/message.ts +12 -11
  48. package/packages/database/src/schemas/rag.ts +10 -6
  49. package/packages/database/src/schemas/session.ts +7 -5
  50. package/packages/database/src/schemas/topic.ts +7 -3
  51. package/packages/model-bank/src/aiModels/siliconcloud.ts +45 -0
  52. package/packages/model-runtime/src/providers/siliconcloud/index.ts +19 -11
@@ -231,6 +231,13 @@
231
231
  "when": 1757993755131,
232
232
  "tag": "0032_improve_agents_field",
233
233
  "breakpoints": true
234
+ },
235
+ {
236
+ "idx": 33,
237
+ "version": "7",
238
+ "when": 1758012348218,
239
+ "tag": "0033_modern_mercury",
240
+ "breakpoints": true
234
241
  }
235
242
  ],
236
243
  "version": "6"
@@ -581,22 +581,39 @@
581
581
  },
582
582
  {
583
583
  "sql": [
584
- "-- 将超过 2000 字符的 description 截断为 2000 字符\nUPDATE agents\nSET description = LEFT(description, 2000)\nWHERE LENGTH(description) > 2000;",
585
- "\nCREATE INDEX IF NOT EXISTS \"agents_title_idx\" ON \"agents\" USING btree (\"title\");",
584
+ "-- Truncate title to 150 characters if it exceeds the limit\nUPDATE agents\nSET title = LEFT(title, 200)\nWHERE LENGTH(title) > 200;",
585
+ "\n\n-- Truncate description to 300 characters if it exceeds the limit\nUPDATE agents\nSET description = LEFT(description, 300)\nWHERE LENGTH(description) > 300;",
586
+ "\n\nCREATE INDEX IF NOT EXISTS \"agents_title_idx\" ON \"agents\" USING btree (\"title\");",
586
587
  "\nCREATE INDEX IF NOT EXISTS \"agents_description_idx\" ON \"agents\" USING btree (\"description\");\n"
587
588
  ],
588
589
  "bps": true,
589
590
  "folderMillis": 1757902833213,
590
- "hash": "39b690dc849ae2bb09357a9ab9d1f2e8f3e37f609f636ab192670a2651d4f605"
591
+ "hash": "41395946b955d89f5c97272077d27d131a626b64bdca2b970c0bbcdf0a8370fd"
591
592
  },
592
593
  {
593
594
  "sql": [
594
- "-- 将超过 255 字符的 title 截断为 255 字符\nUPDATE agents\nSET title = LEFT(title, 255)\nWHERE LENGTH(title) > 255;",
595
- "\nALTER TABLE \"agents\" ALTER COLUMN \"title\" SET DATA TYPE varchar(255);",
595
+ "ALTER TABLE \"agents\" ALTER COLUMN \"title\" SET DATA TYPE varchar(255);",
596
596
  "\nALTER TABLE \"agents\" ALTER COLUMN \"description\" SET DATA TYPE varchar(1000);\n"
597
597
  ],
598
598
  "bps": true,
599
599
  "folderMillis": 1757993755131,
600
- "hash": "0e23099a1ae4d5a40fd9ea5667c3d1939548d98488906742b0f029cde272ef27"
600
+ "hash": "bafc1c74796a4c69342e61d28997b0e3a38f1e7d022ba92d9cbf31e00b5748c8"
601
+ },
602
+ {
603
+ "sql": [
604
+ "-- 解决 chunks 表慢查询\nCREATE INDEX IF NOT EXISTS \"chunks_user_id_idx\" ON \"chunks\" USING btree (\"user_id\");",
605
+ "\n\n-- 解决 topics 表批量删除慢查询\nCREATE INDEX IF NOT EXISTS \"topics_user_id_idx\" ON \"topics\" USING btree (\"user_id\");",
606
+ "\nCREATE INDEX IF NOT EXISTS \"topics_id_user_id_idx\" ON \"topics\" USING btree (\"id\",\"user_id\");",
607
+ "\n\n-- 解决 sessions 表删除慢查询\nCREATE INDEX IF NOT EXISTS \"sessions_user_id_idx\" ON \"sessions\" USING btree (\"user_id\");",
608
+ "\nCREATE INDEX IF NOT EXISTS \"sessions_id_user_id_idx\" ON \"sessions\" USING btree (\"id\",\"user_id\");",
609
+ "\n\n-- 解决 messages 表统计查询慢查询\nCREATE INDEX IF NOT EXISTS \"messages_user_id_idx\" ON \"messages\" USING btree (\"user_id\");",
610
+ "\nCREATE INDEX IF NOT EXISTS \"messages_session_id_idx\" ON \"messages\" USING btree (\"session_id\");",
611
+ "\nCREATE INDEX IF NOT EXISTS \"messages_thread_id_idx\" ON \"messages\" USING btree (\"thread_id\");",
612
+ "\n\n-- 解决 embeddings 删除慢查询\nCREATE INDEX IF NOT EXISTS \"embeddings_chunk_id_idx\" ON \"embeddings\" USING btree (\"chunk_id\");",
613
+ "\n"
614
+ ],
615
+ "bps": true,
616
+ "folderMillis": 1758012348218,
617
+ "hash": "ce04ef4cde2db479d28ff08dced8383052c5052c904bab8343b5493fa10b0679"
601
618
  }
602
619
  ]
@@ -18,12 +18,12 @@ import { GroundingSearch } from '@/types/search';
18
18
  import { idGenerator } from '../utils/idGenerator';
19
19
  import { timestamps } from './_helpers';
20
20
  import { agents } from './agent';
21
+ import { chatGroups } from './chatGroup';
21
22
  import { files } from './file';
22
23
  import { chunks, embeddings } from './rag';
23
24
  import { sessions } from './session';
24
25
  import { threads, topics } from './topic';
25
26
  import { users } from './user';
26
- import { chatGroups } from './chatGroup';
27
27
 
28
28
  // @ts-ignore
29
29
  export const messages = pgTable(
@@ -70,16 +70,17 @@ export const messages = pgTable(
70
70
  targetId: text('target_id'),
71
71
  ...timestamps,
72
72
  },
73
- (table) => ({
74
- createdAtIdx: index('messages_created_at_idx').on(table.createdAt),
75
- messageClientIdUnique: uniqueIndex('message_client_id_user_unique').on(
76
- table.clientId,
77
- table.userId,
78
- ),
79
- topicIdIdx: index('messages_topic_id_idx').on(table.topicId),
80
- parentIdIdx: index('messages_parent_id_idx').on(table.parentId),
81
- quotaIdIdx: index('messages_quota_id_idx').on(table.quotaId),
82
- }),
73
+ (table) => [
74
+ index('messages_created_at_idx').on(table.createdAt),
75
+ uniqueIndex('message_client_id_user_unique').on(table.clientId, table.userId),
76
+ index('messages_topic_id_idx').on(table.topicId),
77
+ index('messages_parent_id_idx').on(table.parentId),
78
+ index('messages_quota_id_idx').on(table.quotaId),
79
+
80
+ index('messages_user_id_idx').on(table.userId),
81
+ index('messages_session_id_idx').on(table.sessionId),
82
+ index('messages_thread_id_idx').on(table.threadId),
83
+ ],
83
84
  );
84
85
 
85
86
  // if the message container a plugin
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
2
  import {
3
+ index,
3
4
  integer,
4
5
  jsonb,
5
6
  pgTable,
@@ -29,9 +30,10 @@ export const chunks = pgTable(
29
30
 
30
31
  ...timestamps,
31
32
  },
32
- (t) => ({
33
- clientIdUnique: uniqueIndex('chunks_client_id_user_id_unique').on(t.clientId, t.userId),
34
- }),
33
+ (t) => [
34
+ uniqueIndex('chunks_client_id_user_id_unique').on(t.clientId, t.userId),
35
+ index('chunks_user_id_idx').on(t.userId),
36
+ ],
35
37
  );
36
38
 
37
39
  export type NewChunkItem = typeof chunks.$inferInsert & { fileId?: string };
@@ -75,9 +77,11 @@ export const embeddings = pgTable(
75
77
  clientId: text('client_id'),
76
78
  userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }),
77
79
  },
78
- (t) => ({
79
- clientIdUnique: uniqueIndex('embeddings_client_id_user_id_unique').on(t.clientId, t.userId),
80
- }),
80
+ (t) => [
81
+ uniqueIndex('embeddings_client_id_user_id_unique').on(t.clientId, t.userId),
82
+ // improve delete embeddings query
83
+ index('embeddings_chunk_id_idx').on(t.chunkId),
84
+ ],
81
85
  );
82
86
 
83
87
  export type NewEmbeddingsItem = typeof embeddings.$inferInsert;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
- import { boolean, integer, pgTable, text, uniqueIndex, varchar } from 'drizzle-orm/pg-core';
2
+ import { boolean, index, integer, pgTable, text, uniqueIndex, varchar } from 'drizzle-orm/pg-core';
3
3
  import { createInsertSchema } from 'drizzle-zod';
4
4
 
5
5
  import { idGenerator, randomSlug } from '../utils/idGenerator';
@@ -64,11 +64,13 @@ export const sessions = pgTable(
64
64
 
65
65
  ...timestamps,
66
66
  },
67
- (t) => ({
68
- slugUserIdUnique: uniqueIndex('slug_user_id_unique').on(t.slug, t.userId),
67
+ (t) => [
68
+ uniqueIndex('slug_user_id_unique').on(t.slug, t.userId),
69
+ uniqueIndex('sessions_client_id_user_id_unique').on(t.clientId, t.userId),
69
70
 
70
- clientIdUnique: uniqueIndex('sessions_client_id_user_id_unique').on(t.clientId, t.userId),
71
- }),
71
+ index('sessions_user_id_idx').on(t.userId),
72
+ index('sessions_id_user_id_idx').on(t.id, t.userId),
73
+ ],
72
74
  );
73
75
 
74
76
  export const insertSessionSchema = createInsertSchema(sessions);
@@ -1,15 +1,15 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
- import { boolean, jsonb, pgTable, primaryKey, text, uniqueIndex } from 'drizzle-orm/pg-core';
2
+ import { boolean, index, jsonb, pgTable, primaryKey, text, uniqueIndex } from 'drizzle-orm/pg-core';
3
3
  import { createInsertSchema } from 'drizzle-zod';
4
4
 
5
5
  import { ChatTopicMetadata } from '@/types/topic';
6
6
 
7
7
  import { idGenerator } from '../utils/idGenerator';
8
8
  import { createdAt, timestamps, timestamptz } from './_helpers';
9
+ import { chatGroups } from './chatGroup';
9
10
  import { documents } from './document';
10
11
  import { sessions } from './session';
11
12
  import { users } from './user';
12
- import { chatGroups } from './chatGroup';
13
13
 
14
14
  export const topics = pgTable(
15
15
  'topics',
@@ -29,7 +29,11 @@ export const topics = pgTable(
29
29
  metadata: jsonb('metadata').$type<ChatTopicMetadata | undefined>(),
30
30
  ...timestamps,
31
31
  },
32
- (t) => [uniqueIndex('topics_client_id_user_id_unique').on(t.clientId, t.userId)],
32
+ (t) => [
33
+ uniqueIndex('topics_client_id_user_id_unique').on(t.clientId, t.userId),
34
+ index('topics_user_id_idx').on(t.userId),
35
+ index('topics_id_user_id_idx').on(t.id, t.userId),
36
+ ],
33
37
  );
34
38
 
35
39
  export type NewTopic = typeof topics.$inferInsert;
@@ -84,6 +84,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
84
84
  ],
85
85
  },
86
86
  releasedAt: '2025-08-20',
87
+ settings: {
88
+ extendParams: ['reasoningBudgetToken'],
89
+ },
87
90
  type: 'chat',
88
91
  },
89
92
  {
@@ -105,6 +108,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
105
108
  ],
106
109
  },
107
110
  releasedAt: '2025-07-31',
111
+ settings: {
112
+ extendParams: ['reasoningBudgetToken'],
113
+ },
108
114
  type: 'chat',
109
115
  },
110
116
  {
@@ -164,6 +170,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
164
170
  ],
165
171
  },
166
172
  releasedAt: '2025-08-11',
173
+ settings: {
174
+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],
175
+ },
167
176
  type: 'chat',
168
177
  },
169
178
  {
@@ -184,6 +193,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
184
193
  ],
185
194
  },
186
195
  releasedAt: '2025-07-28',
196
+ settings: {
197
+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],
198
+ },
187
199
  type: 'chat',
188
200
  },
189
201
  {
@@ -223,6 +235,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
223
235
  ],
224
236
  },
225
237
  releasedAt: '2025-06-17',
238
+ settings: {
239
+ extendParams: ['reasoningBudgetToken'],
240
+ },
226
241
  type: 'chat',
227
242
  },
228
243
  {
@@ -334,6 +349,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
334
349
  ],
335
350
  },
336
351
  releasedAt: '2025-06-17',
352
+ settings: {
353
+ extendParams: ['reasoningBudgetToken'],
354
+ },
337
355
  type: 'chat',
338
356
  },
339
357
  {
@@ -353,6 +371,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
353
371
  ],
354
372
  },
355
373
  releasedAt: '2025-06-27',
374
+ settings: {
375
+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],
376
+ },
356
377
  type: 'chat',
357
378
  },
358
379
  {
@@ -372,6 +393,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
372
393
  ],
373
394
  },
374
395
  releasedAt: '2025-06-16',
396
+ settings: {
397
+ extendParams: ['reasoningBudgetToken'],
398
+ },
375
399
  type: 'chat',
376
400
  },
377
401
  {
@@ -391,6 +415,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
391
415
  ],
392
416
  },
393
417
  releasedAt: '2025-05-26',
418
+ settings: {
419
+ extendParams: ['reasoningBudgetToken'],
420
+ },
394
421
  type: 'chat',
395
422
  },
396
423
  {
@@ -412,6 +439,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
412
439
  ],
413
440
  },
414
441
  releasedAt: '2025-07-25',
442
+ settings: {
443
+ extendParams: ['reasoningBudgetToken'],
444
+ },
415
445
  type: 'chat',
416
446
  },
417
447
  {
@@ -453,6 +483,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
453
483
  ],
454
484
  },
455
485
  releasedAt: '2025-07-30',
486
+ settings: {
487
+ extendParams: ['reasoningBudgetToken'],
488
+ },
456
489
  type: 'chat',
457
490
  },
458
491
  {
@@ -653,6 +686,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
653
686
  ],
654
687
  },
655
688
  releasedAt: '2025-04-14',
689
+ settings: {
690
+ extendParams: ['reasoningBudgetToken'],
691
+ },
656
692
  type: 'chat',
657
693
  },
658
694
  {
@@ -788,6 +824,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
788
824
  { name: 'textOutput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
789
825
  ],
790
826
  },
827
+ settings: {
828
+ extendParams: ['reasoningBudgetToken'],
829
+ },
791
830
  type: 'chat',
792
831
  },
793
832
  {
@@ -807,6 +846,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
807
846
  { name: 'textOutput', rate: 16, strategy: 'fixed', unit: 'millionTokens' },
808
847
  ],
809
848
  },
849
+ settings: {
850
+ extendParams: ['reasoningBudgetToken'],
851
+ },
810
852
  type: 'chat',
811
853
  },
812
854
  {
@@ -1012,6 +1054,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
1012
1054
  { name: 'textOutput', rate: 4, strategy: 'fixed', unit: 'millionTokens' },
1013
1055
  ],
1014
1056
  },
1057
+ settings: {
1058
+ extendParams: ['reasoningBudgetToken'],
1059
+ },
1015
1060
  type: 'chat',
1016
1061
  },
1017
1062
  {
@@ -43,21 +43,29 @@ export const LobeSiliconCloudAI = createOpenAICompatibleRuntime({
43
43
  const thinkingBudget =
44
44
  thinking?.budget_tokens === 0 ? 1 : thinking?.budget_tokens || undefined;
45
45
 
46
- return {
46
+ const result: any = {
47
47
  ...rest,
48
- ...(['qwen3', 'deepseek-v3.1'].some((keyword) => model.toLowerCase().includes(keyword))
49
- ? {
50
- enable_thinking: thinking !== undefined ? thinking.type === 'enabled' : false,
51
- thinking_budget:
52
- thinkingBudget === undefined
53
- ? undefined
54
- : Math.min(Math.max(thinkingBudget, 1), 32_768),
55
- }
56
- : {}),
57
48
  max_tokens:
58
49
  max_tokens === undefined ? undefined : Math.min(Math.max(max_tokens, 1), 16_384),
59
50
  model,
60
- } as any;
51
+ };
52
+
53
+ if (thinking) {
54
+ // 只有部分模型支持指定 enable_thinking,其余一些慢思考模型只支持调节 thinking budget
55
+ const hybridThinkingModels = [
56
+ /GLM-4\.5(?!.*Air$)/, // GLM-4.5 和 GLM-4.5V(不包含 GLM-4.5 Air)
57
+ /Qwen3-(?:\d+B|\d+B-A\d+B)$/, // Qwen3-8B、Qwen3-14B、Qwen3-32B、Qwen3-30B-A3B、Qwen3-235B-A22B
58
+ /DeepSeek-V3\.1/,
59
+ /Hunyuan-A13B-Instruct/,
60
+ ];
61
+ if (hybridThinkingModels.some((regexp) => regexp.test(model))) {
62
+ result.enable_thinking = thinking.type === 'enabled';
63
+ }
64
+ if (typeof thinkingBudget !== 'undefined') {
65
+ result.thinking_budget = Math.min(Math.max(thinkingBudget, 1), 32_768);
66
+ }
67
+ }
68
+ return result;
61
69
  },
62
70
  },
63
71
  debug: {