@lobehub/chat 1.120.6 → 1.121.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/.cursor/rules/project-structure.mdc +54 -42
- package/.cursor/rules/testing-guide/testing-guide.mdc +28 -17
- package/.env.development +122 -0
- package/.vscode/settings.json +0 -1
- package/CHANGELOG.md +50 -0
- package/CLAUDE.md +3 -4
- package/changelog/v1.json +18 -0
- package/docker-compose/local/init_data.json +981 -1024
- package/docker-compose.development.yml +40 -0
- package/docs/development/basic/work-with-server-side-database.mdx +77 -0
- package/docs/development/basic/work-with-server-side-database.zh-CN.mdx +77 -0
- package/docs/self-hosting/advanced/s3/cloudflare-r2.mdx +1 -1
- package/docs/self-hosting/advanced/s3/cloudflare-r2.zh-CN.mdx +2 -2
- package/locales/ar/chat.json +2 -1
- package/locales/ar/models.json +0 -9
- package/locales/ar/providers.json +3 -0
- package/locales/bg-BG/chat.json +2 -1
- package/locales/bg-BG/models.json +0 -9
- package/locales/bg-BG/providers.json +3 -0
- package/locales/de-DE/chat.json +2 -1
- package/locales/de-DE/models.json +0 -9
- package/locales/de-DE/providers.json +3 -0
- package/locales/en-US/chat.json +2 -1
- package/locales/en-US/models.json +0 -9
- package/locales/en-US/providers.json +3 -0
- package/locales/es-ES/chat.json +2 -1
- package/locales/es-ES/models.json +0 -9
- package/locales/es-ES/providers.json +3 -0
- package/locales/fa-IR/chat.json +2 -1
- package/locales/fa-IR/models.json +0 -9
- package/locales/fa-IR/providers.json +3 -0
- package/locales/fr-FR/chat.json +2 -1
- package/locales/fr-FR/models.json +0 -9
- package/locales/fr-FR/providers.json +3 -0
- package/locales/it-IT/chat.json +2 -1
- package/locales/it-IT/models.json +0 -9
- package/locales/it-IT/providers.json +3 -0
- package/locales/ja-JP/chat.json +2 -1
- package/locales/ja-JP/models.json +0 -9
- package/locales/ja-JP/providers.json +3 -0
- package/locales/ko-KR/chat.json +2 -1
- package/locales/ko-KR/models.json +0 -9
- package/locales/ko-KR/providers.json +3 -0
- package/locales/nl-NL/chat.json +2 -1
- package/locales/nl-NL/models.json +0 -9
- package/locales/nl-NL/providers.json +3 -0
- package/locales/pl-PL/chat.json +2 -1
- package/locales/pl-PL/models.json +0 -9
- package/locales/pl-PL/providers.json +3 -0
- package/locales/pt-BR/chat.json +2 -1
- package/locales/pt-BR/models.json +0 -9
- package/locales/pt-BR/providers.json +3 -0
- package/locales/ru-RU/chat.json +2 -1
- package/locales/ru-RU/models.json +0 -9
- package/locales/ru-RU/providers.json +3 -0
- package/locales/tr-TR/chat.json +2 -1
- package/locales/tr-TR/models.json +0 -9
- package/locales/tr-TR/providers.json +3 -0
- package/locales/vi-VN/chat.json +2 -1
- package/locales/vi-VN/models.json +0 -9
- package/locales/vi-VN/providers.json +3 -0
- package/locales/zh-CN/chat.json +2 -1
- package/locales/zh-CN/common.json +7 -0
- package/locales/zh-CN/models.json +0 -9
- package/locales/zh-CN/providers.json +3 -0
- package/locales/zh-TW/chat.json +2 -1
- package/locales/zh-TW/models.json +0 -9
- package/locales/zh-TW/providers.json +3 -0
- package/package.json +2 -1
- package/packages/database/src/repositories/aiInfra/index.ts +3 -1
- package/packages/model-runtime/src/RouterRuntime/createRuntime.test.ts +6 -91
- package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +6 -28
- package/packages/model-runtime/src/openrouter/index.ts +15 -12
- package/packages/model-runtime/src/openrouter/type.ts +10 -0
- package/packages/model-runtime/src/utils/modelParse.test.ts +66 -0
- package/packages/model-runtime/src/utils/modelParse.ts +15 -3
- package/packages/model-runtime/src/utils/postProcessModelList.ts +1 -0
- package/packages/utils/src/detectChinese.test.ts +37 -0
- package/packages/utils/src/detectChinese.ts +12 -0
- package/packages/utils/src/index.ts +1 -0
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.test.tsx +33 -18
- package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +12 -0
- package/src/features/ChatInput/useSend.ts +14 -2
- package/src/hooks/useGeminiChineseWarning.tsx +91 -0
- package/src/locales/default/common.ts +7 -0
- package/src/store/global/initialState.ts +2 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
import { containsChinese } from '@lobechat/utils';
|
2
|
+
import { App, Checkbox } from 'antd';
|
3
|
+
import React, { useCallback } from 'react';
|
4
|
+
import { useTranslation } from 'react-i18next';
|
5
|
+
|
6
|
+
import { useGlobalStore } from '@/store/global';
|
7
|
+
import { systemStatusSelectors } from '@/store/global/selectors';
|
8
|
+
|
9
|
+
const shouldShowChineseWarning = (
|
10
|
+
model: string,
|
11
|
+
prompt: string,
|
12
|
+
hasWarningBeenDismissed: boolean,
|
13
|
+
): boolean => {
|
14
|
+
return (
|
15
|
+
model.includes('gemini-2.5-flash-image-preview') &&
|
16
|
+
!hasWarningBeenDismissed &&
|
17
|
+
Boolean(prompt) &&
|
18
|
+
containsChinese(prompt)
|
19
|
+
);
|
20
|
+
};
|
21
|
+
|
22
|
+
interface UseGeminiChineseWarningOptions {
|
23
|
+
model: string;
|
24
|
+
prompt: string;
|
25
|
+
scenario?: 'chat' | 'image';
|
26
|
+
}
|
27
|
+
|
28
|
+
export const useGeminiChineseWarning = () => {
|
29
|
+
const { t } = useTranslation('common');
|
30
|
+
const { modal } = App.useApp();
|
31
|
+
|
32
|
+
const [hideGeminiChineseWarning, updateSystemStatus] = useGlobalStore((s) => [
|
33
|
+
systemStatusSelectors.systemStatus(s).hideGemini2_5FlashImagePreviewChineseWarning ?? false,
|
34
|
+
s.updateSystemStatus,
|
35
|
+
]);
|
36
|
+
|
37
|
+
const checkWarning = useCallback(
|
38
|
+
async ({
|
39
|
+
model,
|
40
|
+
prompt,
|
41
|
+
scenario = 'chat',
|
42
|
+
}: UseGeminiChineseWarningOptions): Promise<boolean> => {
|
43
|
+
if (!shouldShowChineseWarning(model, prompt, hideGeminiChineseWarning)) {
|
44
|
+
return true;
|
45
|
+
}
|
46
|
+
|
47
|
+
return new Promise<boolean>((resolve) => {
|
48
|
+
let doNotShowAgain = false;
|
49
|
+
|
50
|
+
// 根据场景选择不同的按钮文案
|
51
|
+
const continueText =
|
52
|
+
scenario === 'image'
|
53
|
+
? t('geminiImageChineseWarning.continueGenerate')
|
54
|
+
: t('geminiImageChineseWarning.continueSend');
|
55
|
+
|
56
|
+
modal.confirm({
|
57
|
+
cancelText: t('cancel', { ns: 'common' }),
|
58
|
+
centered: true,
|
59
|
+
content: (
|
60
|
+
<div>
|
61
|
+
<p>{t('geminiImageChineseWarning.content')}</p>
|
62
|
+
<div style={{ marginTop: 16 }}>
|
63
|
+
<Checkbox
|
64
|
+
onChange={(e) => {
|
65
|
+
doNotShowAgain = e.target.checked;
|
66
|
+
}}
|
67
|
+
>
|
68
|
+
{t('geminiImageChineseWarning.doNotShowAgain')}
|
69
|
+
</Checkbox>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
),
|
73
|
+
okText: continueText,
|
74
|
+
onCancel: () => {
|
75
|
+
resolve(false);
|
76
|
+
},
|
77
|
+
onOk: () => {
|
78
|
+
if (doNotShowAgain) {
|
79
|
+
updateSystemStatus({ hideGemini2_5FlashImagePreviewChineseWarning: true });
|
80
|
+
}
|
81
|
+
resolve(true);
|
82
|
+
},
|
83
|
+
title: t('geminiImageChineseWarning.title'),
|
84
|
+
});
|
85
|
+
});
|
86
|
+
},
|
87
|
+
[modal, t, hideGeminiChineseWarning, updateSystemStatus],
|
88
|
+
);
|
89
|
+
|
90
|
+
return checkWarning;
|
91
|
+
};
|
@@ -185,6 +185,13 @@ export default {
|
|
185
185
|
title: '喜欢我们的产品?',
|
186
186
|
},
|
187
187
|
fullscreen: '全屏模式',
|
188
|
+
geminiImageChineseWarning: {
|
189
|
+
content: 'Nano Banana 使用中文有概率性生成图片失败。建议使用英文以获得更好的效果。',
|
190
|
+
continueGenerate: '继续生成',
|
191
|
+
continueSend: '继续发送',
|
192
|
+
doNotShowAgain: '不再提示',
|
193
|
+
title: '中文输入提示',
|
194
|
+
},
|
188
195
|
historyRange: '历史范围',
|
189
196
|
import: '导入',
|
190
197
|
importData: '导入数据',
|
@@ -50,6 +50,7 @@ export interface SystemStatus {
|
|
50
50
|
// which sessionGroup should expand
|
51
51
|
expandSessionGroupKeys: string[];
|
52
52
|
filePanelWidth: number;
|
53
|
+
hideGemini2_5FlashImagePreviewChineseWarning?: boolean;
|
53
54
|
hidePWAInstaller?: boolean;
|
54
55
|
hideThreadLimitAlert?: boolean;
|
55
56
|
imagePanelWidth: number;
|
@@ -108,6 +109,7 @@ export interface GlobalState {
|
|
108
109
|
export const INITIAL_STATUS = {
|
109
110
|
expandSessionGroupKeys: [SessionDefaultGroup.Pinned, SessionDefaultGroup.Default],
|
110
111
|
filePanelWidth: 320,
|
112
|
+
hideGemini2_5FlashImagePreviewChineseWarning: false,
|
111
113
|
hidePWAInstaller: false,
|
112
114
|
hideThreadLimitAlert: false,
|
113
115
|
imagePanelWidth: 320,
|