@lobehub/chat 1.116.3 → 1.117.0

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 (124) hide show
  1. package/.github/PULL_REQUEST_TEMPLATE.md +1 -0
  2. package/.github/workflows/release.yml +2 -0
  3. package/.i18nrc.js +1 -1
  4. package/CHANGELOG.md +117 -0
  5. package/changelog/v1.json +21 -0
  6. package/locales/ar/components.json +12 -0
  7. package/locales/ar/models.json +3 -0
  8. package/locales/bg-BG/components.json +12 -0
  9. package/locales/bg-BG/models.json +3 -0
  10. package/locales/de-DE/components.json +12 -0
  11. package/locales/de-DE/models.json +3 -0
  12. package/locales/en-US/components.json +12 -0
  13. package/locales/en-US/models.json +3 -0
  14. package/locales/es-ES/components.json +12 -0
  15. package/locales/es-ES/models.json +3 -0
  16. package/locales/fa-IR/components.json +12 -0
  17. package/locales/fa-IR/models.json +3 -0
  18. package/locales/fr-FR/components.json +12 -0
  19. package/locales/fr-FR/models.json +3 -0
  20. package/locales/it-IT/components.json +12 -0
  21. package/locales/it-IT/models.json +3 -0
  22. package/locales/ja-JP/components.json +12 -0
  23. package/locales/ja-JP/models.json +3 -0
  24. package/locales/ko-KR/components.json +12 -0
  25. package/locales/ko-KR/models.json +3 -0
  26. package/locales/nl-NL/components.json +12 -0
  27. package/locales/nl-NL/models.json +3 -0
  28. package/locales/pl-PL/components.json +12 -0
  29. package/locales/pl-PL/models.json +3 -0
  30. package/locales/pt-BR/components.json +12 -0
  31. package/locales/pt-BR/models.json +3 -0
  32. package/locales/ru-RU/components.json +12 -0
  33. package/locales/ru-RU/models.json +3 -0
  34. package/locales/tr-TR/components.json +12 -0
  35. package/locales/tr-TR/models.json +3 -0
  36. package/locales/vi-VN/components.json +12 -0
  37. package/locales/vi-VN/models.json +3 -0
  38. package/locales/zh-CN/components.json +12 -0
  39. package/locales/zh-CN/models.json +3 -0
  40. package/locales/zh-TW/components.json +12 -0
  41. package/locales/zh-TW/models.json +3 -0
  42. package/package.json +5 -5
  43. package/packages/const/src/image.ts +9 -0
  44. package/packages/const/src/index.ts +2 -1
  45. package/packages/const/src/meta.ts +3 -2
  46. package/packages/const/src/settings/agent.ts +9 -4
  47. package/packages/const/src/settings/systemAgent.ts +0 -3
  48. package/packages/database/vitest.config.mts +1 -0
  49. package/packages/database/vitest.config.server.mts +1 -0
  50. package/packages/file-loaders/package.json +1 -1
  51. package/packages/file-loaders/vitest.config.mts +3 -7
  52. package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +11 -9
  53. package/packages/model-runtime/src/google/createImage.test.ts +657 -0
  54. package/packages/model-runtime/src/google/createImage.ts +152 -0
  55. package/packages/model-runtime/src/google/index.test.ts +0 -328
  56. package/packages/model-runtime/src/google/index.ts +3 -40
  57. package/packages/model-runtime/src/utils/modelParse.ts +2 -1
  58. package/packages/model-runtime/src/utils/openaiCompatibleFactory/createImage.ts +239 -0
  59. package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.test.ts +22 -22
  60. package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +9 -116
  61. package/packages/model-runtime/src/utils/postProcessModelList.ts +55 -0
  62. package/packages/model-runtime/src/utils/streams/google-ai.test.ts +7 -7
  63. package/packages/model-runtime/src/utils/streams/google-ai.ts +15 -2
  64. package/packages/model-runtime/src/utils/streams/openai/openai.test.ts +41 -0
  65. package/packages/model-runtime/src/utils/streams/openai/openai.ts +38 -2
  66. package/packages/model-runtime/src/utils/streams/protocol.test.ts +32 -0
  67. package/packages/model-runtime/src/utils/streams/protocol.ts +7 -3
  68. package/packages/model-runtime/src/utils/usageConverter.test.ts +58 -0
  69. package/packages/model-runtime/src/utils/usageConverter.ts +5 -1
  70. package/packages/model-runtime/vitest.config.mts +3 -0
  71. package/packages/prompts/package.json +0 -1
  72. package/packages/prompts/src/chains/__tests__/abstractChunk.test.ts +52 -0
  73. package/packages/prompts/src/chains/__tests__/answerWithContext.test.ts +100 -0
  74. package/packages/prompts/src/chains/__tests__/rewriteQuery.test.ts +88 -0
  75. package/packages/prompts/src/chains/__tests__/summaryGenerationTitle.test.ts +107 -0
  76. package/packages/prompts/src/chains/abstractChunk.ts +0 -2
  77. package/packages/prompts/src/chains/rewriteQuery.ts +3 -1
  78. package/packages/prompts/src/index.test.ts +41 -0
  79. package/packages/prompts/src/prompts/systemRole/index.test.ts +136 -0
  80. package/packages/prompts/vitest.config.mts +3 -0
  81. package/packages/types/src/index.ts +2 -0
  82. package/packages/utils/package.json +5 -1
  83. package/packages/utils/src/client/index.ts +2 -0
  84. package/packages/utils/src/server/index.ts +5 -0
  85. package/packages/utils/vitest.config.mts +4 -0
  86. package/src/app/(backend)/middleware/auth/index.test.ts +2 -2
  87. package/src/app/(backend)/middleware/auth/index.ts +1 -1
  88. package/src/app/(backend)/oidc/consent/route.ts +1 -2
  89. package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +2 -2
  90. package/src/app/(backend)/webapi/plugin/gateway/route.ts +1 -1
  91. package/src/app/[variants]/(main)/files/[id]/page.tsx +1 -1
  92. package/src/app/[variants]/(main)/settings/sync/page.tsx +1 -1
  93. package/src/app/[variants]/(main)/settings/system-agent/index.tsx +2 -1
  94. package/src/components/HtmlPreview/HtmlPreviewAction.tsx +32 -0
  95. package/src/components/HtmlPreview/PreviewDrawer.tsx +133 -0
  96. package/src/components/HtmlPreview/index.ts +2 -0
  97. package/src/config/aiModels/google.ts +42 -22
  98. package/src/config/aiModels/openrouter.ts +33 -0
  99. package/src/config/aiModels/vertexai.ts +4 -4
  100. package/src/features/Conversation/Extras/Usage/UsageDetail/index.tsx +6 -0
  101. package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.test.ts +38 -0
  102. package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.ts +13 -1
  103. package/src/features/Conversation/components/ChatItem/ShareMessageModal/ShareText/index.tsx +1 -1
  104. package/src/features/Conversation/components/ChatItem/index.tsx +23 -0
  105. package/src/features/ShareModal/ShareJSON/index.tsx +2 -2
  106. package/src/features/ShareModal/ShareText/index.tsx +1 -1
  107. package/src/libs/oidc-provider/adapter.ts +1 -1
  108. package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +1 -1
  109. package/src/libs/trpc/edge/middleware/jwtPayload.ts +1 -2
  110. package/src/libs/trpc/lambda/middleware/keyVaults.ts +1 -2
  111. package/src/locales/default/chat.ts +1 -0
  112. package/src/locales/default/components.ts +12 -0
  113. package/src/middleware.ts +3 -3
  114. package/src/server/routers/tools/search.test.ts +1 -1
  115. package/src/services/config.ts +2 -4
  116. package/src/utils/client/switchLang.ts +1 -1
  117. package/{packages/utils/src → src/utils}/server/pageProps.ts +2 -1
  118. package/tsconfig.json +1 -1
  119. package/vitest.config.mts +1 -0
  120. package/packages/model-runtime/src/UniformRuntime/index.ts +0 -117
  121. /package/{packages/const/src → src/const}/locale.ts +0 -0
  122. /package/{packages/utils/src → src/utils}/locale.test.ts +0 -0
  123. /package/{packages/utils/src → src/utils}/locale.ts +0 -0
  124. /package/{packages/utils/src → src/utils}/server/routeVariants.ts +0 -0
