@lobehub/chat 0.127.0 → 0.127.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +8 -8
- package/README.zh-CN.md +8 -8
- package/package.json +1 -1
- package/src/app/chat/(desktop)/layout.desktop.tsx +1 -3
- package/src/app/chat/(mobile)/index.tsx +2 -5
- package/src/app/chat/features/ChatHeader/SettingButton.tsx +1 -2
- package/src/app/home/Redirect.tsx +0 -4
- package/src/app/market/(desktop)/layout.desktop.tsx +1 -4
- package/src/app/market/(mobile)/layout.mobile.tsx +1 -4
- package/src/app/market/features/AgentDetailContent/AgentInfo/Header.tsx +0 -4
- package/src/app/settings/(desktop)/features/Header.tsx +3 -4
- package/src/app/settings/(desktop)/features/SideBar.tsx +42 -0
- package/src/app/settings/(desktop)/index.tsx +4 -3
- package/src/app/settings/(desktop)/layout.desktop.tsx +14 -9
- package/src/app/settings/(desktop)/layout.responsive.tsx +4 -4
- package/src/app/settings/(mobile)/features/ExtraList.tsx +7 -5
- package/src/app/settings/(mobile)/features/Header/index.tsx +8 -5
- package/src/app/settings/(mobile)/index.tsx +1 -3
- package/src/app/settings/(mobile)/layout.mobile.tsx +8 -6
- package/src/app/settings/(mobile)/mobile/index.tsx +3 -5
- package/src/app/settings/agent/Agent.tsx +0 -4
- package/src/app/settings/agent/layout.tsx +9 -1
- package/src/app/settings/agent/page.tsx +17 -2
- package/src/app/settings/common/index.tsx +0 -3
- package/src/app/settings/common/layout.tsx +9 -1
- package/src/app/settings/features/SettingList/Item.tsx +50 -0
- package/src/app/settings/features/{SideBar/List.tsx → SettingList/index.tsx} +14 -15
- package/src/app/settings/layout.server.tsx +10 -3
- package/src/app/settings/llm/Azure/index.tsx +78 -106
- package/src/app/settings/llm/Bedrock/index.tsx +60 -89
- package/src/app/settings/llm/Google/index.tsx +26 -55
- package/src/app/settings/llm/Moonshot/index.tsx +29 -54
- package/src/app/settings/llm/Ollama/index.tsx +35 -61
- package/src/app/settings/llm/OpenAI/index.tsx +91 -107
- package/src/app/settings/llm/Zhipu/index.tsx +29 -54
- package/src/app/settings/llm/components/ProviderConfig/index.tsx +58 -0
- package/src/app/settings/llm/index.tsx +42 -0
- package/src/app/settings/llm/layout.tsx +9 -1
- package/src/app/settings/llm/page.tsx +6 -46
- package/src/app/settings/tts/layout.tsx +9 -1
- package/src/app/settings/tts/page.tsx +17 -2
- package/src/const/settings.ts +1 -0
- package/src/features/MobileTabBar/index.tsx +7 -14
- package/src/features/SideBar/BottomActions.tsx +3 -9
- package/src/features/SideBar/TopActions.tsx +2 -7
- package/src/features/SideBar/index.tsx +7 -5
- package/src/layout/AppLayout.desktop.tsx +8 -3
- package/src/layout/AppLayout.mobile.tsx +4 -2
- package/src/layout/ResponsiveLayout.client.tsx +7 -7
- package/src/layout/ResponsiveLayout.server.tsx +6 -6
- package/src/services/_auth.test.ts +132 -0
- package/src/services/_auth.ts +1 -1
- package/src/store/global/hooks/index.ts +1 -1
- package/src/store/global/slices/common/action.test.ts +0 -12
- package/src/store/global/slices/common/action.ts +1 -6
- package/src/store/global/slices/common/initialState.ts +0 -2
- package/src/store/global/slices/settings/action.test.ts +0 -13
- package/src/store/global/slices/settings/action.ts +0 -5
- package/src/store/global/slices/settings/selectors/modelProvider.ts +7 -0
- package/src/types/settings/modelProvider.ts +1 -0
- package/src/app/settings/agent/index.tsx +0 -21
- package/src/app/settings/features/SideBar/Item.tsx +0 -44
- package/src/app/settings/features/SideBar/index.tsx +0 -42
- package/src/app/settings/tts/index.tsx +0 -21
- package/src/store/global/hooks/useSwitchSettingsOnInit.ts +0 -12
- package/src/store/global/hooks/useSwitchSideBarOnInit.ts +0 -13
- /package/src/app/settings/llm/{Checker.tsx → components/Checker.tsx} +0 -0
- /package/src/app/settings/llm/{useSyncSettings.ts → components/ProviderConfig/useSyncSettings.ts} +0 -0
|
@@ -1,76 +1,51 @@
|
|
|
1
1
|
import { Moonshot } from '@lobehub/icons';
|
|
2
|
-
import {
|
|
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 { LLMProviderApiTokenKey, LLMProviderConfigKey } from '../const';
|
|
17
|
-
import { useSyncSettings } from '../useSyncSettings';
|
|
18
12
|
|
|
19
13
|
const providerKey = 'moonshot';
|
|
20
14
|
|
|
21
15
|
const MoonshotProvider = memo(() => {
|
|
22
16
|
const { t } = useTranslation('setting');
|
|
23
|
-
const [form] = AntForm.useForm();
|
|
24
|
-
const theme = useTheme();
|
|
25
|
-
const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
|
|
26
|
-
s.toggleProviderEnabled,
|
|
27
|
-
s.setSettings,
|
|
28
|
-
]);
|
|
29
|
-
const enabled = useGlobalStore(modelProviderSelectors.enableMoonshot);
|
|
30
17
|
|
|
31
|
-
|
|
18
|
+
const theme = useTheme();
|
|
32
19
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
onChange={(enabled) => {
|
|
57
|
-
toggleProviderEnabled(providerKey, enabled);
|
|
58
|
-
}}
|
|
59
|
-
value={enabled}
|
|
60
|
-
/>
|
|
61
|
-
),
|
|
62
|
-
title: (
|
|
63
|
-
<Flexbox align={'center'} gap={8} horizontal>
|
|
20
|
+
return (
|
|
21
|
+
<ProviderConfig
|
|
22
|
+
configItems={[
|
|
23
|
+
{
|
|
24
|
+
children: (
|
|
25
|
+
<Input.Password
|
|
26
|
+
autoComplete={'new-password'}
|
|
27
|
+
placeholder={t('llm.Moonshot.token.placeholder')}
|
|
28
|
+
/>
|
|
29
|
+
),
|
|
30
|
+
desc: t('llm.Moonshot.token.desc'),
|
|
31
|
+
label: t('llm.Moonshot.token.title'),
|
|
32
|
+
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
children: <Checker model={'moonshot-v1-8k'} provider={ModelProvider.Moonshot} />,
|
|
36
|
+
desc: t('llm.checker.desc'),
|
|
37
|
+
label: t('llm.checker.title'),
|
|
38
|
+
minWidth: '100%',
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
provider={providerKey}
|
|
42
|
+
title={
|
|
64
43
|
<Moonshot.Combine
|
|
65
44
|
color={theme.isDarkMode ? theme.colorText : Moonshot.colorPrimary}
|
|
66
45
|
size={24}
|
|
67
46
|
/>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<Form form={form} items={[model]} onValuesChange={debounce(setSettings, 100)} {...FORM_STYLE} />
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
74
49
|
);
|
|
75
50
|
});
|
|
76
51
|
|
|
@@ -1,80 +1,54 @@
|
|
|
1
1
|
import { Ollama } from '@lobehub/icons';
|
|
2
|
-
import {
|
|
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
|
-
<
|
|
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 {
|
|
3
|
-
import {
|
|
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
|
|
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
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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 {
|
|
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
|
-
|
|
19
|
+
const theme = useTheme();
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
};
|