@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.
- package/CHANGELOG.md +25 -0
- package/package.json +1 -1
- package/src/app/chat/features/ChatHeader/SettingButton.tsx +1 -2
- 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 -6
- 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 -4
- 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/SideBar/BottomActions.tsx +1 -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/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/app/settings/llm/{Checker.tsx → components/Checker.tsx} +0 -0
- /package/src/app/settings/llm/{useSyncSettings.ts → components/ProviderConfig/useSyncSettings.ts} +0 -0
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { Azure, OpenAI } from '@lobehub/icons';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Markdown } from '@lobehub/ui';
|
|
3
|
+
import { AutoComplete, Divider, Input } 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
7
|
import { Flexbox } from 'react-layout-kit';
|
|
9
8
|
|
|
10
|
-
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
11
9
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
12
|
-
import { useGlobalStore } from '@/store/global';
|
|
13
|
-
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
14
10
|
|
|
15
|
-
import Checker from '../Checker';
|
|
11
|
+
import Checker from '../components/Checker';
|
|
12
|
+
import ProviderConfig from '../components/ProviderConfig';
|
|
16
13
|
import { LLMProviderApiTokenKey, LLMProviderBaseUrlKey, LLMProviderConfigKey } from '../const';
|
|
17
|
-
import { useSyncSettings } from '../useSyncSettings';
|
|
18
14
|
|
|
19
15
|
const useStyles = createStyles(({ css, token }) => ({
|
|
20
16
|
markdown: css`
|
|
@@ -37,107 +33,83 @@ const providerKey = 'azure';
|
|
|
37
33
|
|
|
38
34
|
const AzureOpenAIProvider = memo(() => {
|
|
39
35
|
const { t } = useTranslation('setting');
|
|
40
|
-
const [form] = AntForm.useForm();
|
|
41
|
-
const { styles } = useStyles();
|
|
42
|
-
|
|
43
|
-
const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
|
|
44
|
-
s.toggleProviderEnabled,
|
|
45
|
-
s.setSettings,
|
|
46
|
-
]);
|
|
47
|
-
|
|
48
|
-
const enabled = useGlobalStore(modelProviderSelectors.enableAzure);
|
|
49
|
-
|
|
50
|
-
useSyncSettings(form);
|
|
51
36
|
|
|
52
|
-
const
|
|
53
|
-
children: [
|
|
54
|
-
{
|
|
55
|
-
children: (
|
|
56
|
-
<Input.Password
|
|
57
|
-
autoComplete={'new-password'}
|
|
58
|
-
placeholder={t('llm.AzureOpenAI.token.placeholder')}
|
|
59
|
-
/>
|
|
60
|
-
),
|
|
61
|
-
desc: t('llm.AzureOpenAI.token.desc'),
|
|
62
|
-
label: t('llm.AzureOpenAI.token.title'),
|
|
63
|
-
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
children: <Input allowClear placeholder={t('llm.AzureOpenAI.endpoint.placeholder')} />,
|
|
67
|
-
desc: t('llm.AzureOpenAI.endpoint.desc'),
|
|
68
|
-
label: t('llm.AzureOpenAI.endpoint.title'),
|
|
69
|
-
name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
children: (
|
|
73
|
-
<AutoComplete
|
|
74
|
-
options={[
|
|
75
|
-
'2023-12-01-preview',
|
|
76
|
-
'2023-08-01-preview',
|
|
77
|
-
'2023-07-01-preview',
|
|
78
|
-
'2023-06-01-preview',
|
|
79
|
-
'2023-03-15-preview',
|
|
80
|
-
].map((i) => ({
|
|
81
|
-
label: i,
|
|
82
|
-
value: i,
|
|
83
|
-
}))}
|
|
84
|
-
placeholder={'20XX-XX-XX'}
|
|
85
|
-
/>
|
|
86
|
-
),
|
|
87
|
-
desc: (
|
|
88
|
-
<Markdown className={styles.markdown}>
|
|
89
|
-
{t('llm.AzureOpenAI.azureApiVersion.desc')}
|
|
90
|
-
</Markdown>
|
|
91
|
-
),
|
|
92
|
-
label: t('llm.AzureOpenAI.azureApiVersion.title'),
|
|
93
|
-
name: [LLMProviderConfigKey, providerKey, 'apiVersion'],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
children: (
|
|
97
|
-
<Input.TextArea
|
|
98
|
-
allowClear
|
|
99
|
-
placeholder={'gpt-35-16k,my-gpt=gpt-35-turbo'}
|
|
100
|
-
style={{ height: 100 }}
|
|
101
|
-
/>
|
|
102
|
-
),
|
|
103
|
-
desc: (
|
|
104
|
-
<Markdown className={styles.markdown}>{t('llm.AzureOpenAI.deployments.desc')}</Markdown>
|
|
105
|
-
),
|
|
106
|
-
|
|
107
|
-
label: t('llm.AzureOpenAI.deployments.title'),
|
|
108
|
-
name: [LLMProviderConfigKey, providerKey, 'deployments'],
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
children: <Checker model={'gpt-3.5-turbo'} provider={ModelProvider.Azure} />,
|
|
112
|
-
desc: t('llm.checker.desc'),
|
|
113
|
-
label: t('llm.checker.title'),
|
|
114
|
-
minWidth: undefined,
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
defaultActive: enabled,
|
|
118
|
-
extra: (
|
|
119
|
-
<Switch
|
|
120
|
-
onChange={(enabled) => {
|
|
121
|
-
toggleProviderEnabled(providerKey, enabled);
|
|
122
|
-
}}
|
|
123
|
-
value={enabled}
|
|
124
|
-
/>
|
|
125
|
-
),
|
|
126
|
-
title: (
|
|
127
|
-
<Flexbox align={'center'} gap={8} horizontal>
|
|
128
|
-
<Azure.Combine size={24} type={'color'}></Azure.Combine>
|
|
129
|
-
<Divider style={{ margin: '0 4px' }} type={'vertical'} />
|
|
130
|
-
<OpenAI.Combine size={24}></OpenAI.Combine>
|
|
131
|
-
</Flexbox>
|
|
132
|
-
),
|
|
133
|
-
};
|
|
37
|
+
const { styles } = useStyles();
|
|
134
38
|
|
|
135
39
|
return (
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
40
|
+
<ProviderConfig
|
|
41
|
+
configItems={[
|
|
42
|
+
{
|
|
43
|
+
children: (
|
|
44
|
+
<Input.Password
|
|
45
|
+
autoComplete={'new-password'}
|
|
46
|
+
placeholder={t('llm.AzureOpenAI.token.placeholder')}
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
desc: t('llm.AzureOpenAI.token.desc'),
|
|
50
|
+
label: t('llm.AzureOpenAI.token.title'),
|
|
51
|
+
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
children: <Input allowClear placeholder={t('llm.AzureOpenAI.endpoint.placeholder')} />,
|
|
55
|
+
desc: t('llm.AzureOpenAI.endpoint.desc'),
|
|
56
|
+
label: t('llm.AzureOpenAI.endpoint.title'),
|
|
57
|
+
name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
children: (
|
|
61
|
+
<AutoComplete
|
|
62
|
+
options={[
|
|
63
|
+
'2023-12-01-preview',
|
|
64
|
+
'2023-08-01-preview',
|
|
65
|
+
'2023-07-01-preview',
|
|
66
|
+
'2023-06-01-preview',
|
|
67
|
+
'2023-03-15-preview',
|
|
68
|
+
].map((i) => ({
|
|
69
|
+
label: i,
|
|
70
|
+
value: i,
|
|
71
|
+
}))}
|
|
72
|
+
placeholder={'20XX-XX-XX'}
|
|
73
|
+
/>
|
|
74
|
+
),
|
|
75
|
+
desc: (
|
|
76
|
+
<Markdown className={styles.markdown}>
|
|
77
|
+
{t('llm.AzureOpenAI.azureApiVersion.desc')}
|
|
78
|
+
</Markdown>
|
|
79
|
+
),
|
|
80
|
+
label: t('llm.AzureOpenAI.azureApiVersion.title'),
|
|
81
|
+
name: [LLMProviderConfigKey, providerKey, 'apiVersion'],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
children: (
|
|
85
|
+
<Input.TextArea
|
|
86
|
+
allowClear
|
|
87
|
+
placeholder={'gpt-35-16k,my-gpt=gpt-35-turbo'}
|
|
88
|
+
style={{ height: 100 }}
|
|
89
|
+
/>
|
|
90
|
+
),
|
|
91
|
+
desc: (
|
|
92
|
+
<Markdown className={styles.markdown}>{t('llm.AzureOpenAI.deployments.desc')}</Markdown>
|
|
93
|
+
),
|
|
94
|
+
|
|
95
|
+
label: t('llm.AzureOpenAI.deployments.title'),
|
|
96
|
+
name: [LLMProviderConfigKey, providerKey, 'deployments'],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
children: <Checker model={'gpt-3.5-turbo'} provider={ModelProvider.Azure} />,
|
|
100
|
+
desc: t('llm.checker.desc'),
|
|
101
|
+
label: t('llm.checker.title'),
|
|
102
|
+
minWidth: undefined,
|
|
103
|
+
},
|
|
104
|
+
]}
|
|
105
|
+
provider={providerKey}
|
|
106
|
+
title={
|
|
107
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
|
108
|
+
<Azure.Combine size={24} type={'color'}></Azure.Combine>
|
|
109
|
+
<Divider style={{ margin: '0 4px' }} type={'vertical'} />
|
|
110
|
+
<OpenAI.Combine size={24}></OpenAI.Combine>
|
|
111
|
+
</Flexbox>
|
|
112
|
+
}
|
|
141
113
|
/>
|
|
142
114
|
);
|
|
143
115
|
});
|
|
@@ -1,108 +1,79 @@
|
|
|
1
1
|
import { Aws, Bedrock } from '@lobehub/icons';
|
|
2
|
-
import {
|
|
3
|
-
import { Form as AntForm, Divider, Input, Select, Switch } from 'antd';
|
|
4
|
-
import { debounce } from 'lodash-es';
|
|
2
|
+
import { Divider, Input, Select } from 'antd';
|
|
5
3
|
import { memo } from 'react';
|
|
6
4
|
import { useTranslation } from 'react-i18next';
|
|
7
5
|
import { Flexbox } from 'react-layout-kit';
|
|
8
6
|
|
|
9
|
-
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
10
7
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
11
|
-
import { useGlobalStore } from '@/store/global';
|
|
12
|
-
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
13
8
|
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
14
9
|
|
|
15
|
-
import Checker from '../Checker';
|
|
10
|
+
import Checker from '../components/Checker';
|
|
11
|
+
import ProviderConfig from '../components/ProviderConfig';
|
|
16
12
|
import { LLMProviderConfigKey } from '../const';
|
|
17
|
-
import { useSyncSettings } from '../useSyncSettings';
|
|
18
13
|
|
|
19
14
|
const providerKey: GlobalLLMProviderKey = 'bedrock';
|
|
20
15
|
|
|
21
16
|
const BedrockProvider = memo(() => {
|
|
22
17
|
const { t } = useTranslation('setting');
|
|
23
|
-
const [form] = AntForm.useForm();
|
|
24
|
-
const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
|
|
25
|
-
s.toggleProviderEnabled,
|
|
26
|
-
s.setSettings,
|
|
27
|
-
]);
|
|
28
|
-
const enabled = useGlobalStore(modelProviderSelectors.enableBedrock);
|
|
29
|
-
|
|
30
|
-
useSyncSettings(form);
|
|
31
|
-
|
|
32
|
-
const model: ItemGroup = {
|
|
33
|
-
children: [
|
|
34
|
-
{
|
|
35
|
-
children: (
|
|
36
|
-
<Input.Password
|
|
37
|
-
autoComplete={'new-password'}
|
|
38
|
-
placeholder={t('llm.Bedrock.accessKeyId.placeholder')}
|
|
39
|
-
/>
|
|
40
|
-
),
|
|
41
|
-
desc: t('llm.Bedrock.accessKeyId.desc'),
|
|
42
|
-
label: t('llm.Bedrock.accessKeyId.title'),
|
|
43
|
-
name: [LLMProviderConfigKey, providerKey, 'accessKeyId'],
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
children: (
|
|
47
|
-
<Input.Password
|
|
48
|
-
autoComplete={'new-password'}
|
|
49
|
-
placeholder={t('llm.Bedrock.secretAccessKey.placeholder')}
|
|
50
|
-
/>
|
|
51
|
-
),
|
|
52
|
-
desc: t('llm.Bedrock.secretAccessKey.desc'),
|
|
53
|
-
label: t('llm.Bedrock.secretAccessKey.title'),
|
|
54
|
-
name: [LLMProviderConfigKey, providerKey, 'secretAccessKey'],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
children: (
|
|
58
|
-
<Select
|
|
59
|
-
allowClear
|
|
60
|
-
options={['us-east-1', 'us-west-2', 'ap-southeast-1'].map((i) => ({
|
|
61
|
-
label: i,
|
|
62
|
-
value: i,
|
|
63
|
-
}))}
|
|
64
|
-
placeholder={'us-east-1'}
|
|
65
|
-
/>
|
|
66
|
-
),
|
|
67
|
-
desc: t('llm.Bedrock.region.desc'),
|
|
68
|
-
label: t('llm.Bedrock.region.title'),
|
|
69
|
-
name: [LLMProviderConfigKey, providerKey, 'region'],
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
children: (
|
|
73
|
-
<Checker model={'anthropic.claude-instant-v1'} provider={ModelProvider.Bedrock} />
|
|
74
|
-
),
|
|
75
|
-
desc: t('llm.Bedrock.checker.desc'),
|
|
76
|
-
label: t('llm.checker.title'),
|
|
77
|
-
minWidth: '100%',
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
defaultActive: enabled,
|
|
81
|
-
extra: (
|
|
82
|
-
<div
|
|
83
|
-
onClick={(e) => {
|
|
84
|
-
e.stopPropagation();
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
<Switch
|
|
88
|
-
onChange={(enabled) => {
|
|
89
|
-
toggleProviderEnabled(providerKey, enabled);
|
|
90
|
-
}}
|
|
91
|
-
value={enabled}
|
|
92
|
-
/>
|
|
93
|
-
</div>
|
|
94
|
-
),
|
|
95
|
-
title: (
|
|
96
|
-
<Flexbox align={'center'} gap={8} horizontal>
|
|
97
|
-
<Aws.Color size={32} />
|
|
98
|
-
<Divider style={{ margin: '0 4px' }} type={'vertical'} />
|
|
99
|
-
<Bedrock.Combine size={24} type={'color'} />
|
|
100
|
-
</Flexbox>
|
|
101
|
-
),
|
|
102
|
-
};
|
|
103
18
|
|
|
104
19
|
return (
|
|
105
|
-
<
|
|
20
|
+
<ProviderConfig
|
|
21
|
+
configItems={[
|
|
22
|
+
{
|
|
23
|
+
children: (
|
|
24
|
+
<Input.Password
|
|
25
|
+
autoComplete={'new-password'}
|
|
26
|
+
placeholder={t('llm.Bedrock.accessKeyId.placeholder')}
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
29
|
+
desc: t('llm.Bedrock.accessKeyId.desc'),
|
|
30
|
+
label: t('llm.Bedrock.accessKeyId.title'),
|
|
31
|
+
name: [LLMProviderConfigKey, providerKey, 'accessKeyId'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
children: (
|
|
35
|
+
<Input.Password
|
|
36
|
+
autoComplete={'new-password'}
|
|
37
|
+
placeholder={t('llm.Bedrock.secretAccessKey.placeholder')}
|
|
38
|
+
/>
|
|
39
|
+
),
|
|
40
|
+
desc: t('llm.Bedrock.secretAccessKey.desc'),
|
|
41
|
+
label: t('llm.Bedrock.secretAccessKey.title'),
|
|
42
|
+
name: [LLMProviderConfigKey, providerKey, 'secretAccessKey'],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
children: (
|
|
46
|
+
<Select
|
|
47
|
+
allowClear
|
|
48
|
+
options={['us-east-1', 'us-west-2', 'ap-southeast-1'].map((i) => ({
|
|
49
|
+
label: i,
|
|
50
|
+
value: i,
|
|
51
|
+
}))}
|
|
52
|
+
placeholder={'us-east-1'}
|
|
53
|
+
/>
|
|
54
|
+
),
|
|
55
|
+
desc: t('llm.Bedrock.region.desc'),
|
|
56
|
+
label: t('llm.Bedrock.region.title'),
|
|
57
|
+
name: [LLMProviderConfigKey, providerKey, 'region'],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
children: (
|
|
61
|
+
<Checker model={'anthropic.claude-instant-v1'} provider={ModelProvider.Bedrock} />
|
|
62
|
+
),
|
|
63
|
+
desc: t('llm.Bedrock.checker.desc'),
|
|
64
|
+
label: t('llm.checker.title'),
|
|
65
|
+
minWidth: '100%',
|
|
66
|
+
},
|
|
67
|
+
]}
|
|
68
|
+
provider={providerKey}
|
|
69
|
+
title={
|
|
70
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
|
71
|
+
<Aws.Color size={32} />
|
|
72
|
+
<Divider style={{ margin: '0 4px' }} type={'vertical'} />
|
|
73
|
+
<Bedrock.Combine size={24} type={'color'} />
|
|
74
|
+
</Flexbox>
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
106
77
|
);
|
|
107
78
|
});
|
|
108
79
|
|
|
@@ -1,73 +1,44 @@
|
|
|
1
1
|
import { Google } from '@lobehub/icons';
|
|
2
|
-
import {
|
|
3
|
-
import { Form as AntForm, Input, Switch } from 'antd';
|
|
4
|
-
import { debounce } from 'lodash-es';
|
|
2
|
+
import { Input } from 'antd';
|
|
5
3
|
import { memo } from 'react';
|
|
6
4
|
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import { Flexbox } from 'react-layout-kit';
|
|
8
5
|
|
|
9
|
-
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
10
6
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
11
|
-
import { useGlobalStore } from '@/store/global';
|
|
12
|
-
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
13
7
|
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
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: GlobalLLMProviderKey = 'google';
|
|
20
14
|
|
|
21
15
|
const GoogleProvider = memo(() => {
|
|
22
16
|
const { t } = useTranslation('setting');
|
|
23
|
-
const [form] = AntForm.useForm();
|
|
24
|
-
useSyncSettings(form);
|
|
25
|
-
|
|
26
|
-
const [toggleProviderEnabled, setSettings] = useGlobalStore((s) => [
|
|
27
|
-
s.toggleProviderEnabled,
|
|
28
|
-
s.setSettings,
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
const enabled = useGlobalStore(modelProviderSelectors.enableGoogle);
|
|
32
|
-
|
|
33
|
-
const model: ItemGroup = {
|
|
34
|
-
children: [
|
|
35
|
-
{
|
|
36
|
-
children: (
|
|
37
|
-
<Input.Password
|
|
38
|
-
autoComplete={'new-password'}
|
|
39
|
-
placeholder={t('llm.Google.token.placeholder')}
|
|
40
|
-
/>
|
|
41
|
-
),
|
|
42
|
-
desc: t('llm.Google.token.desc'),
|
|
43
|
-
label: t('llm.Google.token.title'),
|
|
44
|
-
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
children: <Checker model={'gemini-pro'} provider={ModelProvider.Google} />,
|
|
48
|
-
desc: t('llm.checker.desc'),
|
|
49
|
-
label: t('llm.checker.title'),
|
|
50
|
-
minWidth: '100%',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
defaultActive: enabled,
|
|
54
|
-
extra: (
|
|
55
|
-
<Switch
|
|
56
|
-
onChange={(enabled) => {
|
|
57
|
-
toggleProviderEnabled(providerKey, enabled);
|
|
58
|
-
}}
|
|
59
|
-
value={enabled}
|
|
60
|
-
/>
|
|
61
|
-
),
|
|
62
|
-
title: (
|
|
63
|
-
<Flexbox align={'center'} gap={8} horizontal>
|
|
64
|
-
<Google.BrandColor size={28} />
|
|
65
|
-
</Flexbox>
|
|
66
|
-
),
|
|
67
|
-
};
|
|
68
17
|
|
|
69
18
|
return (
|
|
70
|
-
<
|
|
19
|
+
<ProviderConfig
|
|
20
|
+
configItems={[
|
|
21
|
+
{
|
|
22
|
+
children: (
|
|
23
|
+
<Input.Password
|
|
24
|
+
autoComplete={'new-password'}
|
|
25
|
+
placeholder={t('llm.Google.token.placeholder')}
|
|
26
|
+
/>
|
|
27
|
+
),
|
|
28
|
+
desc: t('llm.Google.token.desc'),
|
|
29
|
+
label: t('llm.Google.token.title'),
|
|
30
|
+
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
children: <Checker model={'gemini-pro'} provider={ModelProvider.Google} />,
|
|
34
|
+
desc: t('llm.checker.desc'),
|
|
35
|
+
label: t('llm.checker.title'),
|
|
36
|
+
minWidth: '100%',
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
provider={providerKey}
|
|
40
|
+
title={<Google.BrandColor size={28} />}
|
|
41
|
+
/>
|
|
71
42
|
);
|
|
72
43
|
});
|
|
73
44
|
|
|
@@ -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
|
|