@lobehub/chat 0.161.21 → 0.161.23

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 (111) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/package.json +1 -1
  3. package/src/app/(main)/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +3 -3
  4. package/src/app/(main)/settings/common/features/Common.tsx +1 -1
  5. package/src/app/(main)/settings/common/features/Theme/ThemeSwatches/ThemeSwatchesNeutral.tsx +5 -5
  6. package/src/app/(main)/settings/common/features/Theme/ThemeSwatches/ThemeSwatchesPrimary.tsx +5 -5
  7. package/src/app/(main)/settings/common/features/Theme/index.tsx +5 -4
  8. package/src/app/(main)/settings/llm/Azure/index.tsx +4 -4
  9. package/src/app/(main)/settings/llm/Bedrock/index.tsx +5 -5
  10. package/src/app/(main)/settings/llm/Ollama/Checker.tsx +1 -1
  11. package/src/app/(main)/settings/llm/components/Checker.tsx +10 -6
  12. package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +6 -5
  13. package/src/app/(main)/settings/llm/components/ProviderModelList/CustomModelOption.tsx +1 -1
  14. package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +1 -1
  15. package/src/app/(main)/settings/llm/components/ProviderModelList/Option.tsx +1 -1
  16. package/src/app/(main)/settings/llm/components/ProviderModelList/index.tsx +1 -1
  17. package/src/app/(main)/settings/llm/const.ts +2 -1
  18. package/src/const/settings/agent.ts +2 -2
  19. package/src/const/settings/common.ts +2 -2
  20. package/src/const/settings/index.ts +4 -3
  21. package/src/const/settings/llm.ts +2 -21
  22. package/src/const/settings/sync.ts +2 -2
  23. package/src/const/settings/systemAgent.ts +2 -2
  24. package/src/const/settings/tts.ts +2 -2
  25. package/src/database/client/core/db.ts +19 -0
  26. package/src/database/client/core/migrations/migrateSettingsToUser/type.ts +1 -1
  27. package/src/database/client/core/schemas.ts +3 -2
  28. package/src/database/client/models/__tests__/user.test.ts +5 -5
  29. package/src/database/client/models/user.ts +2 -3
  30. package/src/database/client/schemas/user.ts +10 -4
  31. package/src/features/AgentSetting/AgentMeta/index.tsx +3 -3
  32. package/src/features/AgentSetting/AgentTTS/index.tsx +2 -2
  33. package/src/features/ChatInput/STT/browser.tsx +2 -2
  34. package/src/features/ChatInput/STT/openai.tsx +2 -2
  35. package/src/features/Conversation/Error/APIKeyForm/Bedrock.tsx +5 -5
  36. package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +5 -5
  37. package/src/features/Conversation/Error/APIKeyForm/index.tsx +1 -1
  38. package/src/features/Conversation/Error/AccessCodeForm.tsx +4 -4
  39. package/src/features/Conversation/Extras/TTS/index.tsx +2 -2
  40. package/src/features/Conversation/Plugins/Render/MarkdownType/index.tsx +2 -2
  41. package/src/features/Conversation/components/BubblesLoading.tsx +49 -41
  42. package/src/features/Conversation/components/ChatItem/index.tsx +2 -2
  43. package/src/features/PluginDevModal/LocalForm.tsx +2 -2
  44. package/src/features/PluginStore/index.tsx +6 -2
  45. package/src/features/User/UserPanel/LangButton.tsx +2 -2
  46. package/src/features/User/UserPanel/ThemeButton.tsx +2 -2
  47. package/src/hooks/_header.ts +6 -3
  48. package/src/hooks/useTTS.ts +2 -2
  49. package/src/layout/GlobalProvider/AppTheme.tsx +4 -4
  50. package/src/libs/agent-runtime/types/type.ts +3 -2
  51. package/src/migrations/FromV6ToV7/fixtures/output-v7-from-v1.json +203 -0
  52. package/src/migrations/FromV6ToV7/fixtures/provider-input-v6.json +103 -0
  53. package/src/migrations/FromV6ToV7/fixtures/provider-output-v7.json +118 -0
  54. package/src/migrations/FromV6ToV7/index.ts +101 -0
  55. package/src/migrations/FromV6ToV7/migrations.test.ts +64 -0
  56. package/src/migrations/FromV6ToV7/types/v6.ts +61 -0
  57. package/src/migrations/FromV6ToV7/types/v7.ts +71 -0
  58. package/src/migrations/index.ts +9 -3
  59. package/src/services/__tests__/chat.test.ts +19 -19
  60. package/src/services/__tests__/share.test.ts +4 -4
  61. package/src/services/_auth.test.ts +10 -5
  62. package/src/services/_auth.ts +11 -7
  63. package/src/services/_header.ts +6 -3
  64. package/src/services/config.ts +2 -2
  65. package/src/services/ollama.ts +3 -3
  66. package/src/services/share.ts +3 -3
  67. package/src/services/user/client.test.ts +3 -3
  68. package/src/services/user/client.ts +3 -3
  69. package/src/services/user/type.ts +2 -2
  70. package/src/store/agent/store.ts +4 -9
  71. package/src/store/chat/store.ts +4 -8
  72. package/src/store/file/store.ts +3 -9
  73. package/src/store/global/store.ts +5 -8
  74. package/src/store/market/store.ts +5 -8
  75. package/src/store/middleware/createDevtools.ts +23 -0
  76. package/src/store/serverConfig/store.ts +5 -11
  77. package/src/store/session/store.ts +3 -1
  78. package/src/store/tool/store.ts +4 -9
  79. package/src/store/user/helpers.ts +3 -2
  80. package/src/store/user/selectors.ts +10 -2
  81. package/src/store/user/slices/common/action.test.ts +3 -3
  82. package/src/store/user/slices/common/action.ts +4 -4
  83. package/src/store/user/slices/modelList/action.test.ts +2 -2
  84. package/src/store/user/slices/modelList/action.ts +16 -4
  85. package/src/store/user/slices/modelList/selectors/index.ts +1 -0
  86. package/src/store/user/slices/modelList/selectors/keyVaults.ts +25 -0
  87. package/src/store/user/slices/modelList/selectors/modelConfig.test.ts +1 -1
  88. package/src/store/user/slices/modelList/selectors/modelConfig.ts +1 -6
  89. package/src/store/user/slices/modelList/selectors/modelProvider.ts +1 -1
  90. package/src/store/user/slices/settings/action.test.ts +16 -14
  91. package/src/store/user/slices/settings/action.ts +14 -8
  92. package/src/store/user/slices/settings/initialState.ts +3 -3
  93. package/src/store/user/slices/settings/selectors/general.test.ts +45 -0
  94. package/src/store/user/slices/settings/selectors/general.ts +40 -0
  95. package/src/store/user/slices/settings/selectors/index.ts +1 -0
  96. package/src/store/user/slices/settings/selectors/settings.test.ts +0 -39
  97. package/src/store/user/slices/settings/selectors/settings.ts +11 -34
  98. package/src/store/user/store.ts +5 -8
  99. package/src/types/exportConfig.ts +2 -2
  100. package/src/types/serverConfig.ts +2 -2
  101. package/src/types/user/index.ts +2 -2
  102. package/src/types/{settings/base.ts → user/settings/general.ts} +4 -1
  103. package/src/types/user/settings/index.ts +32 -0
  104. package/src/types/user/settings/keyVaults.ts +36 -0
  105. package/src/types/user/settings/modelProvider.ts +34 -0
  106. package/src/types/{settings → user/settings}/sync.ts +1 -1
  107. package/src/types/{settings → user/settings}/systemAgent.ts +1 -1
  108. package/src/types/user/settings/tool.ts +5 -0
  109. package/src/types/{settings → user/settings}/tts.ts +1 -1
  110. package/src/types/settings/index.ts +0 -33
  111. package/src/types/settings/modelProvider.ts +0 -62
