@lobehub/chat 0.161.21 → 0.161.22

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 (60) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.json +1 -1
  3. package/src/app/(main)/settings/llm/Bedrock/index.tsx +1 -1
  4. package/src/app/(main)/settings/llm/components/Checker.tsx +10 -6
  5. package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +1 -1
  6. package/src/app/(main)/settings/llm/components/ProviderModelList/CustomModelOption.tsx +1 -1
  7. package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +1 -1
  8. package/src/app/(main)/settings/llm/components/ProviderModelList/Option.tsx +1 -1
  9. package/src/app/(main)/settings/llm/components/ProviderModelList/index.tsx +1 -1
  10. package/src/const/settings/agent.ts +2 -2
  11. package/src/const/settings/common.ts +2 -2
  12. package/src/const/settings/index.ts +2 -2
  13. package/src/const/settings/llm.ts +2 -2
  14. package/src/const/settings/sync.ts +2 -2
  15. package/src/const/settings/systemAgent.ts +2 -2
  16. package/src/const/settings/tts.ts +2 -2
  17. package/src/database/client/core/migrations/migrateSettingsToUser/type.ts +1 -1
  18. package/src/database/client/models/__tests__/user.test.ts +1 -1
  19. package/src/database/client/models/user.ts +2 -2
  20. package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +1 -1
  21. package/src/features/Conversation/Error/APIKeyForm/index.tsx +1 -1
  22. package/src/features/Conversation/components/BubblesLoading.tsx +49 -41
  23. package/src/services/__tests__/share.test.ts +2 -2
  24. package/src/services/_auth.test.ts +2 -2
  25. package/src/services/config.ts +2 -2
  26. package/src/services/share.ts +3 -3
  27. package/src/services/user/client.test.ts +3 -3
  28. package/src/services/user/client.ts +3 -3
  29. package/src/services/user/type.ts +2 -2
  30. package/src/store/agent/store.ts +4 -9
  31. package/src/store/chat/store.ts +4 -8
  32. package/src/store/file/store.ts +3 -9
  33. package/src/store/global/store.ts +5 -8
  34. package/src/store/market/store.ts +5 -8
  35. package/src/store/middleware/createDevtools.ts +23 -0
  36. package/src/store/serverConfig/store.ts +5 -11
  37. package/src/store/session/store.ts +3 -1
  38. package/src/store/tool/store.ts +4 -9
  39. package/src/store/user/slices/common/action.ts +2 -2
  40. package/src/store/user/slices/modelList/action.test.ts +2 -2
  41. package/src/store/user/slices/modelList/action.ts +2 -2
  42. package/src/store/user/slices/modelList/selectors/modelConfig.ts +1 -1
  43. package/src/store/user/slices/modelList/selectors/modelProvider.ts +1 -1
  44. package/src/store/user/slices/settings/action.test.ts +4 -4
  45. package/src/store/user/slices/settings/action.ts +3 -3
  46. package/src/store/user/slices/settings/initialState.ts +3 -3
  47. package/src/store/user/slices/settings/selectors/settings.ts +8 -5
  48. package/src/store/user/store.ts +5 -8
  49. package/src/types/exportConfig.ts +2 -2
  50. package/src/types/serverConfig.ts +2 -2
  51. package/src/types/user/index.ts +2 -2
  52. package/src/types/{settings/base.ts → user/settings/general.ts} +4 -1
  53. package/src/types/user/settings/index.ts +54 -0
  54. package/src/types/user/settings/modelProvider.ts +70 -0
  55. package/src/types/{settings → user/settings}/sync.ts +1 -1
  56. package/src/types/{settings → user/settings}/systemAgent.ts +1 -1
  57. package/src/types/user/settings/tool.ts +5 -0
  58. package/src/types/{settings → user/settings}/tts.ts +1 -1
  59. package/src/types/settings/index.ts +0 -33
  60. package/src/types/settings/modelProvider.ts +0 -62
@@ -1,10 +1,9 @@
1
- import { devtools, subscribeWithSelector } from 'zustand/middleware';
1
+ import { subscribeWithSelector } from 'zustand/middleware';
2
2
  import { shallow } from 'zustand/shallow';
