@lobehub/chat 0.127.0 → 0.127.1

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 (52) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.json +1 -1
  3. package/src/app/chat/features/ChatHeader/SettingButton.tsx +1 -2
  4. package/src/app/settings/(desktop)/features/Header.tsx +3 -4
  5. package/src/app/settings/(desktop)/features/SideBar.tsx +42 -0
  6. package/src/app/settings/(desktop)/index.tsx +4 -3
  7. package/src/app/settings/(desktop)/layout.desktop.tsx +14 -6
  8. package/src/app/settings/(desktop)/layout.responsive.tsx +4 -4
  9. package/src/app/settings/(mobile)/features/ExtraList.tsx +7 -5
  10. package/src/app/settings/(mobile)/features/Header/index.tsx +8 -5
  11. package/src/app/settings/(mobile)/index.tsx +1 -3
  12. package/src/app/settings/(mobile)/layout.mobile.tsx +8 -4
  13. package/src/app/settings/(mobile)/mobile/index.tsx +3 -5
  14. package/src/app/settings/agent/Agent.tsx +0 -4
  15. package/src/app/settings/agent/layout.tsx +9 -1
  16. package/src/app/settings/agent/page.tsx +17 -2
  17. package/src/app/settings/common/index.tsx +0 -3
  18. package/src/app/settings/common/layout.tsx +9 -1
  19. package/src/app/settings/features/SettingList/Item.tsx +50 -0
  20. package/src/app/settings/features/{SideBar/List.tsx → SettingList/index.tsx} +14 -15
  21. package/src/app/settings/layout.server.tsx +10 -3
  22. package/src/app/settings/llm/Azure/index.tsx +78 -106
  23. package/src/app/settings/llm/Bedrock/index.tsx +60 -89
  24. package/src/app/settings/llm/Google/index.tsx +26 -55
  25. package/src/app/settings/llm/Moonshot/index.tsx +29 -54
  26. package/src/app/settings/llm/Ollama/index.tsx +35 -61
  27. package/src/app/settings/llm/OpenAI/index.tsx +91 -107
  28. package/src/app/settings/llm/Zhipu/index.tsx +29 -54
  29. package/src/app/settings/llm/components/ProviderConfig/index.tsx +58 -0
  30. package/src/app/settings/llm/index.tsx +42 -0
  31. package/src/app/settings/llm/layout.tsx +9 -1
  32. package/src/app/settings/llm/page.tsx +6 -46
  33. package/src/app/settings/tts/layout.tsx +9 -1
  34. package/src/app/settings/tts/page.tsx +17 -2
  35. package/src/const/settings.ts +1 -0
  36. package/src/features/SideBar/BottomActions.tsx +1 -2
  37. package/src/layout/ResponsiveLayout.client.tsx +7 -7
  38. package/src/layout/ResponsiveLayout.server.tsx +6 -6
  39. package/src/services/_auth.test.ts +132 -0
  40. package/src/services/_auth.ts +1 -1
  41. package/src/store/global/slices/common/initialState.ts +0 -2
  42. package/src/store/global/slices/settings/action.test.ts +0 -13
  43. package/src/store/global/slices/settings/action.ts +0 -5
  44. package/src/store/global/slices/settings/selectors/modelProvider.ts +7 -0
  45. package/src/types/settings/modelProvider.ts +1 -0
  46. package/src/app/settings/agent/index.tsx +0 -21
  47. package/src/app/settings/features/SideBar/Item.tsx +0 -44
  48. package/src/app/settings/features/SideBar/index.tsx +0 -42
  49. package/src/app/settings/tts/index.tsx +0 -21
  50. package/src/store/global/hooks/useSwitchSettingsOnInit.ts +0 -12
  51. /package/src/app/settings/llm/{Checker.tsx → components/Checker.tsx} +0 -0
  52. /package/src/app/settings/llm/{useSyncSettings.ts → components/ProviderConfig/useSyncSettings.ts} +0 -0
@@ -1,80 +1,54 @@
1
1
  import { Ollama } from '@lobehub/icons';
2
- import { Form, type ItemGroup } from '@lobehub/ui';
3
- import { Form as AntForm, Input, Switch } from 'antd';
2
+ import { Input } from 'antd';
4
3
  import { useTheme } from 'antd-style';
5
- import { debounce } from 'lodash-es';
6
4
  import { memo } from 'react';
