@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.
Files changed (86) hide show
  1. package/.cursor/rules/project-structure.mdc +54 -42
  2. package/.cursor/rules/testing-guide/testing-guide.mdc +28 -17
  3. package/.env.development +122 -0
  4. package/.vscode/settings.json +0 -1
  5. package/CHANGELOG.md +50 -0
  6. package/CLAUDE.md +3 -4
  7. package/changelog/v1.json +18 -0
  8. package/docker-compose/local/init_data.json +981 -1024
  9. package/docker-compose.development.yml +40 -0
  10. package/docs/development/basic/work-with-server-side-database.mdx +77 -0
  11. package/docs/development/basic/work-with-server-side-database.zh-CN.mdx +77 -0
  12. package/docs/self-hosting/advanced/s3/cloudflare-r2.mdx +1 -1
  13. package/docs/self-hosting/advanced/s3/cloudflare-r2.zh-CN.mdx +2 -2
  14. package/locales/ar/chat.json +2 -1
  15. package/locales/ar/models.json +0 -9
  16. package/locales/ar/providers.json +3 -0
  17. package/locales/bg-BG/chat.json +2 -1
  18. package/locales/bg-BG/models.json +0 -9
  19. package/locales/bg-BG/providers.json +3 -0
  20. package/locales/de-DE/chat.json +2 -1
  21. package/locales/de-DE/models.json +0 -9
  22. package/locales/de-DE/providers.json +3 -0
  23. package/locales/en-US/chat.json +2 -1
  24. package/locales/en-US/models.json +0 -9
  25. package/locales/en-US/providers.json +3 -0
  26. package/locales/es-ES/chat.json +2 -1
  27. package/locales/es-ES/models.json +0 -9
  28. package/locales/es-ES/providers.json +3 -0
  29. package/locales/fa-IR/chat.json +2 -1
  30. package/locales/fa-IR/models.json +0 -9
  31. package/locales/fa-IR/providers.json +3 -0
  32. package/locales/fr-FR/chat.json +2 -1
  33. package/locales/fr-FR/models.json +0 -9
  34. package/locales/fr-FR/providers.json +3 -0
  35. package/locales/it-IT/chat.json +2 -1
  36. package/locales/it-IT/models.json +0 -9
  37. package/locales/it-IT/providers.json +3 -0
  38. package/locales/ja-JP/chat.json +2 -1
  39. package/locales/ja-JP/models.json +0 -9
  40. package/locales/ja-JP/providers.json +3 -0
  41. package/locales/ko-KR/chat.json +2 -1
  42. package/locales/ko-KR/models.json +0 -9
  43. package/locales/ko-KR/providers.json +3 -0
  44. package/locales/nl-NL/chat.json +2 -1
  45. package/locales/nl-NL/models.json +0 -9
  46. package/locales/nl-NL/providers.json +3 -0
  47. package/locales/pl-PL/chat.json +2 -1
  48. package/locales/pl-PL/models.json +0 -9
  49. package/locales/pl-PL/providers.json +3 -0
  50. package/locales/pt-BR/chat.json +2 -1
  51. package/locales/pt-BR/models.json +0 -9
  52. package/locales/pt-BR/providers.json +3 -0
  53. package/locales/ru-RU/chat.json +2 -1
  54. package/locales/ru-RU/models.json +0 -9
  55. package/locales/ru-RU/providers.json +3 -0
  56. package/locales/tr-TR/chat.json +2 -1
  57. package/locales/tr-TR/models.json +0 -9
  58. package/locales/tr-TR/providers.json +3 -0
  59. package/locales/vi-VN/chat.json +2 -1
  60. package/locales/vi-VN/models.json +0 -9
  61. package/locales/vi-VN/providers.json +3 -0
  62. package/locales/zh-CN/chat.json +2 -1
  63. package/locales/zh-CN/common.json +7 -0
  64. package/locales/zh-CN/models.json +0 -9
  65. package/locales/zh-CN/providers.json +3 -0
  66. package/locales/zh-TW/chat.json +2 -1
  67. package/locales/zh-TW/models.json +0 -9
  68. package/locales/zh-TW/providers.json +3 -0
  69. package/package.json +2 -1
  70. package/packages/database/src/repositories/aiInfra/index.ts +3 -1
  71. package/packages/model-runtime/src/RouterRuntime/createRuntime.test.ts +6 -91
  72. package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +6 -28
  73. package/packages/model-runtime/src/openrouter/index.ts +15 -12
  74. package/packages/model-runtime/src/openrouter/type.ts +10 -0
  75. package/packages/model-runtime/src/utils/modelParse.test.ts +66 -0
  76. package/packages/model-runtime/src/utils/modelParse.ts +15 -3
  77. package/packages/model-runtime/src/utils/postProcessModelList.ts +1 -0
  78. package/packages/utils/src/detectChinese.test.ts +37 -0
  79. package/packages/utils/src/detectChinese.ts +12 -0
  80. package/packages/utils/src/index.ts +1 -0
  81. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.test.tsx +33 -18
  82. package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +12 -0
  83. package/src/features/ChatInput/useSend.ts +14 -2
  84. package/src/hooks/useGeminiChineseWarning.tsx +91 -0
  85. package/src/locales/default/common.ts +7 -0
  86. 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,