3
3
  import { createWithEqualityFn } from 'zustand/traditional';
4
4
  import { StateCreator } from 'zustand/vanilla';
5
5
 
6
- import { isDev } from '@/utils/env';
7
-
6
+ import { createDevtools } from '../middleware/createDevtools';
8
7
  import { type GlobalStoreAction, globalActionSlice } from './action';
9
8
  import { type GlobalState, initialState } from './initialState';
10
9
 
@@ -19,11 +18,9 @@ const createStore: StateCreator<GlobalStore, [['zustand/devtools', never]]> = (.
19
18
 
20
19
  // =============== 实装 useStore ============ //
21
20
 
21
+ const devtools = createDevtools('global');
22
+
22
23
  export const useGlobalStore = createWithEqualityFn<GlobalStore>()(
23
- subscribeWithSelector(
24
- devtools(createStore, {
25
- name: 'LobeChat_Global' + (isDev ? '_DEV' : ''),
26
- }),
27
- ),
24
+ subscribeWithSelector(devtools(createStore)),
28
25
  shallow,
29
26
  );
@@ -1,11 +1,11 @@
1
- import { PersistOptions, devtools, persist } from 'zustand/middleware';
1
+ import { PersistOptions, persist } from 'zustand/middleware';
2
2
  import { shallow } from 'zustand/shallow';
3
3
  import { createWithEqualityFn } from 'zustand/traditional';
4
4
  import type { StateCreator } from 'zustand/vanilla';
5
5
 
6
6
  import { createHyperStorage } from '@/store/middleware/createHyperStorage';
7
- import { isDev } from '@/utils/env';
8
7
 
8
+ import { createDevtools } from '../middleware/createDevtools';
9
9
  import { type StoreAction, createMarketAction } from './action';
10
10
  import { type StoreState, initialState } from './initialState';
11
11
 
@@ -40,12 +40,9 @@ const createStore: StateCreator<Store, [['zustand/devtools', never]]> = (...para
40
40
  ...createMarketAction(...parameters),
41
41
  });
42
42
 
43
+ const devtools = createDevtools('market');
44
+
43
45
  export const useMarketStore = createWithEqualityFn<Store>()(
44
- persist(
45
- devtools(createStore, {
46
- name: LOBE_AGENT_MARKET + (isDev ? '_DEV' : ''),
47
- }),
48
- persistOptions,
49
- ),
46
+ persist(devtools(createStore), persistOptions),
50
47
  shallow,
51
48
  );
@@ -0,0 +1,23 @@
1
+ import { optionalDevtools } from 'zustand-utils';
2
+ import { devtools as _devtools } from 'zustand/middleware';
3
+
4
+ import { isDev } from '@/utils/env';
5
+
6
+ export const createDevtools =
7
+ (name: string): typeof _devtools =>
8
+ (initializer) => {
9
+ let showDevtools = false;
10
+
11
+ // check url to show devtools
12
+ if (typeof window !== 'undefined') {
13
+ const url = new URL(window.location.href);
14
+ const debug = url.searchParams.get('debug');
15
+ if (debug?.includes(name)) {
16
+ showDevtools = true;
17
+ }
18
+ }
19
+
20
+ return optionalDevtools(showDevtools)(initializer, {
21
+ name: `LobeChat_${name}` + (isDev ? '_DEV' : ''),
22
+ });
23
+ };
@@ -1,13 +1,12 @@
1
1
  import { StoreApi } from 'zustand';
2
2
  import { createContext } from 'zustand-utils';
3
- import { devtools } from 'zustand/middleware';
4
3
  import { shallow } from 'zustand/shallow';
5
4
  import { createWithEqualityFn } from 'zustand/traditional';
6
5
  import { StateCreator } from 'zustand/vanilla';
7
6
 
8
7
  import { DEFAULT_FEATURE_FLAGS, IFeatureFlags } from '@/config/featureFlags';
8
+ import { createDevtools } from '@/store/middleware/createDevtools';
9
9
  import { GlobalServerConfig } from '@/types/serverConfig';
10
- import { isDev } from '@/utils/env';
11
10
  import { merge } from '@/utils/merge';
12
11
  import { StoreApiWithSelector } from '@/utils/zustand';