7
5
  import { useTranslation } from 'react-i18next';
8
- import { Flexbox } from 'react-layout-kit';
9
6
 
10
- import { FORM_STYLE } from '@/const/layoutTokens';
11
7
  import { ModelProvider } from '@/libs/agent-runtime';
12
- import { useGlobalStore } from '@/store/global';
13
- import { modelProviderSelectors } from '@/store/global/selectors';
14
8
 
15
- import Checker from '../Checker';
9
+ import Checker from '../components/Checker';
10
+ import ProviderConfig from '../components/ProviderConfig';
16
11
  import { LLMProviderBaseUrlKey, LLMProviderConfigKey } from '../const';
17
- import { useSyncSettings } from '../useSyncSettings';
18
12
 
19
13
  const providerKey = 'ollama';
20
14
 
21
15
  const OllamaProvider = memo(() => {
22
16
  const { t } = useTranslation('setting');
23
- const [form] = AntForm.useForm();
24
17
  const theme = useTheme();
25
- const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
26
- s.toggleProviderEnabled,
27
- s.setSettings,
28
- ]);
29
- const enabled = useGlobalStore(modelProviderSelectors.enableOllama);
30
-
31
- useSyncSettings(form);
32
-
33
- const model: ItemGroup = {
34
- children: [
35
- {
36
- children: <Input allowClear placeholder={t('llm.Ollama.endpoint.placeholder')} />,
37
- desc: t('llm.Ollama.endpoint.desc'),
38
- label: t('llm.Ollama.endpoint.title'),
39
- name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
40
- },
41
- {
42
- children: (
43
- <Input.TextArea
44
- allowClear
45
- placeholder={t('llm.Ollama.customModelName.placeholder')}
46
- style={{ height: 100 }}
47
- />
48
- ),
49
- desc: t('llm.Ollama.customModelName.desc'),
50
- label: t('llm.Ollama.customModelName.title'),
51
- name: [LLMProviderConfigKey, providerKey, 'customModelName'],
52
- },
53
- {
54
- children: <Checker model={'llama2'} provider={ModelProvider.Ollama} />,
55
- desc: t('llm.Ollama.checker.desc'),
56
- label: t('llm.checker.title'),
57
- minWidth: undefined,
58
- },
59
- ],
60
- defaultActive: enabled,
61
- extra: (
62
- <Switch
63
- onChange={(enabled: boolean) => {
64
- toggleProviderEnabled(providerKey, enabled);
65
- }}
66
- value={enabled}
67
- />
68
- ),
69
- title: (
70
- <Flexbox align={'center'} gap={8} horizontal>
71
- <Ollama.Combine color={theme.isDarkMode ? theme.colorText : theme.colorPrimary} size={24} />
72
- </Flexbox>
73
- ),
74
- };
75
18
 
76
19
  return (
77
- <Form form={form} items={[model]} onValuesChange={debounce(setSettings, 100)} {...FORM_STYLE} />
20
+ <ProviderConfig
21
+ configItems={[
22
+ {
23
+ children: <Input allowClear placeholder={t('llm.Ollama.endpoint.placeholder')} />,
24
+ desc: t('llm.Ollama.endpoint.desc'),
25
+ label: t('llm.Ollama.endpoint.title'),
26
+ name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
27
+ },
28
+ {
29
+ children: (
30
+ <Input.TextArea
31
+ allowClear
32
+ placeholder={t('llm.Ollama.customModelName.placeholder')}
33
+ style={{ height: 100 }}
34
+ />
35
+ ),
36
+ desc: t('llm.Ollama.customModelName.desc'),
37
+ label: t('llm.Ollama.customModelName.title'),
38
+ name: [LLMProviderConfigKey, providerKey, 'customModelName'],
39
+ },
40
+ {
41
+ children: <Checker model={'llama2'} provider={ModelProvider.Ollama} />,
42
+ desc: t('llm.Ollama.checker.desc'),
43
+ label: t('llm.checker.title'),
44
+ minWidth: undefined,
45
+ },
46
+ ]}
47
+ provider={providerKey}
48
+ title={
49
+ <Ollama.Combine color={theme.isDarkMode ? theme.colorText : theme.colorPrimary} size={24} />
50
+ }
51
+ />
78
52
  );
79
53
  });
80
54
 
@@ -1,20 +1,17 @@
1
1
  import { OpenAI } from '@lobehub/icons';