@@ -73,6 +73,18 @@
73
73
  "GoBack": {
74
74
  "back": "Quay lại"
75
75
  },
76
+ "HtmlPreview": {
77
+ "actions": {
78
+ "download": "Tải xuống",
79
+ "preview": "Xem trước"
80
+ },
81
+ "iframeTitle": "Xem trước HTML",
82
+ "mode": {
83
+ "code": "Mã",
84
+ "preview": "Xem trước"
85
+ },
86
+ "title": "Xem trước HTML"
87
+ },
76
88
  "ImageUpload": {
77
89
  "actions": {
78
90
  "changeImage": "Nhấn để thay đổi hình ảnh",
@@ -1220,6 +1220,9 @@
1220
1220
  "gemini-2.5-flash-image-preview": {
1221
1221
  "description": "Gemini 2.5 Flash Image Preview là mô hình đa phương thức nguyên bản mới nhất, nhanh nhất và hiệu quả nhất của Google; nó cho phép bạn tạo và chỉnh sửa hình ảnh thông qua hội thoại."
1222
1222
  },
1223
+ "gemini-2.5-flash-image-preview:image": {
1224
+ "description": "Gemini 2.5 Flash Image Preview là mô hình đa phương thức gốc mới nhất, nhanh nhất và hiệu quả nhất của Google, cho phép bạn tạo và chỉnh sửa hình ảnh thông qua đối thoại."
1225
+ },
1223
1226
  "gemini-2.5-flash-lite": {
1224
1227
  "description": "Gemini 2.5 Flash-Lite là mô hình nhỏ nhất và có hiệu suất chi phí tốt nhất của Google, được thiết kế dành cho việc sử dụng quy mô lớn."
1225
1228
  },
@@ -73,6 +73,18 @@
73
73
  "GoBack": {
74
74
  "back": "返回"
75
75
  },
76
+ "HtmlPreview": {
77
+ "actions": {
78
+ "download": "下载",
79
+ "preview": "预览"
80
+ },
81
+ "iframeTitle": "HTML 预览",
82
+ "mode": {
83
+ "code": "代码",
84
+ "preview": "预览"
85
+ },
86
+ "title": "HTML 预览"
87
+ },
76
88
  "ImageUpload": {
77
89
  "actions": {
78
90
  "changeImage": "点击更换图片",
@@ -1220,6 +1220,9 @@
1220
1220
  "gemini-2.5-flash-image-preview": {
1221
1221
  "description": "Gemini 2.5 Flash Image Preview 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。"
1222
1222
  },
1223
+ "gemini-2.5-flash-image-preview:image": {
1224
+ "description": "Gemini 2.5 Flash Image Preview 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。"
1225
+ },
1223
1226
  "gemini-2.5-flash-lite": {
1224
1227
  "description": "Gemini 2.5 Flash-Lite 是 Google 最小、性价比最高的模型,专为大规模使用而设计。"
1225
1228
  },
@@ -73,6 +73,18 @@
73
73
  "GoBack": {
74
74
  "back": "返回"
75
75
  },
76
+ "HtmlPreview": {
77
+ "actions": {
78
+ "download": "下載",
79
+ "preview": "預覽"
80
+ },
81
+ "iframeTitle": "HTML 預覽",
82
+ "mode": {
83
+ "code": "程式碼",
84
+ "preview": "預覽"
85
+ },
86
+ "title": "HTML 預覽"
87
+ },
76
88
  "ImageUpload": {
77
89
  "actions": {
78
90
  "changeImage": "點擊更換圖片",
@@ -1220,6 +1220,9 @@
1220
1220
  "gemini-2.5-flash-image-preview": {
1221
1221
  "description": "Gemini 2.5 Flash Image Preview 是 Google 最新、速度最快且效率最高的原生多模態模型,允許您透過對話生成與編輯圖像。"
1222
1222
  },
1223
+ "gemini-2.5-flash-image-preview:image": {
1224
+ "description": "Gemini 2.5 Flash Image Preview 是 Google 最新、最快、最高效的原生多模態模型,它允許您透過對話生成和編輯圖像。"
1225
+ },
1223
1226
  "gemini-2.5-flash-lite": {
1224
1227
  "description": "Gemini 2.5 Flash-Lite 是 Google 最小、性價比最高的模型,專為大規模使用而設計。"
1225
1228
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.116.3",
3
+ "version": "1.117.0",
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",
@@ -183,7 +183,7 @@
183
183
  "dayjs": "^1.11.13",
184
184
  "debug": "^4.4.1",
185
185
  "dexie": "^3.2.7",
186
- "diff": "^7.0.0",
186
+ "diff": "^8.0.0",
187
187
  "drizzle-orm": "^0.44.4",
188
188
  "drizzle-zod": "^0.5.1",
189
189
  "epub2": "^3.0.2",
@@ -300,7 +300,7 @@
300
300
  "@types/chroma-js": "^3.1.1",
301
301
  "@types/crypto-js": "^4.2.2",
302
302
  "@types/debug": "^4.1.12",
303
- "@types/diff": "^7.0.2",
303
+ "@types/diff": "^8.0.0",
304
304
  "@types/fs-extra": "^11.0.4",
305
305
  "@types/ip": "^1.1.3",
306
306
  "@types/json-schema": "^7.0.15",
@@ -324,10 +324,10 @@
324
324
  "ajv-keywords": "^5.1.0",
325
325
  "commitlint": "^19.8.1",
326
326
  "consola": "^3.4.2",
327
- "cross-env": "^7.0.3",
327
+ "cross-env": "^10.0.0",
328
328
  "crypto-js": "^4.2.0",
329
329
  "dbdocs": "^0.16.0",
330
- "dotenv": "^16.6.1",
330
+ "dotenv": "^17.0.0",
331
331
  "dpdm-fast": "1.0.7",
332
332
  "drizzle-dbml-generator": "^0.10.0",
333
333
  "drizzle-kit": "^0.31.4",
@@ -1,3 +1,5 @@
1
+ import { ModelParamsSchema } from '@/libs/standard-parameters';
2
+
1
3
  /**
2
4
  * 默认宽高比,当模型不支持原生宽高比时使用
3
5
  */
@@ -40,3 +42,10 @@ export const DEFAULT_DIMENSION_CONSTRAINTS = {
40
42
  } as const;
41
43
 
42
44
  export const MAX_SEED = 2 ** 31 - 1;
45
+
46
+ export const CHAT_MODEL_IMAGE_GENERATION_PARAMS: ModelParamsSchema = {
47
+ imageUrl: {
48
+ default: null,
49
+ },
50
+ prompt: { default: '' },
51
+ };
@@ -1,5 +1,6 @@
1
+ export * from './branding';
1
2
  export * from './image';
2
- export * from './locale';
3
+ export * from './layoutTokens';
3
4
  export * from './message';
4
5
  export * from './settings';
5
6
  export * from './version';
@@ -1,5 +1,6 @@
1
- import { BRANDING_LOGO_URL } from '@/const/branding';
2
- import { MetaData } from '@/types/meta';
1
+ import { MetaData } from '@lobechat/types';
2
+
3
+ import { BRANDING_LOGO_URL } from './branding';
3
4
 
4
5
  export const DEFAULT_AVATAR = '🤖';
5
6
  export const DEFAULT_USER_AVATAR = '😀';
@@ -1,7 +1,12 @@
1
- import { DEFAULT_AGENT_META } from '@/const/meta';
2
- import { DEFAULT_MODEL, DEFAULT_PROVIDER } from '@/const/settings/llm';
3
- import { LobeAgentChatConfig, LobeAgentConfig, LobeAgentTTSConfig } from '@/types/agent';
4
- import { UserDefaultAgent } from '@/types/user/settings';
1
+ import {
2
+ LobeAgentChatConfig,
3
+ LobeAgentConfig,
4
+ LobeAgentTTSConfig,
5
+ UserDefaultAgent,
6
+ } from '@lobechat/types';
7
+
8
+ import { DEFAULT_AGENT_META } from '../meta';
9
+ import { DEFAULT_MODEL, DEFAULT_PROVIDER } from './llm';
5
10
 
6
11
  export const DEFAUTT_AGENT_TTS_CONFIG: LobeAgentTTSConfig = {
7
12
  showAllLocaleVoice: false,
@@ -6,9 +6,6 @@ import {
6
6
 
7
7
  import { DEFAULT_MODEL, DEFAULT_PROVIDER } from './llm';
8
8
 
9
- export const DEFAULT_REWRITE_QUERY =
10
- 'Given the following conversation and a follow-up question, rephrase the follow up question to be a standalone question, in its original language. Keep as much details as possible from previous messages. Keep entity names and all.';
11
-
12
9
  export const DEFAULT_SYSTEM_AGENT_ITEM: SystemAgentItem = {
13
10
  model: DEFAULT_MODEL,
14
11
  provider: DEFAULT_PROVIDER,
@@ -13,6 +13,7 @@ export default defineConfig({
13
13
  '@/utils/errorResponse': resolve(__dirname, '../../src/utils/errorResponse'),
14
14
  '@/utils': resolve(__dirname, '../utils/src'),
15
15
  '@/database': resolve(__dirname, '../database/src'),
16
+ '@/libs/model-runtime': resolve(__dirname, '../model-runtime/src'),
16
17
  '@/types': resolve(__dirname, '../types/src'),
17
18
  '@': resolve(__dirname, '../../src'),
18
19
  /* eslint-enable */
@@ -9,6 +9,7 @@ export default defineConfig({
9
9
  '@/utils/errorResponse': resolve(__dirname, '../../src/utils/errorResponse'),
10
10
  '@/utils': resolve(__dirname, '../utils/src'),
11
11
  '@/database': resolve(__dirname, '../database/src'),
12
+ '@/libs/model-runtime': resolve(__dirname, '../model-runtime/src'),
12
13
  '@/types': resolve(__dirname, '../types/src'),
13
14
  '@': resolve(__dirname, '../../src'),
14
15
  /* eslint-enable */
@@ -33,7 +33,7 @@
33
33
  "mammoth": "^1.8.0",
34
34
  "officeparser": "5.1.1",
35
35
  "pdfjs-dist": "4.10.38",
36
- "xlsx": "^0.18.5",
36
+ "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
37
37
  "yauzl": "^3.2.0"
38
38
  },
39
39
  "devDependencies": {
@@ -2,13 +2,9 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
- // coverage: {
6
- // all: false,
7
- // provider: 'v8',
8
- // reporter: ['text', 'json', 'lcov', 'text-summary'],
9
- // reportsDirectory: './coverage/app',
10
- // },
5
+ coverage: {
6
+ reporter: ['text', 'json', 'lcov', 'text-summary'],
7
+ },
11
8
  environment: 'happy-dom',
12
- // setupFiles: join(__dirname, './test/setup.ts'),
13
9
  },
14
10
  });
@@ -10,6 +10,7 @@ import {
10
10
  CreateImageOptions,
11
11
  CustomClientOptions,
12
12
  } from '@/libs/model-runtime/utils/openaiCompatibleFactory';
13
+ import { postProcessModelList } from '@/libs/model-runtime/utils/postProcessModelList';
13
14
  import type { ChatModelCard } from '@/types/llm';
14
15
 
15
16
  import { LobeRuntimeAI } from '../BaseAI';
@@ -146,27 +147,27 @@ export const createRouterRuntime = ({
146
147
  this._options = _options;
147
148
  }
148
149
 
149
- // 获取 runtime models 列表,支持同步数组和异步函数,带缓存机制
150
+ // Get runtime's models list, supporting both synchronous arrays and asynchronous functions with caching
150
151
  private async getModels(runtimeItem: RuntimeItem): Promise<string[]> {
151
152
  const cacheKey = runtimeItem.id;
152
153
 
153
- // 如果是同步数组,直接返回不需要缓存
154
+ // If it's a synchronous array, return directly without caching
154
155
  if (typeof runtimeItem.models !== 'function') {
155
156
  return runtimeItem.models || [];
156
157
  }
157
158
 
158
- // 检查缓存
159
+ // Check cache
159
160
  if (this._modelCache.has(cacheKey)) {
160
161
  return this._modelCache.get(cacheKey)!;
161
162
  }
162
163
 
163
- // 获取模型列表并缓存结果
164
+ // Get model list and cache result
164
165
  const models = await runtimeItem.models();
165
166
  this._modelCache.set(cacheKey, models);
166
167
  return models;
167
168
  }
168
169
 
169
- // 检查下是否能匹配到特定模型,否则默认使用最后一个 runtime
170
+ // Check if it can match a specific model, otherwise default to using the last runtime
170
171
  async getRuntimeByModel(model: string) {
171
172
  for (const runtimeItem of this._runtimes) {
172
173
  const models = await this.getModels(runtimeItem);
@@ -208,10 +209,11 @@ export const createRouterRuntime = ({
208
209
 
209
210
  async models() {
210
211
  if (models && typeof models === 'function') {
211
- // 如果是函数式配置,使用最后一个 runtime client 调用函数
212
+ // If it's function-style configuration, use the last runtime's client to call the function
212
213
  const lastRuntime = this._runtimes.at(-1)?.runtime;
213
214
  if (lastRuntime && 'client' in lastRuntime) {
214
- return await models({ client: (lastRuntime as any).client });
215
+ const modelList = await models({ client: (lastRuntime as any).client });
216
+ return await postProcessModelList(modelList);
215
217
  }
216
218
  }
217
219
  return this._runtimes.at(-1)?.runtime.models?.();
@@ -230,8 +232,8 @@ export const createRouterRuntime = ({
230
232
  }
231
233
 
232
234
  /**
233
- * 清除模型列表缓存,强制下次获取时重新加载
234
- * @param runtimeId - 可选,指定清除特定 runtime 的缓存,不传则清除所有缓存
235
+ * Clear model list cache, forcing reload on next access
236
+ * @param runtimeId - Optional, specify to clear cache for a specific runtime, omit to clear all caches
235
237
  */
236
238
  clearModelCache(runtimeId?: string) {
237
239
  if (runtimeId) {