13
12
 
@@ -42,21 +41,16 @@ declare global {
42
41
  }
43
42
  }
44
43
 
44
+ const devtools = createDevtools('serverConfig');
45
+
45
46
  export const initServerConfigStore = (initState: Partial<ServerConfigStore>) =>
46
- createWithEqualityFn<ServerConfigStore>()(
47
- devtools(createStore(initState || {}), {
48
- name: 'LobeChat_ServerConfig' + (isDev ? '_DEV' : ''),
49
- }),
50
- shallow,
51
- );
47
+ createWithEqualityFn<ServerConfigStore>()(devtools(createStore(initState || {})), shallow);
52
48
 
53
49
  export const createServerConfigStore = (initState?: Partial<ServerConfigStore>) => {
54
50
  // make sure there is only one store
55
51
  if (!store) {
56
52
  store = createWithEqualityFn<ServerConfigStore>()(
57
- devtools(createStore(initState || {}), {
58
- name: 'LobeChat_ServerConfig' + (isDev ? '_DEV' : ''),
59
- }),
53
+ devtools(createStore(initState || {})),
60
54
  shallow,
61
55
  );
62
56
 
@@ -1,10 +1,11 @@
1
- import { devtools, subscribeWithSelector } from 'zustand/middleware';
1
+ import { subscribeWithSelector } from 'zustand/middleware';
2
2
  import { shallow } from 'zustand/shallow';
3
3
  import { createWithEqualityFn } from 'zustand/traditional';
4
4
  import { StateCreator } from 'zustand/vanilla';
5
5
 
6
6
  import { isDev } from '@/utils/env';
7
7
 
8
+ import { createDevtools } from '../middleware/createDevtools';
8
9
  import { SessionStoreState, initialState } from './initialState';
9
10
  import { SessionAction, createSessionSlice } from './slices/session/action';
10
11
  import { SessionGroupAction, createSessionGroupSlice } from './slices/sessionGroup/action';
@@ -20,6 +21,7 @@ const createStore: StateCreator<SessionStore, [['zustand/devtools', never]]> = (
20
21
  });
21
22
 
22
23
  // =============== implement useStore ============ //
24
+ const devtools = createDevtools('session');
23
25
 
24
26
  export const useSessionStore = createWithEqualityFn<SessionStore>()(
25
27
  subscribeWithSelector(
@@ -1,10 +1,8 @@
1
- import { devtools } from 'zustand/middleware';
2
1
  import { shallow } from 'zustand/shallow';
3
2
  import { createWithEqualityFn } from 'zustand/traditional';
4
3
  import { StateCreator } from 'zustand/vanilla';
5
4
 
6
- import { isDev } from '@/utils/env';
7
-
5
+ import { createDevtools } from '../middleware/createDevtools';
8
6
  import { ToolStoreState, initialState } from './initialState';
9
7
  import { BuiltinToolAction, createBuiltinToolSlice } from './slices/builtin';
10
8
  import { CustomPluginAction, createCustomPluginSlice } from './slices/customPlugin';
@@ -29,9 +27,6 @@ const createStore: StateCreator<ToolStore, [['zustand/devtools', never]]> = (...
29
27
 
30
28
  // =============== 实装 useStore ============ //
31
29
 
32
- export const useToolStore = createWithEqualityFn<ToolStore>()(
33
- devtools(createStore, {
34
- name: 'LobeChat_Tool' + (isDev ? '_DEV' : ''),
35
- }),
36
- shallow,
37
- );
30
+ const devtools = createDevtools('tools');
31
+
32
+ export const useToolStore = createWithEqualityFn<ToolStore>()(devtools(createStore), shallow);
@@ -7,8 +7,8 @@ import { userService } from '@/services/user';
7
7
  import { ClientService } from '@/services/user/client';
8
8
  import type { UserStore } from '@/store/user';
9
9
  import type { GlobalServerConfig } from '@/types/serverConfig';
10
- import type { GlobalSettings } from '@/types/settings';
11
10
  import { UserInitializationState } from '@/types/user';
11
+ import type { UserSettings } from '@/types/user/settings';
12
12
  import { switchLang } from '@/utils/client/switchLang';
13
13
  import { merge } from '@/utils/merge';
14
14
  import { setNamespace } from '@/utils/storeDebug';
@@ -78,7 +78,7 @@ export const createCommonSlice: StateCreator<
78
78
 
79
79
  if (data) {
80
80
  // merge settings
81
- const serverSettings: DeepPartial<GlobalSettings> = {
81
+ const serverSettings: DeepPartial<UserSettings> = {
82
82
  defaultAgent: serverConfig.defaultAgent,
83
83
  languageModel: serverConfig.languageModel,
84
84
  };
@@ -4,7 +4,7 @@ import { describe, expect, it, vi } from 'vitest';
4
4
  import { modelsService } from '@/services/models';
5
5
  import { userService } from '@/services/user';
6
6
  import { useUserStore } from '@/store/user';
7
- import { GeneralModelProviderConfig } from '@/types/settings';
7
+ import { OpenAICompatibleProviderConfig } from '@/types/user/settings';
8
8
 
9
9
  import { settingsSelectors } from '../settings/selectors';
10
10
  import { CustomModelCardDispatch } from './reducers/customModelCard';
@@ -24,7 +24,7 @@ describe('LLMSettingsSliceAction', () => {
24
24
  describe('setModelProviderConfig', () => {
25
25
  it('should set OpenAI configuration', async () => {
26
26
  const { result } = renderHook(() => useUserStore());
27
- const openAIConfig: Partial<GeneralModelProviderConfig> = { apiKey: 'test-key' };
27
+ const openAIConfig: Partial<OpenAICompatibleProviderConfig> = { apiKey: 'test-key' };
28
28
 
29
29
  // Perform the action
30
30
  await act(async () => {
@@ -6,7 +6,7 @@ import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
6
6
  import { ModelProvider } from '@/libs/agent-runtime';
7
7
  import { UserStore } from '@/store/user';
8
8
  import { ChatModelCard } from '@/types/llm';
9
- import { GlobalLLMConfig, GlobalLLMProviderKey } from '@/types/settings';
9
+ import { UserModelProviderConfig, GlobalLLMProviderKey } from '@/types/user/settings';
10
10
 
11
11
  import { settingsSelectors } from '../settings/selectors';
12
12
  import { CustomModelCardDispatch, customModelCardsReducer } from './reducers/customModelCard';
@@ -28,7 +28,7 @@ export interface ModelListAction {
28
28
  removeEnabledModels: (provider: GlobalLLMProviderKey, model: string) => Promise<void>;
29
29
  setModelProviderConfig: <T extends GlobalLLMProviderKey>(
30
30
  provider: T,
31
- config: Partial<GlobalLLMConfig[T]>,
31
+ config: Partial<UserModelProviderConfig[T]>,
32
32
  ) => Promise<void>;
33
33
 
34
34
  toggleEditingCustomModelCard: (params?: { id: string; provider: GlobalLLMProviderKey }) => void;
@@ -1,4 +1,4 @@
1
- import { GlobalLLMProviderKey } from '@/types/settings';
1
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
2
2
 
3
3
  import { UserStore } from '../../../store';
4
4
  import { currentLLMSettings, getProviderConfigById } from '../../settings/selectors/settings';
@@ -3,7 +3,7 @@ import { uniqBy } from 'lodash-es';
3
3
  import { filterEnabledModels } from '@/config/modelProviders';
4
4
  import { ChatModelCard, ModelProviderCard } from '@/types/llm';
5
5
  import { ServerModelProviderConfig } from '@/types/serverConfig';
6
- import { GlobalLLMProviderKey } from '@/types/settings';
6
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
7
7
 
8
8
  import { UserStore } from '../../../store';
9
9
  import { currentSettings, getProviderConfigById } from '../../settings/selectors/settings';
@@ -7,7 +7,7 @@ import { DEFAULT_AGENT, DEFAULT_SETTINGS } from '@/const/settings';
7
7
  import { userService } from '@/services/user';
8
8
  import { useUserStore } from '@/store/user';
9
9
  import { LobeAgentSettings } from '@/types/session';
10
- import { GlobalSettings } from '@/types/settings';
10
+ import { UserSettings } from '@/types/user/settings';
11
11
 
12
12
  // Mock userService
13
13
  vi.mock('@/services/user', () => ({
@@ -21,7 +21,7 @@ describe('SettingsAction', () => {
21
21
  describe('importAppSettings', () => {
22
22
  it('should import app settings', async () => {
23
23
  const { result } = renderHook(() => useUserStore());
24
- const newSettings: GlobalSettings = {
24
+ const newSettings: UserSettings = {
25
25
  ...DEFAULT_SETTINGS,
26
26
  themeMode: 'dark',
27
27
  };
@@ -69,7 +69,7 @@ describe('SettingsAction', () => {
69
69
  describe('setSettings', () => {
70
70
  it('should set partial settings', async () => {
71
71
  const { result } = renderHook(() => useUserStore());
72
- const partialSettings: Partial<GlobalSettings> = { themeMode: 'dark' };
72
+ const partialSettings: Partial<UserSettings> = { themeMode: 'dark' };
73
73
 
74
74
  // Perform the action
75
75
  await act(async () => {
@@ -116,7 +116,7 @@ describe('SettingsAction', () => {
116
116
  describe('setTranslationSystemAgent', () => {
117
117
  it('should set partial settings', async () => {
118
118
  const { result } = renderHook(() => useUserStore());
119
- const systemAgentSettings: Partial<GlobalSettings> = {
119
+ const systemAgentSettings: Partial<UserSettings> = {
120
120
  systemAgent: {
121
121
  translation: {
122
122
  model: 'testmodel',
@@ -7,15 +7,15 @@ import { userService } from '@/services/user';
7
7
  import type { UserStore } from '@/store/user';
8
8
  import { LocaleMode } from '@/types/locale';
9
9
  import { LobeAgentSettings } from '@/types/session';
10
- import { GlobalSettings } from '@/types/settings';
10
+ import { UserSettings } from '@/types/user/settings';
11
11
  import { switchLang } from '@/utils/client/switchLang';
12
12
  import { difference } from '@/utils/difference';
13
13
  import { merge } from '@/utils/merge';
14
14
 
15
15
  export interface UserSettingsAction {
16
- importAppSettings: (settings: GlobalSettings) => Promise<void>;
16
+ importAppSettings: (settings: UserSettings) => Promise<void>;
17
17
  resetSettings: () => Promise<void>;
18
- setSettings: (settings: DeepPartial<GlobalSettings>) => Promise<void>;
18
+ setSettings: (settings: DeepPartial<UserSettings>) => Promise<void>;
19
19
  setTranslationSystemAgent: (provider: string, model: string) => Promise<void>;
20
20
  switchLocale: (locale: LocaleMode) => Promise<void>;
21
21
  switchThemeMode: (themeMode: ThemeMode) => Promise<void>;
@@ -1,11 +1,11 @@
1
1
  import { DeepPartial } from 'utility-types';
2
2
 
3
3
  import { DEFAULT_SETTINGS } from '@/const/settings';
4
- import { GlobalSettings } from '@/types/settings';
4
+ import { UserSettings } from '@/types/user/settings';
5
5
 
6
6
  export interface UserSettingsState {
7
- defaultSettings: GlobalSettings;
8
- settings: DeepPartial<GlobalSettings>;
7
+ defaultSettings: UserSettings;
8
+ settings: DeepPartial<UserSettings>;
9
9
  }
10
10
 
11
11
  export const initialSettingsState: UserSettingsState = {
@@ -7,19 +7,22 @@ import {
7
7
  DEFAULT_TTS_CONFIG,
8
8
  } from '@/const/settings';
9
9
  import { Locales } from '@/locales/resources';
10
- import { GeneralModelProviderConfig, GlobalLLMProviderKey, GlobalSettings } from '@/types/settings';
10
+ import {
11
+ OpenAICompatibleProviderConfig,
12
+ GlobalLLMProviderKey,
13
+ UserSettings,
14
+ } from '@/types/user/settings';
11
15
  import { isOnServerSide } from '@/utils/env';
12
16
  import { merge } from '@/utils/merge';
13
17
 
14
18
  import { UserStore } from '../../../store';
15
19
 
16
- export const currentSettings = (s: UserStore): GlobalSettings =>
17
- merge(s.defaultSettings, s.settings);
20
+ export const currentSettings = (s: UserStore): UserSettings => merge(s.defaultSettings, s.settings);
18
21
 
19
22
  export const currentLLMSettings = (s: UserStore) => currentSettings(s).languageModel;
20
23
 
21
24
  export const getProviderConfigById = (provider: string) => (s: UserStore) =>
22
- currentLLMSettings(s)[provider as GlobalLLMProviderKey] as GeneralModelProviderConfig | undefined;
25
+ currentLLMSettings(s)[provider as GlobalLLMProviderKey] as OpenAICompatibleProviderConfig | undefined;
23
26
 
24
27
  const password = (s: UserStore) => currentSettings(s).password;
25
28
 
@@ -35,7 +38,7 @@ const exportSettings = (s: UserStore) => {
35
38
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
39
  const { password: _, ...settings } = currentSettings(s);
37
40
 
38
- return settings as GlobalSettings;
41
+ return settings as UserSettings;
39
42
  };
40
43
 
41
44
  const currentLanguage = (s: UserStore) => {
@@ -1,10 +1,9 @@
1
- import { devtools, subscribeWithSelector } from 'zustand/middleware';
1
+ import { subscribeWithSelector } from 'zustand/middleware';
2
2
  import { shallow } from 'zustand/shallow';
3
3
  import { createWithEqualityFn } from 'zustand/traditional';
4
4
  import { StateCreator } from 'zustand/vanilla';
5
5
 
6
- import { isDev } from '@/utils/env';
7
-
6
+ import { createDevtools } from '../middleware/createDevtools';
8
7
  import { type UserState, initialState } from './initialState';
9
8
  import { type UserAuthAction, createAuthSlice } from './slices/auth/action';
10
9
  import { type CommonAction, createCommonSlice } from './slices/common/action';
@@ -35,11 +34,9 @@ const createStore: StateCreator<UserStore, [['zustand/devtools', never]]> = (...
35
34
 
36
35
  // =============== 实装 useStore ============ //
37
36
 
37
+ const devtools = createDevtools('user');
38
+
38
39
  export const useUserStore = createWithEqualityFn<UserStore>()(
39
- subscribeWithSelector(
40
- devtools(createStore, {
41
- name: 'LobeChat_User' + (isDev ? '_DEV' : ''),
42
- }),
43
- ),
40
+ subscribeWithSelector(devtools(createStore)),
44
41
  shallow,
45
42
  );
@@ -1,7 +1,7 @@
1
1
  import { ChatMessage } from '@/types/message';
2
2
  import { LobeSessions, SessionGroupItem } from '@/types/session';
3
- import { GlobalSettings } from '@/types/settings';
4
3
  import { ChatTopic } from '@/types/topic';
4
+ import { UserSettings } from '@/types/user/settings';
5
5
 
6
6
  /**
7
7
  * 导出方式
@@ -69,7 +69,7 @@ export interface ConfigStateAgents {
69
69
  * 配置状态:设置
70
70
  */
71
71
  export interface ConfigStateSettings {
72
- settings: GlobalSettings;
72
+ settings: UserSettings;
73
73
  }
74
74
 
75
75
  /**
@@ -1,7 +1,7 @@
1
1
  import { DeepPartial } from 'utility-types';
2
2
 
3
3
  import { ChatModelCard } from '@/types/llm';
4
- import { GlobalDefaultAgent, GlobalLLMProviderKey } from '@/types/settings';
4
+ import { UserDefaultAgent, GlobalLLMProviderKey } from '@/types/user/settings';
5
5
 
6
6
  export interface ServerModelProviderConfig {
7
7
  enabled?: boolean;
@@ -16,7 +16,7 @@ export interface ServerModelProviderConfig {
16
16
  export type ServerLanguageModel = Partial<Record<GlobalLLMProviderKey, ServerModelProviderConfig>>;
17
17
 
18
18
  export interface GlobalServerConfig {
19
- defaultAgent?: DeepPartial<GlobalDefaultAgent>;
19
+ defaultAgent?: DeepPartial<UserDefaultAgent>;
20
20
  enableUploadFileToServer?: boolean;
21
21
  enabledAccessCode?: boolean;
22
22
  enabledOAuthSSO?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { DeepPartial } from 'utility-types';
2
2
 
3
- import { GlobalSettings } from '@/types/settings';
3
+ import { UserSettings } from '@/types/user/settings';
4
4
 
5
5
  export interface LobeUser {
6
6
  avatar?: string;
@@ -39,6 +39,6 @@ export interface UserInitializationState {
39
39
  hasConversation?: boolean;
40
40
  isOnboard?: boolean;
41
41
  preference: UserPreference;
42
- settings: DeepPartial<GlobalSettings>;
42
+ settings: DeepPartial<UserSettings>;
43
43
  userId?: string;
44
44
  }
@@ -3,10 +3,13 @@ import type { ThemeMode } from 'antd-style';
3
3
 
4
4
  import { LocaleMode } from '@/types/locale';
5
5
 
6
- export interface GlobalBaseSettings {
6
+ export interface UserGeneralSettings {
7
7
  fontSize: number;
8
8
  language: LocaleMode;
9
9
  neutralColor?: NeutralColors;
10
+ /**
11
+ * @deprecated
12
+ */
10
13
  password: string;
11
14
  primaryColor?: PrimaryColors;
12
15
  themeMode: ThemeMode;
@@ -0,0 +1,54 @@
1
+ import type { NeutralColors, PrimaryColors } from '@lobehub/ui';
2
+ import type { ThemeMode } from 'antd-style';
3
+
4
+ import { LocaleMode } from '@/types/locale';
5
+ import type { LobeAgentSession } from '@/types/session';
6
+
7
+ import { UserModelProviderConfig } from './modelProvider';
8
+ import { UserSyncSettings } from './sync';
9
+ import { UserSystemAgentConfig } from './systemAgent';
10
+ import { UserToolConfig } from './tool';
11
+ import { UserTTSConfig } from './tts';
12
+
13
+ export type UserDefaultAgent = Pick<LobeAgentSession, 'config' | 'meta'>;
14
+
15
+ export * from './general';
16
+ export * from './modelProvider';
17
+ export * from './sync';
18
+ export * from './systemAgent';
19
+ export * from './tts';
20
+
21
+ /**
22
+ * 配置设置
23
+ */
24
+ export interface UserSettings {
25
+ defaultAgent: UserDefaultAgent;
26
+ /**
27
+ * @deprecated
28
+ */
29
+ fontSize: number;
30
+ /**
31
+ * @deprecated
32
+ */
33
+ language: LocaleMode;
34
+ languageModel: UserModelProviderConfig;
35
+ /**
36
+ * @deprecated
37
+ */
38
+ neutralColor?: NeutralColors;
39
+
40
+ password: string;
41
+
42
+ /**
43
+ * @deprecated
44
+ */
45
+ primaryColor?: PrimaryColors;
46
+ sync: UserSyncSettings;
47
+ systemAgent: UserSystemAgentConfig;
48
+ /**
49
+ * @deprecated
50
+ */
51
+ themeMode: ThemeMode;
52
+ tool: UserToolConfig;
53
+ tts: UserTTSConfig;
54
+ }
@@ -0,0 +1,70 @@
1
+ import { ChatModelCard } from '@/types/llm';
2
+
3
+ export interface OpenAICompatibleProviderConfig {
4
+ /**
5
+ * @deprecated
6
+ */
7
+ apiKey?: string;
8
+ /**
9
+ * whether to auto fetch model lists
10
+ */
11
+ autoFetchModelLists?: boolean;
12
+ /**
13
+ * user defined model cards
14
+ */
15
+ customModelCards?: ChatModelCard[];
16
+ enabled: boolean;
17
+ /**
18
+ * enabled models id
19
+ */
20
+ enabledModels?: string[] | null;
21
+ /**
22
+ * @deprecated
23
+ */
24
+ endpoint?: string;
25
+ /**
26
+ * whether fetch on client
27
+ */
28
+ fetchOnClient?: boolean;
29
+ /**
30
+ * the latest fetch model list time
31
+ */
32
+ latestFetchTime?: number;
33
+ /**
34
+ * fetched models from provider side
35
+ */
36
+ remoteModelCards?: ChatModelCard[];
37
+ }
38
+
39
+ export interface AzureOpenAIConfig extends Omit<OpenAICompatibleProviderConfig, 'endpoint'> {
40
+ apiVersion?: string;
41
+ endpoint?: string;
42
+ }
43
+
44
+ export interface AWSBedrockConfig
45
+ extends Omit<OpenAICompatibleProviderConfig, 'apiKey' | 'endpoint'> {
46
+ accessKeyId?: string;
47
+ region?: string;
48
+ secretAccessKey?: string;
49
+ }
50
+
51
+ export interface UserModelProviderConfig {
52
+ anthropic: OpenAICompatibleProviderConfig;
53
+ azure: AzureOpenAIConfig;
54
+ bedrock: AWSBedrockConfig;
55
+ deepseek: OpenAICompatibleProviderConfig;
56
+ google: OpenAICompatibleProviderConfig;
57
+ groq: OpenAICompatibleProviderConfig;
58
+ minimax: OpenAICompatibleProviderConfig;
59
+ mistral: OpenAICompatibleProviderConfig;
60
+ moonshot: OpenAICompatibleProviderConfig;
61
+ ollama: OpenAICompatibleProviderConfig;
62
+ openai: OpenAICompatibleProviderConfig;
63
+ openrouter: OpenAICompatibleProviderConfig;
64
+ perplexity: OpenAICompatibleProviderConfig;
65
+ togetherai: OpenAICompatibleProviderConfig;
66
+ zeroone: OpenAICompatibleProviderConfig;
67
+ zhipu: OpenAICompatibleProviderConfig;
68
+ }
69
+
70
+ export type GlobalLLMProviderKey = keyof UserModelProviderConfig;
@@ -4,7 +4,7 @@ export interface WebRTCSyncConfig {
4
4
  enabled: boolean;
5
5
  signaling?: string;
6
6
  }
7
- export interface GlobalSyncSettings {
7
+ export interface UserSyncSettings {
8
8
  deviceName?: string;
9
9
  webrtc: WebRTCSyncConfig;
10
10
  }
@@ -3,6 +3,6 @@ export interface GlobalTranslationConfig {
3
3
  provider: string;
4
4
  }
5
5
 
6
- export interface GlobalSystemAgentConfig {
6
+ export interface UserSystemAgentConfig {
7
7
  translation: GlobalTranslationConfig;
8
8
  }
@@ -0,0 +1,5 @@
1
+ export interface UserToolConfig {
2
+ dalle: {
3
+ autoGenerate: boolean;
4
+ };
5
+ }
@@ -1,6 +1,6 @@
1
1
  export type STTServer = 'openai' | 'browser';
2
2
 
3
- export interface GlobalTTSConfig {
3
+ export interface UserTTSConfig {
4
4
  openAI: {
5
5
  sttModel: 'whisper-1';
6
6
  ttsModel: 'tts-1' | 'tts-1-hd';
@@ -1,33 +0,0 @@
1
- import type { LobeAgentSession } from '@/types/session';
2
-
3
- import { GlobalBaseSettings } from './base';
4
- import { GlobalLLMConfig } from './modelProvider';
5
- import { GlobalSyncSettings } from './sync';
6
- import { GlobalSystemAgentConfig } from './systemAgent';
7
- import { GlobalTTSConfig } from './tts';
8
-
9
- export type GlobalDefaultAgent = Pick<LobeAgentSession, 'config' | 'meta'>;
10
-
11
- export * from './base';
12
- export * from './modelProvider';
13
- export * from './sync';
14
- export * from './systemAgent';
15
- export * from './tts';
16
-
17
- export interface GlobalTool {
18
- dalle: {
19
- autoGenerate: boolean;
20
- };
21
- }
22
-
23
- /**
24
- * 配置设置
25
- */
26
- export interface GlobalSettings extends GlobalBaseSettings {
27
- defaultAgent: GlobalDefaultAgent;
28
- languageModel: GlobalLLMConfig;
29
- sync: GlobalSyncSettings;
30
- systemAgent: GlobalSystemAgentConfig;
31
- tool: GlobalTool;
32
- tts: GlobalTTSConfig;
33
- }