package/CHANGELOG.md CHANGED
@@ -2,6 +2,64 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.161.23](https://github.com/lobehub/lobe-chat/compare/v0.161.22...v0.161.23)
6
+
7
+ <sup>Released on **2024-05-27**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor `keyVaults` and rename `endpoint` to `baseURL`.
12
+
13
+ #### 💄 Styles
14
+
15
+ - **misc**: Fix PluginStore layout.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### Code refactoring
23
+
24
+ - **misc**: Refactor `keyVaults` and rename `endpoint` to `baseURL`, closes [#2673](https://github.com/lobehub/lobe-chat/issues/2673) ([4049bc7](https://github.com/lobehub/lobe-chat/commit/4049bc7))
25
+
26
+ #### Styles
27
+
28
+ - **misc**: Fix PluginStore layout, closes [#2590](https://github.com/lobehub/lobe-chat/issues/2590) [#2511](https://github.com/lobehub/lobe-chat/issues/2511) ([e1ae39b](https://github.com/lobehub/lobe-chat/commit/e1ae39b))
29
+
30
+ </details>
31
+
32
+ <div align="right">
33
+
34
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
35
+
36
+ </div>
37
+
38
+ ### [Version 0.161.22](https://github.com/lobehub/lobe-chat/compare/v0.161.21...v0.161.22)
39
+
40
+ <sup>Released on **2024-05-26**</sup>
41
+
42
+ #### 🐛 Bug Fixes
43
+
44
+ - **misc**: Fix connection checker.
45
+
46
+ <br/>
47
+
48
+ <details>
49
+ <summary><kbd>Improvements and Fixes</kbd></summary>
50
+
51
+ #### What's fixed
52
+
53
+ - **misc**: Fix connection checker, closes [#2672](https://github.com/lobehub/lobe-chat/issues/2672) ([bef8926](https://github.com/lobehub/lobe-chat/commit/bef8926))
54
+
55
+ </details>
56
+
57
+ <div align="right">
58
+
59
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
60
+
61
+ </div>
62
+
5
63
  ### [Version 0.161.21](https://github.com/lobehub/lobe-chat/compare/v0.161.20...v0.161.21)
6
64
 
7
65
  <sup>Released on **2024-05-26**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.161.21",
3
+ "version": "0.161.23",
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",
@@ -17,7 +17,7 @@ import { agentSelectors } from '@/store/agent/selectors';
17
17
  import { useSessionStore } from '@/store/session';
18
18
  import { sessionMetaSelectors } from '@/store/session/selectors';
19
19
  import { useUserStore } from '@/store/user';
20
- import { settingsSelectors } from '@/store/user/selectors';
20
+ import { userGeneralSettingsSelectors } from '@/store/user/selectors';
21
21
 
22
22
  const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
23
23
  const { t } = useTranslation('setting');
@@ -25,7 +25,7 @@ const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
25
25
  const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
26
26
  const theme = useTheme();
27
27
  const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
28
- const language = useUserStore((s) => settingsSelectors.currentSettings(s).language);
28
+ const language = useUserStore((s) => userGeneralSettingsSelectors.currentLanguage(s));
29
29
 
30
30
  const isMetaPass = Boolean(
31
31
  meta && meta.title && meta.description && (meta.tags as string[])?.length > 0 && meta.avatar,
@@ -46,7 +46,7 @@ const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
46
46
  '### tags',
47
47
  (meta.tags as string[]).join(', '),
48
48
  '### locale',
49
- language === 'auto' ? navigator.language : language,
49
+ language,
50
50
  ].join('\n\n');
51
51
 
52
52
  const url = qs.stringifyUrl({
@@ -110,7 +110,7 @@ const Common = memo(() => {
110
110
  desc: t('settingSystem.accessCode.desc'),
111
111
  hidden: !showAccessCodeConfig,
112
112
  label: t('settingSystem.accessCode.title'),
113
- name: 'password',
113
+ name: ['keyVaults', 'password'],
114
114
  },
115
115
  {
116
116
  children: isSignedIn ? (
@@ -8,17 +8,17 @@ import {
8
8
  import { memo } from 'react';
9
9
 
10
10
  import { useUserStore } from '@/store/user';
11
- import { settingsSelectors } from '@/store/user/selectors';
11
+ import { userGeneralSettingsSelectors } from '@/store/user/selectors';
12
12
 
13
13
  const ThemeSwatchesNeutral = memo(() => {
14
- const [neutralColor, setSettings] = useUserStore((s) => [
15
- settingsSelectors.currentSettings(s).neutralColor,
16
- s.setSettings,
14
+ const [neutralColor, updateGeneralConfig] = useUserStore((s) => [
15
+ userGeneralSettingsSelectors.neutralColor(s),
16
+ s.updateGeneralConfig,
17
17
  ]);
18
18
 
19
19
  const handleSelect = (v: any) => {
20
20
  const name = findCustomThemeName('neutral', v) as NeutralColors;
21
- setSettings({ neutralColor: name || '' });
21
+ updateGeneralConfig({ neutralColor: name || '' });
22
22
  };
23
23
 
24
24
  return (
@@ -8,17 +8,17 @@ import {
8
8
  import { memo } from 'react';
9
9
 
10
10
  import { useUserStore } from '@/store/user';
11
- import { settingsSelectors } from '@/store/user/selectors';
11
+ import { userGeneralSettingsSelectors } from '@/store/user/selectors';
12
12
 
13
13
  const ThemeSwatchesPrimary = memo(() => {
14
- const [primaryColor, setSettings] = useUserStore((s) => [
15
- settingsSelectors.currentSettings(s).primaryColor,
16
- s.setSettings,
14
+ const [primaryColor, updateGeneralConfig] = useUserStore((s) => [
15
+ userGeneralSettingsSelectors.primaryColor(s),
16
+ s.updateGeneralConfig,
17
17
  ]);
18
18
 
19
19
  const handleSelect = (v: any) => {
20
20
  const name = findCustomThemeName('primary', v) as PrimaryColors;
21
- setSettings({ primaryColor: name || '' });
21
+ updateGeneralConfig({ primaryColor: name || '' });
22
22
  };
23
23
 
24
24
  return (
@@ -14,7 +14,7 @@ import { imageUrl } from '@/const/url';
14
14
  import AvatarWithUpload from '@/features/AvatarWithUpload';
15
15
  import { localeOptions } from '@/locales/resources';
16
16
  import { useUserStore } from '@/store/user';
17
- import { settingsSelectors } from '@/store/user/selectors';
17
+ import { settingsSelectors, userGeneralSettingsSelectors } from '@/store/user/selectors';
18
18
  import { switchLang } from '@/utils/client/switchLang';
19
19
 
20
20
  import { ThemeSwatchesNeutral, ThemeSwatchesPrimary } from './ThemeSwatches';
@@ -25,6 +25,7 @@ const Theme = memo(() => {
25
25
  const { t } = useTranslation('setting');
26
26
  const [form] = Form.useForm();
27
27
  const settings = useUserStore(settingsSelectors.currentSettings, isEqual);
28
+ const themeMode = useUserStore(userGeneralSettingsSelectors.currentThemeMode);
28
29
  const [setThemeMode, setSettings] = useUserStore((s) => [s.switchThemeMode, s.setSettings]);
29
30
 
30
31
  useSyncSettings(form);
@@ -40,7 +41,7 @@ const Theme = memo(() => {
40
41
  {
41
42
  children: (
42
43
  <SelectWithImg
43
- defaultValue={settings.themeMode}
44
+ defaultValue={themeMode}
44
45
  height={60}
45
46
  onChange={setThemeMode}
46
47
  options={[
@@ -78,7 +79,7 @@ const Theme = memo(() => {
78
79
  />
79
80
  ),
80
81
  label: t('settingTheme.lang.title'),
81
- name: 'language',
82
+ name: ['general', 'language'],
82
83
  },
83
84
  {
84
85
  children: (
@@ -113,7 +114,7 @@ const Theme = memo(() => {
113
114
  ),
114
115
  desc: t('settingTheme.fontSize.desc'),
115
116
  label: t('settingTheme.fontSize.title'),
116
- name: 'fontSize',
117
+ name: ['general', 'fontSize'],
117
118
  },
118
119
  {
119
120
  children: <ThemeSwatchesPrimary />,
@@ -13,7 +13,7 @@ import { useUserStore } from '@/store/user';
13
13
  import { modelProviderSelectors } from '@/store/user/selectors';
14
14
 
15
15
  import ProviderConfig from '../components/ProviderConfig';
16
- import { LLMProviderApiTokenKey, LLMProviderBaseUrlKey, LLMProviderConfigKey } from '../const';
16
+ import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../const';
17
17
 
18
18
  const useStyles = createStyles(({ css, token }) => ({
19
19
  markdown: css`
@@ -57,13 +57,13 @@ const AzureOpenAIProvider = memo(() => {
57
57
  ),
58
58
  desc: t('azure.token.desc'),
59
59
  label: t('azure.token.title'),
60
- name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
60
+ name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
61
61
  },
62
62
  {
63
63
  children: <Input allowClear placeholder={t('azure.endpoint.placeholder')} />,
64
64
  desc: t('azure.endpoint.desc'),
65
65
  label: t('azure.endpoint.title'),
66
- name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
66
+ name: [KeyVaultsConfigKey, providerKey, 'endpoint'],
67
67
  },
68
68
  {
69
69
  children: (
@@ -85,7 +85,7 @@ const AzureOpenAIProvider = memo(() => {
85
85
  </Markdown>
86
86
  ),
87
87
  label: t('azure.azureApiVersion.title'),
88
- name: [LLMProviderConfigKey, providerKey, 'apiVersion'],
88
+ name: [KeyVaultsConfigKey, providerKey, 'apiVersion'],
89
89
  },
90
90
  ]}
91
91
  checkModel={checkModel}
@@ -7,10 +7,10 @@ import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
9
9
  import { ModelProvider } from '@/libs/agent-runtime';
10
- import { GlobalLLMProviderKey } from '@/types/settings';
10
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
11
11
 
12
12
  import ProviderConfig from '../components/ProviderConfig';
13
- import { LLMProviderConfigKey } from '../const';
13
+ import { KeyVaultsConfigKey } from '../const';
14
14
 
15
15
  const providerKey: GlobalLLMProviderKey = 'bedrock';
16
16
 
@@ -29,7 +29,7 @@ const BedrockProvider = memo(() => {
29
29
  ),
30
30
  desc: t(`${providerKey}.accessKeyId.desc`),
31
31
  label: t(`${providerKey}.accessKeyId.title`),
32
- name: [LLMProviderConfigKey, providerKey, 'accessKeyId'],
32
+ name: [KeyVaultsConfigKey, providerKey, 'accessKeyId'],
33
33
  },
34
34
  {
35
35
  children: (
@@ -40,7 +40,7 @@ const BedrockProvider = memo(() => {
40
40
  ),
41
41
  desc: t(`${providerKey}.secretAccessKey.desc`),
42
42
  label: t(`${providerKey}.secretAccessKey.title`),
43
- name: [LLMProviderConfigKey, providerKey, 'secretAccessKey'],
43
+ name: [KeyVaultsConfigKey, providerKey, 'secretAccessKey'],
44
44
  },
45
45
  {
46
46
  children: (
@@ -55,7 +55,7 @@ const BedrockProvider = memo(() => {
55
55
  ),
56
56
  desc: t(`${providerKey}.region.desc`),
57
57
  label: t(`${providerKey}.region.title`),
58
- name: [LLMProviderConfigKey, providerKey, 'region'],
58
+ name: [KeyVaultsConfigKey, providerKey, 'region'],
59
59
  },
60
60
  ]}
61
61
  checkModel={'anthropic.claude-instant-v1'}
@@ -27,7 +27,7 @@ const OllamaChecker = memo(() => {
27
27
  );
28
28
 
29
29
  const checkConnection = () => {
30
- mutate();
30
+ mutate().catch();
31
31
  };
32
32
 
33
33
  const isMobile = useIsMobile();
@@ -50,10 +50,19 @@ const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
50
50
  const [error, setError] = useState<ChatMessageError | undefined>();
51
51
 
52
52
  const checkConnection = async () => {
53
- const data = await chatService.fetchPresetTaskResult({
53
+ let isError = false;
54
+
55
+ await chatService.fetchPresetTaskResult({
54
56
  onError: (_, rawError) => {
55
57
  setError(rawError);
56
58
  setPass(false);
59
+ isError = true;
60
+ },
61
+ onFinish: async () => {
62
+ if (!isError) {
63
+ setError(undefined);
64
+ setPass(true);
65
+ }
57
66
  },
58
67
  onLoadingChange: (loading) => {
59
68
  setLoading(loading);
@@ -74,11 +83,6 @@ const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
74
83
  traceName: TraceNameMap.ConnectivityChecker,
75
84
  },
76
85
  });
77
-
78
- if (data) {
79
- setError(undefined);
80
- setPass(true);
81
- }
82
86
  };
83
87
  const isMobile = useIsMobile();
84
88
 
@@ -10,6 +10,7 @@ import { Flexbox } from 'react-layout-kit';
10
10
 
11
11
  import { useSyncSettings } from '@/app/(main)/settings/hooks/useSyncSettings';
12
12
  import {
13
+ KeyVaultsConfigKey,
13
14
  LLMProviderApiTokenKey,
14
15
  LLMProviderBaseUrlKey,
15
16
  LLMProviderConfigKey,
@@ -17,8 +18,8 @@ import {
17
18
  } from '@/app/(main)/settings/llm/const';
18
19
  import { FORM_STYLE } from '@/const/layoutTokens';
19
20
  import { useUserStore } from '@/store/user';
20
- import { modelConfigSelectors } from '@/store/user/selectors';
21
- import { GlobalLLMProviderKey } from '@/types/settings';
21
+ import { keyVaultsConfigSelectors, modelConfigSelectors } from '@/store/user/selectors';
22
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
22
23
 
23
24
  import Checker from '../Checker';
24
25
  import ProviderModelListSelect from '../ProviderModelList';
@@ -100,7 +101,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
100
101
  s.setSettings,
101
102
  modelConfigSelectors.isProviderEnabled(provider)(s),
102
103
  modelConfigSelectors.isProviderFetchOnClient(provider)(s),
103
- modelConfigSelectors.isProviderEndpointNotEmpty(provider)(s),
104
+ keyVaultsConfigSelectors.isProviderEndpointNotEmpty(provider)(s),
104
105
  ]);
105
106
 
106
107
  useSyncSettings(form);
@@ -117,7 +118,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
117
118
  ),
118
119
  desc: modelT(`${provider}.token.desc` as any),
119
120
  label: modelT(`${provider}.token.title` as any),
120
- name: [LLMProviderConfigKey, provider, LLMProviderApiTokenKey],
121
+ name: [KeyVaultsConfigKey, provider, LLMProviderApiTokenKey],
121
122
  },
122
123
  ];
123
124
 
@@ -128,7 +129,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
128
129
  children: <Input allowClear placeholder={proxyUrl?.placeholder} />,
129
130
  desc: proxyUrl?.desc || t('llm.proxyUrl.desc'),
130
131
  label: proxyUrl?.title || t('llm.proxyUrl.title'),
131
- name: [LLMProviderConfigKey, provider, LLMProviderBaseUrlKey],
132
+ name: [KeyVaultsConfigKey, provider, LLMProviderBaseUrlKey],
132
133
  },
133
134
  (showBrowserRequest || (showEndpoint && isProviderEndpointNotEmpty)) && {
134
135
  children: (
@@ -10,7 +10,7 @@ import ModelIcon from '@/components/ModelIcon';
10
10
  import { ModelInfoTags } from '@/components/ModelSelect';
11
11
  import { useUserStore } from '@/store/user';
12
12
  import { modelConfigSelectors } from '@/store/user/selectors';
13
- import { GlobalLLMProviderKey } from '@/types/settings';
13
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
14
14
 
15
15
  interface CustomModelOptionProps {
16
16
  id: string;
@@ -13,7 +13,7 @@ import {
13
13
  modelProviderSelectors,
14
14
  settingsSelectors,
15
15
  } from '@/store/user/selectors';
16
- import { GlobalLLMProviderKey } from '@/types/settings';
16
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
17
17
 
18
18
  const useStyles = createStyles(({ css, token }) => ({
19
19
  hover: css`
@@ -11,7 +11,7 @@ import ModelIcon from '@/components/ModelIcon';
11
11
  import { ModelInfoTags } from '@/components/ModelSelect';
12
12
  import { useUserStore } from '@/store/user';
13
13
  import { modelProviderSelectors } from '@/store/user/selectors';
14
- import { GlobalLLMProviderKey } from '@/types/settings';
14
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
15
15
 
16
16
  import CustomModelOption from './CustomModelOption';
17
17
 
@@ -9,7 +9,7 @@ import { Flexbox } from 'react-layout-kit';
9
9
 
10
10
  import { useUserStore } from '@/store/user';
11
11
  import { modelProviderSelectors } from '@/store/user/selectors';
12
- import { GlobalLLMProviderKey } from '@/types/settings';
12
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
13
13
 
14
14
  import ModelConfigModal from './ModelConfigModal';
15
15
  import ModelFetcher from './ModelFetcher';
@@ -1,4 +1,5 @@
1
1
  export const LLMProviderConfigKey = 'languageModel';
2
+ export const KeyVaultsConfigKey = 'keyVaults';
2
3
 
3
4
  /**
4
5
  * we use this key to define default api key
@@ -10,7 +11,7 @@ export const LLMProviderApiTokenKey = 'apiKey';
10
11
  * we use this key to define the baseURL
11
12
  * equal OPENAI_PROXY_URL
12
13
  */
13
- export const LLMProviderBaseUrlKey = 'endpoint';
14
+ export const LLMProviderBaseUrlKey = 'baseURL';
14
15
 
15
16
  /**
16
17
  * we use this key to define the custom model name
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_AGENT_META } from '@/const/meta';
2
2
  import { ModelProvider } from '@/libs/agent-runtime';
3
3
  import { LobeAgentChatConfig, LobeAgentConfig, LobeAgentTTSConfig } from '@/types/agent';
4
- import { GlobalDefaultAgent } from '@/types/settings';
4
+ import { UserDefaultAgent } from '@/types/user/settings';
5
5
 
6
6
  export const DEFAUTT_AGENT_TTS_CONFIG: LobeAgentTTSConfig = {
7
7
  showAllLocaleVoice: false,
@@ -34,7 +34,7 @@ export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
34
34
  tts: DEFAUTT_AGENT_TTS_CONFIG,
35
35
  };
36
36
 
37
- export const DEFAULT_AGENT: GlobalDefaultAgent = {
37
+ export const DEFAULT_AGENT: UserDefaultAgent = {
38
38
  config: DEFAULT_AGENT_CONFIG,
39
39
  meta: DEFAULT_AGENT_META,
40
40
  };
@@ -1,6 +1,6 @@
1
- import { GlobalBaseSettings } from '@/types/settings';
1
+ import { UserGeneralConfig } from '@/types/user/settings';
2
2
 
3
- export const DEFAULT_COMMON_SETTINGS: GlobalBaseSettings = {
3
+ export const DEFAULT_COMMON_SETTINGS: UserGeneralConfig = {
4
4
  fontSize: 14,
5
5
  language: 'auto',
6
6
  password: '',
@@ -1,4 +1,4 @@
1
- import { GlobalSettings } from '@/types/settings';
1
+ import { UserSettings } from '@/types/user/settings';
2
2
 
3
3
  import { DEFAULT_AGENT } from './agent';
4
4
  import { DEFAULT_COMMON_SETTINGS } from './common';
@@ -16,12 +16,13 @@ export * from './systemAgent';
16
16
  export * from './tool';
17
17
  export * from './tts';
18
18
 
19
- export const DEFAULT_SETTINGS: GlobalSettings = {
19
+ export const DEFAULT_SETTINGS: UserSettings = {
20
20
  defaultAgent: DEFAULT_AGENT,
21
+ general: DEFAULT_COMMON_SETTINGS,
22
+ keyVaults: {},
21
23
  languageModel: DEFAULT_LLM_CONFIG,
22
24
  sync: DEFAULT_SYNC_CONFIG,
23
25
  systemAgent: DEFAULT_SYSTEM_AGENT_CONFIG,
24
26
  tool: DEFAULT_TOOL_CONFIG,
25
27
  tts: DEFAULT_TTS_CONFIG,
26
- ...DEFAULT_COMMON_SETTINGS,
27
28
  };
@@ -17,89 +17,70 @@ import {
17
17
  filterEnabledModels,
18
18
  } from '@/config/modelProviders';
19
19
  import { ModelProvider } from '@/libs/agent-runtime';
20
- import { GlobalLLMConfig } from '@/types/settings';
20
+ import { UserModelProviderConfig } from '@/types/user/settings';
21
21
 
22
- export const DEFAULT_LLM_CONFIG: GlobalLLMConfig = {
22
+ export const DEFAULT_LLM_CONFIG: UserModelProviderConfig = {
23
23
  anthropic: {
24
- apiKey: '',
25
24
  enabled: false,
26
25
  enabledModels: filterEnabledModels(AnthropicProviderCard),
27
26
  },
28
27
  azure: {
29
- apiKey: '',
30
28
  enabled: false,
31
- endpoint: '',
32
29
  },
33
30
  bedrock: {
34
- accessKeyId: '',
35
31
  enabled: false,
36
32
  enabledModels: filterEnabledModels(BedrockProviderCard),
37
- region: 'us-east-1',
38
- secretAccessKey: '',
39
33
  },
40
34
  deepseek: {
41
- apiKey: '',
42
35
  enabled: false,
43
36
  enabledModels: filterEnabledModels(DeepSeekProviderCard),
44
37
  },
45
38
  google: {
46
- apiKey: '',
47
39
  enabled: false,
48
40
  enabledModels: filterEnabledModels(GoogleProviderCard),
49
41
  },
50
42
  groq: {
51
- apiKey: '',
52
43
  enabled: false,
53
44
  enabledModels: filterEnabledModels(GroqProviderCard),
54
45
  },
55
46
  minimax: {
56
- apiKey: '',
57
47
  enabled: false,
58
48
  enabledModels: filterEnabledModels(MinimaxProviderCard),
59
49
  },
60
50
  mistral: {
61
- apiKey: '',
62
51
  enabled: false,
63
52
  enabledModels: filterEnabledModels(MistralProviderCard),
64
53
  },
65
54
  moonshot: {
66
- apiKey: '',
67
55
  enabled: false,
68
56
  enabledModels: filterEnabledModels(MoonshotProviderCard),
69
57
  },
70
58
  ollama: {
71
59
  enabled: true,
72
60
  enabledModels: filterEnabledModels(OllamaProviderCard),
73
- endpoint: '',
74
61
  fetchOnClient: true,
75
62
  },
76
63
  openai: {
77
- apiKey: '',
78
64
  enabled: true,
79
65
  enabledModels: filterEnabledModels(OpenAIProviderCard),
80
66
  },
81
67
  openrouter: {
82
- apiKey: '',
83
68
  enabled: false,
84
69
  enabledModels: filterEnabledModels(OpenRouterProviderCard),
85
70
  },
86
71
  perplexity: {
87
- apiKey: '',
88
72
  enabled: false,
89
73
  enabledModels: filterEnabledModels(PerplexityProviderCard),
90
74
  },
91
75
  togetherai: {
92
- apiKey: '',
93
76
  enabled: false,
94
77
  enabledModels: filterEnabledModels(TogetherAIProviderCard),
95
78
  },
96
79
  zeroone: {
97
- apiKey: '',
98
80
  enabled: false,
99
81
  enabledModels: filterEnabledModels(ZeroOneProviderCard),
100
82
  },
101
83
  zhipu: {
102
- apiKey: '',
103
84
  enabled: false,
104
85
  enabledModels: filterEnabledModels(ZhiPuProviderCard),
105
86
  },
@@ -1,5 +1,5 @@
1
- import { GlobalSyncSettings } from '@/types/settings';
1
+ import { UserSyncSettings } from '@/types/user/settings';
2
2
 
3
- export const DEFAULT_SYNC_CONFIG: GlobalSyncSettings = {
3
+ export const DEFAULT_SYNC_CONFIG: UserSyncSettings = {
4
4
  webrtc: { enabled: false },
5
5
  };
@@ -1,4 +1,4 @@
1
- import { GlobalSystemAgentConfig, GlobalTranslationConfig } from '@/types/settings';
1
+ import { UserSystemAgentConfig, GlobalTranslationConfig } from '@/types/user/settings';
2
2
 
3
3
  import { DEFAULT_MODEL, DEFAULT_PROVIDER } from './llm';
4
4
 
@@ -7,6 +7,6 @@ export const DEFAULT_TRANSLATION_CONFIG: GlobalTranslationConfig = {
7
7
  provider: DEFAULT_PROVIDER,
8
8
  };
9
9
 
10
- export const DEFAULT_SYSTEM_AGENT_CONFIG: GlobalSystemAgentConfig = {
10
+ export const DEFAULT_SYSTEM_AGENT_CONFIG: UserSystemAgentConfig = {
11
11
  translation: DEFAULT_TRANSLATION_CONFIG,
12
12
  };
@@ -1,6 +1,6 @@
1
- import { GlobalTTSConfig } from '@/types/settings';
1
+ import { UserTTSConfig } from '@/types/user/settings';
2
2
 
3
- export const DEFAULT_TTS_CONFIG: GlobalTTSConfig = {
3
+ export const DEFAULT_TTS_CONFIG: UserTTSConfig = {
4
4
  openAI: {
5
5
  sttModel: 'whisper-1',
6
6
  ttsModel: 'tts-1',
@@ -2,6 +2,7 @@ import Dexie, { Transaction } from 'dexie';
2
2
 
3
3
  import { MigrationLLMSettings } from '@/migrations/FromV3ToV4';
4
4
  import { MigrationAgentChatConfig } from '@/migrations/FromV5ToV6';
5
+ import { MigrationKeyValueSettings } from '@/migrations/FromV6ToV7';
5
6
  import { uuid } from '@/utils/uuid';
6
7
 
7
8
  import { DB_File } from '../schemas/files';
@@ -77,6 +78,10 @@ export class BrowserDB extends Dexie {
77
78
  .stores(dbSchemaV9)
78
79
  .upgrade((trans) => this.upgradeToV10(trans));
79
80
 
81
+ this.version(11)
82
+ .stores(dbSchemaV9)
83
+ .upgrade((trans) => this.upgradeToV11(trans));
84
+
80
85
  this.files = this.table('files');
81
86
  this.sessions = this.table('sessions');
82
87
  this.messages = this.table('messages');
@@ -207,6 +212,20 @@ export class BrowserDB extends Dexie {
207
212
  session.config = MigrationAgentChatConfig.migrateChatConfig(session.config as any);
208
213
  });
209
214
  };
215
+
216
+ /**
217
+ * 2024.05.27
218
+ * migrate apiKey in languageModel to keyVaults
219
+ */
220
+ upgradeToV11 = async (trans: Transaction) => {
221
+ const users = trans.table('users');
222
+
223
+ await users.toCollection().modify((user: DB_User) => {
224
+ if (user.settings) {
225
+ user.settings = MigrationKeyValueSettings.migrateSettings(user.settings as any);
226
+ }
227
+ });
228
+ };
210
229
  }
211
230
 
212
231
  export const browserDB = new BrowserDB();
@@ -3,7 +3,7 @@ import type { ThemeMode } from 'antd-style';
3
3
  import { LobeAgentTTSConfig } from '@/types/agent';
4
4
  import { FewShots, LLMParams } from '@/types/llm';
5
5
  import { MetaData } from '@/types/meta';
6
- import { STTServer } from '@/types/settings';
6
+ import { STTServer } from '@/types/user/settings';
7
7
 
8
8
  interface V4LobeAgentConfig {
9
9
  autoCreateTopicThreshold: number;