@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.
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- package/.github/workflows/release.yml +2 -0
- package/.i18nrc.js +1 -1
- package/CHANGELOG.md +117 -0
- package/changelog/v1.json +21 -0
- package/locales/ar/components.json +12 -0
- package/locales/ar/models.json +3 -0
- package/locales/bg-BG/components.json +12 -0
- package/locales/bg-BG/models.json +3 -0
- package/locales/de-DE/components.json +12 -0
- package/locales/de-DE/models.json +3 -0
- package/locales/en-US/components.json +12 -0
- package/locales/en-US/models.json +3 -0
- package/locales/es-ES/components.json +12 -0
- package/locales/es-ES/models.json +3 -0
- package/locales/fa-IR/components.json +12 -0
- package/locales/fa-IR/models.json +3 -0
- package/locales/fr-FR/components.json +12 -0
- package/locales/fr-FR/models.json +3 -0
- package/locales/it-IT/components.json +12 -0
- package/locales/it-IT/models.json +3 -0
- package/locales/ja-JP/components.json +12 -0
- package/locales/ja-JP/models.json +3 -0
- package/locales/ko-KR/components.json +12 -0
- package/locales/ko-KR/models.json +3 -0
- package/locales/nl-NL/components.json +12 -0
- package/locales/nl-NL/models.json +3 -0
- package/locales/pl-PL/components.json +12 -0
- package/locales/pl-PL/models.json +3 -0
- package/locales/pt-BR/components.json +12 -0
- package/locales/pt-BR/models.json +3 -0
- package/locales/ru-RU/components.json +12 -0
- package/locales/ru-RU/models.json +3 -0
- package/locales/tr-TR/components.json +12 -0
- package/locales/tr-TR/models.json +3 -0
- package/locales/vi-VN/components.json +12 -0
- package/locales/vi-VN/models.json +3 -0
- package/locales/zh-CN/components.json +12 -0
- package/locales/zh-CN/models.json +3 -0
- package/locales/zh-TW/components.json +12 -0
- package/locales/zh-TW/models.json +3 -0
- package/package.json +5 -5
- package/packages/const/src/image.ts +9 -0
- package/packages/const/src/index.ts +2 -1
- package/packages/const/src/meta.ts +3 -2
- package/packages/const/src/settings/agent.ts +9 -4
- package/packages/const/src/settings/systemAgent.ts +0 -3
- package/packages/database/vitest.config.mts +1 -0
- package/packages/database/vitest.config.server.mts +1 -0
- package/packages/file-loaders/package.json +1 -1
- package/packages/file-loaders/vitest.config.mts +3 -7
- package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +11 -9
- package/packages/model-runtime/src/google/createImage.test.ts +657 -0
- package/packages/model-runtime/src/google/createImage.ts +152 -0
- package/packages/model-runtime/src/google/index.test.ts +0 -328
- package/packages/model-runtime/src/google/index.ts +3 -40
- package/packages/model-runtime/src/utils/modelParse.ts +2 -1
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/createImage.ts +239 -0
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.test.ts +22 -22
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +9 -116
- package/packages/model-runtime/src/utils/postProcessModelList.ts +55 -0
- package/packages/model-runtime/src/utils/streams/google-ai.test.ts +7 -7
- package/packages/model-runtime/src/utils/streams/google-ai.ts +15 -2
- package/packages/model-runtime/src/utils/streams/openai/openai.test.ts +41 -0
- package/packages/model-runtime/src/utils/streams/openai/openai.ts +38 -2
- package/packages/model-runtime/src/utils/streams/protocol.test.ts +32 -0
- package/packages/model-runtime/src/utils/streams/protocol.ts +7 -3
- package/packages/model-runtime/src/utils/usageConverter.test.ts +58 -0
- package/packages/model-runtime/src/utils/usageConverter.ts +5 -1
- package/packages/model-runtime/vitest.config.mts +3 -0
- package/packages/prompts/package.json +0 -1
- package/packages/prompts/src/chains/__tests__/abstractChunk.test.ts +52 -0
- package/packages/prompts/src/chains/__tests__/answerWithContext.test.ts +100 -0
- package/packages/prompts/src/chains/__tests__/rewriteQuery.test.ts +88 -0
- package/packages/prompts/src/chains/__tests__/summaryGenerationTitle.test.ts +107 -0
- package/packages/prompts/src/chains/abstractChunk.ts +0 -2
- package/packages/prompts/src/chains/rewriteQuery.ts +3 -1
- package/packages/prompts/src/index.test.ts +41 -0
- package/packages/prompts/src/prompts/systemRole/index.test.ts +136 -0
- package/packages/prompts/vitest.config.mts +3 -0
- package/packages/types/src/index.ts +2 -0
- package/packages/utils/package.json +5 -1
- package/packages/utils/src/client/index.ts +2 -0
- package/packages/utils/src/server/index.ts +5 -0
- package/packages/utils/vitest.config.mts +4 -0
- package/src/app/(backend)/middleware/auth/index.test.ts +2 -2
- package/src/app/(backend)/middleware/auth/index.ts +1 -1
- package/src/app/(backend)/oidc/consent/route.ts +1 -2
- package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +2 -2
- package/src/app/(backend)/webapi/plugin/gateway/route.ts +1 -1
- package/src/app/[variants]/(main)/files/[id]/page.tsx +1 -1
- package/src/app/[variants]/(main)/settings/sync/page.tsx +1 -1
- package/src/app/[variants]/(main)/settings/system-agent/index.tsx +2 -1
- package/src/components/HtmlPreview/HtmlPreviewAction.tsx +32 -0
- package/src/components/HtmlPreview/PreviewDrawer.tsx +133 -0
- package/src/components/HtmlPreview/index.ts +2 -0
- package/src/config/aiModels/google.ts +42 -22
- package/src/config/aiModels/openrouter.ts +33 -0
- package/src/config/aiModels/vertexai.ts +4 -4
- package/src/features/Conversation/Extras/Usage/UsageDetail/index.tsx +6 -0
- package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.test.ts +38 -0
- package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.ts +13 -1
- package/src/features/Conversation/components/ChatItem/ShareMessageModal/ShareText/index.tsx +1 -1
- package/src/features/Conversation/components/ChatItem/index.tsx +23 -0
- package/src/features/ShareModal/ShareJSON/index.tsx +2 -2
- package/src/features/ShareModal/ShareText/index.tsx +1 -1
- package/src/libs/oidc-provider/adapter.ts +1 -1
- package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +1 -1
- package/src/libs/trpc/edge/middleware/jwtPayload.ts +1 -2
- package/src/libs/trpc/lambda/middleware/keyVaults.ts +1 -2
- package/src/locales/default/chat.ts +1 -0
- package/src/locales/default/components.ts +12 -0
- package/src/middleware.ts +3 -3
- package/src/server/routers/tools/search.test.ts +1 -1
- package/src/services/config.ts +2 -4
- package/src/utils/client/switchLang.ts +1 -1
- package/{packages/utils/src → src/utils}/server/pageProps.ts +2 -1
- package/tsconfig.json +1 -1
- package/vitest.config.mts +1 -0
- package/packages/model-runtime/src/UniformRuntime/index.ts +0 -117
- /package/{packages/const/src → src/const}/locale.ts +0 -0
- /package/{packages/utils/src → src/utils}/locale.test.ts +0 -0
- /package/{packages/utils/src → src/utils}/locale.ts +0 -0
- /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.
|
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": "^
|
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": "^
|
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": "^
|
327
|
+
"cross-env": "^10.0.0",
|
328
328
|
"crypto-js": "^4.2.0",
|
329
329
|
"dbdocs": "^0.16.0",
|
330
|
-
"dotenv": "^
|
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
|
-
import {
|
2
|
-
|
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 {
|
2
|
-
|
3
|
-
|
4
|
-
|
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 */
|
@@ -2,13 +2,9 @@ import { defineConfig } from 'vitest/config';
|
|
2
2
|
|
3
3
|
export default defineConfig({
|
4
4
|
test: {
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
//
|
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
|
-
//
|
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
|
-
//
|
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
|
-
|
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 -
|
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) {
|