2
- import { Form, type ItemGroup, Markdown } from '@lobehub/ui';
3
- import { Form as AntForm, AutoComplete, Input, Switch } from 'antd';
2
+ import { Markdown } from '@lobehub/ui';
3
+ import { AutoComplete, Input, Switch } from 'antd';
4
4
  import { createStyles } from 'antd-style';
5
- import { debounce } from 'lodash-es';
6
5
  import { memo } from 'react';
7
6
  import { useTranslation } from 'react-i18next';
8
- import { Flexbox } from 'react-layout-kit';
9
7
 
10
- import { FORM_STYLE } from '@/const/layoutTokens';
11
8
  import { ModelProvider } from '@/libs/agent-runtime';
12
9
  import { useGlobalStore } from '@/store/global';
13
10
  import { modelProviderSelectors } from '@/store/global/selectors';
14
11
 
15
- import Checker from '../Checker';
12
+ import Checker from '../components/Checker';
13
+ import ProviderConfig from '../components/ProviderConfig';
16
14
  import { LLMProviderConfigKey } from '../const';
17
- import { useSyncSettings } from '../useSyncSettings';
18
15
 
19
16
  const useStyles = createStyles(({ css, token }) => ({
20
17
  markdown: css`
@@ -37,109 +34,96 @@ const providerKey = 'openAI';
37
34
  const LLM = memo(() => {
38
35
  const { t } = useTranslation('setting');
39
36
  const { styles } = useStyles();
40
- const [form] = AntForm.useForm();
41
37
 
42
- const [useAzure, setSettings] = useGlobalStore((s) => [
43
- modelProviderSelectors.enableAzure(s),
44
- s.setSettings,
45
- ]);
46
-
47
- useSyncSettings(form);
48
-
49
- const openAI: ItemGroup = {
50
- children: [
51
- {
52
- children: (
53
- <Input.Password
54
- autoComplete={'new-password'}
55
- placeholder={
56
- useAzure ? t('llm.AzureOpenAI.token.placeholder') : t('llm.OpenAI.token.placeholder')
57
- }
58
- />
59
- ),
60
- desc: useAzure ? t('llm.AzureOpenAI.token.desc') : t('llm.OpenAI.token.desc'),
61
- label: useAzure ? t('llm.AzureOpenAI.token.title') : t('llm.OpenAI.token.title'),
62
- name: [LLMProviderConfigKey, providerKey, 'OPENAI_API_KEY'],
63
- },
64
- {
65
- children: (
66
- <Input
67
- allowClear
68
- placeholder={
69
- useAzure
70
- ? t('llm.AzureOpenAI.endpoint.placeholder')
71
- : t('llm.OpenAI.endpoint.placeholder')
72
- }
73
- />
74
- ),
75
- desc: useAzure ? t('llm.AzureOpenAI.endpoint.desc') : t('llm.OpenAI.endpoint.desc'),
76
- label: useAzure ? t('llm.AzureOpenAI.endpoint.title') : t('llm.OpenAI.endpoint.title'),
77
- name: [LLMProviderConfigKey, providerKey, 'endpoint'],
78
- },
79
- {
80
- children: (
81
- <Input.TextArea
82
- allowClear
83
- placeholder={t('llm.OpenAI.customModelName.placeholder')}
84
- style={{ height: 100 }}
85
- />
86
- ),
87
- desc: t('llm.OpenAI.customModelName.desc'),
88
- label: t('llm.OpenAI.customModelName.title'),
89
- name: [LLMProviderConfigKey, providerKey, 'customModelName'],
90
- },
91
- {
92
- children: <Switch />,
93
- desc: t('llm.OpenAI.useAzure.desc'),
94
- label: t('llm.OpenAI.useAzure.title'),
95
- minWidth: undefined,
96
- name: [LLMProviderConfigKey, 'openAI', 'useAzure'],
97
- valuePropName: 'checked',
98
- },
99
- {
100
- children: (
101
- <AutoComplete
102
- options={[
103
- '2023-12-01-preview',
104
- '2023-08-01-preview',
105
- '2023-07-01-preview',
106
- '2023-06-01-preview',
107
- '2023-05-15',
108
- '2023-03-15-preview',
109
- ].map((i) => ({
110
- label: i,
111
- value: i,
112
- }))}
113
- placeholder={'20XX-XX-XX'}
114
- />
115
- ),
116
- desc: (
117
- <Markdown className={styles.markdown}>{t('llm.OpenAI.azureApiVersion.desc')}</Markdown>
118
- ),
119
- hidden: !useAzure,
120
- label: t('llm.OpenAI.azureApiVersion.title'),
121
- name: [LLMProviderConfigKey, providerKey, 'azureApiVersion'],
122
- },
123
- {
124
- children: <Checker model={'gpt-3.5-turbo'} provider={ModelProvider.OpenAI} />,
125
- desc: t('llm.checker.desc'),
126
- label: t('llm.checker.title'),
127
- minWidth: '100%',
128
- },
129
- ],
130
- title: (
131
- <Flexbox align={'center'} gap={8} horizontal>
132
- <OpenAI.Combine size={24}></OpenAI.Combine>
133
- </Flexbox>
134
- ),
135
- };
38
+ const [useAzure] = useGlobalStore((s) => [modelProviderSelectors.enableAzure(s)]);
136
39
 
137
40
  return (
138
- <Form
139
- form={form}
140
- items={[openAI]}
141
- onValuesChange={debounce(setSettings, 100)}
142
- {...FORM_STYLE}
41
+ <ProviderConfig
42
+ canDeactivate={false}
43
+ configItems={[
44
+ {
45
+ children: (
46
+ <Input.Password
47
+ autoComplete={'new-password'}
48
+ placeholder={
49
+ useAzure
50
+ ? t('llm.AzureOpenAI.token.placeholder')
51
+ : t('llm.OpenAI.token.placeholder')
52
+ }
53
+ />
54
+ ),
55
+ desc: useAzure ? t('llm.AzureOpenAI.token.desc') : t('llm.OpenAI.token.desc'),
56
+ label: useAzure ? t('llm.AzureOpenAI.token.title') : t('llm.OpenAI.token.title'),
57
+ name: [LLMProviderConfigKey, providerKey, 'OPENAI_API_KEY'],
58
+ },
59
+ {
60
+ children: (
61
+ <Input
62
+ allowClear
63
+ placeholder={
64
+ useAzure
65
+ ? t('llm.AzureOpenAI.endpoint.placeholder')
66
+ : t('llm.OpenAI.endpoint.placeholder')
67
+ }
68
+ />
69
+ ),
70
+ desc: useAzure ? t('llm.AzureOpenAI.endpoint.desc') : t('llm.OpenAI.endpoint.desc'),
71
+ label: useAzure ? t('llm.AzureOpenAI.endpoint.title') : t('llm.OpenAI.endpoint.title'),
72
+ name: [LLMProviderConfigKey, providerKey, 'endpoint'],
73
+ },
74
+ {
75
+ children: (
76
+ <Input.TextArea
77
+ allowClear
78
+ placeholder={t('llm.OpenAI.customModelName.placeholder')}
79
+ style={{ height: 100 }}
80
+ />
81
+ ),
82
+ desc: t('llm.OpenAI.customModelName.desc'),
83
+ label: t('llm.OpenAI.customModelName.title'),
84
+ name: [LLMProviderConfigKey, providerKey, 'customModelName'],
85
+ },
86
+ {
87
+ children: <Switch />,
88
+ desc: t('llm.OpenAI.useAzure.desc'),
89
+ label: t('llm.OpenAI.useAzure.title'),
90
+ minWidth: undefined,
91
+ name: [LLMProviderConfigKey, 'openAI', 'useAzure'],
92
+ valuePropName: 'checked',
93
+ },
94
+ {
95
+ children: (
96
+ <AutoComplete
97
+ options={[
98
+ '2023-12-01-preview',
99
+ '2023-08-01-preview',
100
+ '2023-07-01-preview',
101
+ '2023-06-01-preview',
102
+ '2023-05-15',
103
+ '2023-03-15-preview',
104
+ ].map((i) => ({
105
+ label: i,
106
+ value: i,
107
+ }))}
108
+ placeholder={'20XX-XX-XX'}
109
+ />
110
+ ),
111
+ desc: (
112
+ <Markdown className={styles.markdown}>{t('llm.OpenAI.azureApiVersion.desc')}</Markdown>
113
+ ),
114
+ hidden: !useAzure,
115
+ label: t('llm.OpenAI.azureApiVersion.title'),
116
+ name: [LLMProviderConfigKey, providerKey, 'azureApiVersion'],
117
+ },
118
+ {
119
+ children: <Checker model={'gpt-3.5-turbo'} provider={ModelProvider.OpenAI} />,
120
+ desc: t('llm.checker.desc'),
121
+ label: t('llm.checker.title'),
122
+ minWidth: '100%',
123
+ },
124
+ ]}
125
+ provider={providerKey}
126
+ title={<OpenAI.Combine size={24}></OpenAI.Combine>}
143
127
  />
144
128
  );
145
129
  });
@@ -1,77 +1,52 @@
1
1
  import { Zhipu } from '@lobehub/icons';
2
- import { Form, type ItemGroup } from '@lobehub/ui';
3
- import { Form as AntForm, Input, Switch } from 'antd';
2
+ import { Input } from 'antd';
4
3
  import { useTheme } from 'antd-style';
5
- import { debounce } from 'lodash-es';
6
4
  import { lighten } from 'polished';
7
5
  import { memo } from 'react';
8
6
  import { useTranslation } from 'react-i18next';
9
- import { Flexbox } from 'react-layout-kit';
10
7
 
11
- import { FORM_STYLE } from '@/const/layoutTokens';
12
8
  import { ModelProvider } from '@/libs/agent-runtime';
13
- import { useGlobalStore } from '@/store/global';
14
- import { modelProviderSelectors } from '@/store/global/selectors';
15
9
 
16
- import Checker from '../Checker';
10
+ import Checker from '../components/Checker';
11
+ import ProviderConfig from '../components/ProviderConfig';
17
12
  import { LLMProviderApiTokenKey, LLMProviderConfigKey } from '../const';
18
- import { useSyncSettings } from '../useSyncSettings';
19
13
 
20
14
  const providerKey = 'zhipu';
21
15
 
22
16
  const ZhipuProvider = memo(() => {
23
17
  const { t } = useTranslation('setting');
24
- const [form] = AntForm.useForm();
25
- const theme = useTheme();
26
- const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
27
- s.toggleProviderEnabled,
28
- s.setSettings,
29
- ]);
30
- const enabled = useGlobalStore(modelProviderSelectors.enableZhipu);
31
18
 
32
- useSyncSettings(form);
19
+ const theme = useTheme();
33
20
 
34
- const model: ItemGroup = {
35
- children: [
36
- {
37
- children: (
38
- <Input.Password
39
- autoComplete={'new-password'}
40
- placeholder={t('llm.Zhipu.token.placeholder')}
41
- />
42
- ),
43
- desc: t('llm.Zhipu.token.desc'),
44
- label: t('llm.Zhipu.token.title'),
45
- name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
46
- },
47
- {
48
- children: <Checker model={'glm-3-turbo'} provider={ModelProvider.ZhiPu} />,
49
- desc: t('llm.checker.desc'),
50
- label: t('llm.checker.title'),
51
- minWidth: '100%',
52
- },
53
- ],
54
- defaultActive: enabled,
55
- extra: (
56
- <Switch
57
- onChange={(enabled) => {
58
- toggleProviderEnabled(providerKey, enabled);
59
- }}
60
- value={enabled}
61
- />
62
- ),
63
- title: (
64
- <Flexbox align={'center'} gap={8} horizontal>
21
+ return (
22
+ <ProviderConfig
23
+ configItems={[
24
+ {
25
+ children: (
26
+ <Input.Password
27
+ autoComplete={'new-password'}
28
+ placeholder={t('llm.Zhipu.token.placeholder')}
29
+ />
30
+ ),
31
+ desc: t('llm.Zhipu.token.desc'),
32
+ label: t('llm.Zhipu.token.title'),
33
+ name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
34
+ },
35
+ {
36
+ children: <Checker model={'glm-3-turbo'} provider={ModelProvider.ZhiPu} />,
37
+ desc: t('llm.checker.desc'),
38
+ label: t('llm.checker.title'),
39
+ minWidth: '100%',
40
+ },
41
+ ]}
42
+ provider={providerKey}
43
+ title={
65
44
  <Zhipu.Combine
66
45
  color={theme.isDarkMode ? lighten(0.1, Zhipu.colorPrimary) : Zhipu.colorPrimary}
67
46
  size={32}
68
47
  />
69
- </Flexbox>
70
- ),
71
- };
72
-
73
- return (
74
- <Form form={form} items={[model]} onValuesChange={debounce(setSettings, 100)} {...FORM_STYLE} />
48
+ }
49
+ />
75
50
  );
76
51
  });
77
52
 
@@ -0,0 +1,58 @@
1
+ import { Form, type ItemGroup } from '@lobehub/ui';
2
+ import type { FormItemProps } from '@lobehub/ui/es/Form/components/FormItem';
3
+ import { Form as AntForm, Switch } from 'antd';
4
+ import { debounce } from 'lodash-es';
5
+ import { ReactNode, memo } from 'react';
6
+
7
+ import { FORM_STYLE } from '@/const/layoutTokens';
8
+ import { useGlobalStore } from '@/store/global';
9
+ import { modelProviderSelectors } from '@/store/global/selectors';
10
+ import { GlobalLLMProviderKey } from '@/types/settings';
11
+
12
+ import { useSyncSettings } from './useSyncSettings';
13
+
14
+ interface ProviderConfigProps {
15
+ canDeactivate?: boolean;
16
+ configItems: FormItemProps[];
17
+ provider: GlobalLLMProviderKey;
18
+ title: ReactNode;
19
+ }
20
+
21
+ const ProviderConfig = memo<ProviderConfigProps>(
22
+ ({ provider, canDeactivate = true, title, configItems }) => {
23
+ const [form] = AntForm.useForm();
24
+ const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
25
+ s.toggleProviderEnabled,
26
+ s.setSettings,
27
+ ]);
28
+
29
+ const enabled = useGlobalStore(modelProviderSelectors.providerEnabled(provider));
30
+
31
+ useSyncSettings(form);
32
+
33
+ const model: ItemGroup = {
34
+ children: configItems,
35
+ defaultActive: canDeactivate ? enabled : undefined,
36
+ extra: canDeactivate ? (
37
+ <Switch
38
+ onChange={(enabled) => {
39
+ toggleProviderEnabled(provider, enabled);
40
+ }}
41
+ value={enabled}
42
+ />
43
+ ) : undefined,
44
+ title,
45
+ };
46
+
47
+ return (
48
+ <Form
49
+ form={form}
50
+ items={[model]}
51
+ onValuesChange={debounce(setSettings, 100)}
52
+ {...FORM_STYLE}
53
+ />
54
+ );
55
+ },
56
+ );
57
+
58
+ export default ProviderConfig;
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+
3
+ import Link from 'next/link';
4
+ import { memo } from 'react';
5
+ import { Trans, useTranslation } from 'react-i18next';
6
+
7
+ import PageTitle from '@/components/PageTitle';
8
+ import { MORE_MODEL_PROVIDER_REQUEST_URL } from '@/const/url';
9
+
10
+ import Footer from '../features/Footer';
11
+ import Bedrock from './Bedrock';
12
+ import Google from './Google';
13
+ import Moonshot from './Moonshot';
14
+ import Ollama from './Ollama';
15
+ import OpenAI from './OpenAI';
16
+ import Zhipu from './Zhipu';
17
+
18
+ export default memo<{ showOllama: boolean }>(({ showOllama }) => {
19
+ const { t } = useTranslation('setting');
20
+
21
+ return (
22
+ <>
23
+ <PageTitle title={t('tab.llm')} />
24
+ <OpenAI />
25
+ {/*<AzureOpenAI />*/}
26
+ <Zhipu />
27
+ <Moonshot />
28
+ <Google />
29
+ <Bedrock />
30
+ {showOllama && <Ollama />}
31
+ <Footer>
32
+ <Trans i18nKey="llm.waitingForMore" ns={'setting'}>
33
+ 更多模型正在
34
+ <Link aria-label={'todo'} href={MORE_MODEL_PROVIDER_REQUEST_URL} target="_blank">
35
+ 计划接入
36
+ </Link>
37
+ 中 ,敬请期待 ✨
38
+ </Trans>
39
+ </Footer>
40
+ </>
41
+ );
42
+ });
@@ -1 +1,9 @@
1
- export { default } from '../layout.server';
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ import { SettingsTabs } from '@/store/global/initialState';
4
+
5
+ import SettingLayout from '../layout.server';
6
+
7
+ export default ({ children }: PropsWithChildren) => {
8
+ return <SettingLayout activeTab={SettingsTabs.LLM}>{children}</SettingLayout>;
9
+ };
@@ -1,49 +1,9 @@
1
- 'use client';
1
+ import { getServerConfig } from '@/config/server';
2
2
 
3
- import Link from 'next/link';
4
- import { memo } from 'react';
5
- import { Trans, useTranslation } from 'react-i18next';
3
+ import Page from './index';
6
4
 
7
- import Footer from '@/app/settings/features/Footer';
8
- import PageTitle from '@/components/PageTitle';
9
- import { MORE_MODEL_PROVIDER_REQUEST_URL } from '@/const/url';
10
- import { useGlobalStore } from '@/store/global';
11
- import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
12
- import { SettingsTabs } from '@/store/global/initialState';
13
- import { modelProviderSelectors } from '@/store/global/selectors';
5
+ export default () => {
6
+ const { ENABLE_OLLAMA } = getServerConfig();
14
7
 
15
- import Bedrock from './Bedrock';
16
- import Google from './Google';
17
- import Moonshot from './Moonshot';
18
- import Ollama from './Ollama';
19
- import OpenAI from './OpenAI';
20
- import Zhipu from './Zhipu';
21
-
22
- export default memo(() => {
23
- useSwitchSideBarOnInit(SettingsTabs.LLM);
24
- const enableOllamaFormServerConfig = useGlobalStore(
25
- modelProviderSelectors.enableOllamaConfigInSettings,
26
- );
27
- const { t } = useTranslation('setting');
28
- return (
29
- <>
30
- <PageTitle title={t('tab.llm')} />
31
- <OpenAI />
32
- {/*<AzureOpenAI />*/}
33
- <Zhipu />
34
- <Moonshot />
35
- <Google />
36
- <Bedrock />
37
- {enableOllamaFormServerConfig && <Ollama />}
38
- <Footer>
39
- <Trans i18nKey="llm.waitingForMore" ns={'setting'}>
40
- 更多模型正在
41
- <Link aria-label={'todo'} href={MORE_MODEL_PROVIDER_REQUEST_URL} target="_blank">
42
- 计划接入
43
- </Link>
44
- 中 ,敬请期待 ✨
45
- </Trans>
46
- </Footer>
47
- </>
48
- );
49
- });
8
+ return <Page showOllama={ENABLE_OLLAMA} />;
9
+ };
@@ -1 +1,9 @@
1
- export { default } from '../layout.server';
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ import { SettingsTabs } from '@/store/global/initialState';
4
+
5
+ import SettingLayout from '../layout.server';
6
+
7
+ export default ({ children }: PropsWithChildren) => {
8
+ return <SettingLayout activeTab={SettingsTabs.TTS}>{children}</SettingLayout>;
9
+ };
@@ -1,3 +1,18 @@
1
- import Index from './index';
1
+ 'use client';
2
2
 
3
- export default () => <Index />;
3
+ import { memo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+
6
+ import PageTitle from '@/components/PageTitle';
7
+
8
+ import TTS from './TTS';
9
+
10
+ export default memo(() => {
11
+ const { t } = useTranslation('setting');
12
+ return (
13
+ <>
14
+ <PageTitle title={t('tab.llm')} />
15
+ <TTS />
16
+ </>
17
+ );
18
+ });
@@ -72,6 +72,7 @@ export const DEFAULT_LLM_CONFIG: GlobalLLMConfig = {
72
72
  },
73
73
  openAI: {
74
74
  OPENAI_API_KEY: '',
75
+ enabled: true,
75
76
  models: [],
76
77
  },
77
78
  zhipu: {
@@ -20,7 +20,7 @@ import { ABOUT, CHANGELOG, DISCORD, FEEDBACK, GITHUB, WIKI } from '@/const/url';
20
20
  import DataImporter from '@/features/DataImporter';
21
21
  import { configService } from '@/services/config';
22
22
  import { GlobalStore, useGlobalStore } from '@/store/global';
23
- import { SettingsTabs, SidebarTabKey } from '@/store/global/initialState';
23
+ import { SidebarTabKey } from '@/store/global/initialState';
24
24
 
25
25
  export interface BottomActionProps {
26
26
  setTab: GlobalStore['switchSideBar'];
@@ -115,7 +115,6 @@ const BottomActions = memo<BottomActionProps>(({ tab, setTab }) => {
115
115
  onClick: () => {
116
116
  setTab(SidebarTabKey.Setting);
117
117
  useGlobalStore.setState({
118
- settingsTab: SettingsTabs.Common,
119
118
  sidebarKey: SidebarTabKey.Setting,
120
119
  });
121
120
  router.push('/settings/common');