@lobehub/chat 1.47.4 → 1.47.6
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/changelog/v1.json +18 -0
- package/package.json +1 -1
- package/src/app/(main)/settings/provider/(detail)/[id]/index.tsx +8 -2
- package/src/app/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +6 -50
- package/src/app/(main)/settings/provider/(list)/ProviderGrid/style.ts +50 -0
- package/src/app/(main)/settings/provider/ProviderMenu/Item.tsx +11 -2
- package/src/app/(main)/settings/provider/features/ProviderConfig/EnableSwitch.tsx +46 -0
- package/src/app/(main)/settings/provider/features/ProviderConfig/index.tsx +2 -13
- package/src/types/llm.ts +4 -2
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.47.6](https://github.com/lobehub/lobe-chat/compare/v1.47.5...v1.47.6)
|
6
|
+
|
7
|
+
<sup>Released on **2025-01-20**</sup>
|
8
|
+
|
9
|
+
#### ♻ Code Refactoring
|
10
|
+
|
11
|
+
- **misc**: Refactor provider code.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Code refactoring
|
19
|
+
|
20
|
+
- **misc**: Refactor provider code, closes [#5516](https://github.com/lobehub/lobe-chat/issues/5516) ([fa1a07f](https://github.com/lobehub/lobe-chat/commit/fa1a07f))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.47.5](https://github.com/lobehub/lobe-chat/compare/v1.47.4...v1.47.5)
|
31
|
+
|
32
|
+
<sup>Released on **2025-01-20**</sup>
|
33
|
+
|
34
|
+
#### ♻ Code Refactoring
|
35
|
+
|
36
|
+
- **misc**: Improve ai provider code.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### Code refactoring
|
44
|
+
|
45
|
+
- **misc**: Improve ai provider code, closes [#5514](https://github.com/lobehub/lobe-chat/issues/5514) ([92789cd](https://github.com/lobehub/lobe-chat/commit/92789cd))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.47.4](https://github.com/lobehub/lobe-chat/compare/v1.47.3...v1.47.4)
|
6
56
|
|
7
57
|
<sup>Released on **2025-01-18**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"improvements": [
|
5
|
+
"Refactor provider code."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-01-20",
|
9
|
+
"version": "1.47.6"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"improvements": [
|
14
|
+
"Improve ai provider code."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2025-01-20",
|
18
|
+
"version": "1.47.5"
|
19
|
+
},
|
2
20
|
{
|
3
21
|
"children": {},
|
4
22
|
"date": "2025-01-18",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.47.
|
3
|
+
"version": "1.47.6",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -6,10 +6,16 @@ import { Flexbox } from 'react-layout-kit';
|
|
6
6
|
import ModelList from '../../features/ModelList';
|
7
7
|
import ProviderConfig, { ProviderConfigProps } from '../../features/ProviderConfig';
|
8
8
|
|
9
|
-
|
9
|
+
interface ProviderDetailProps extends ProviderConfigProps {
|
10
|
+
showConfig?: boolean;
|
11
|
+
}
|
12
|
+
const ProviderDetail = memo<ProviderDetailProps>(({ showConfig = true, ...card }) => {
|
10
13
|
return (
|
11
14
|
<Flexbox gap={24} paddingBlock={8}>
|
12
|
-
|
15
|
+
{/* ↓ cloud slot ↓ */}
|
16
|
+
|
17
|
+
{/* ↑ cloud slot ↑ */}
|
18
|
+
{showConfig && <ProviderConfig {...card} />}
|
13
19
|
<ModelList id={card.id} />
|
14
20
|
</Flexbox>
|
15
21
|
);
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { ProviderCombine, ProviderIcon } from '@lobehub/icons';
|
2
2
|
import { Avatar } from '@lobehub/ui';
|
3
3
|
import { Divider, Skeleton, Typography } from 'antd';
|
4
|
-
import { createStyles } from 'antd-style';
|
5
4
|
import Link from 'next/link';
|
6
5
|
import { memo } from 'react';
|
7
6
|
import { useTranslation } from 'react-i18next';
|
@@ -11,56 +10,9 @@ import InstantSwitch from '@/components/InstantSwitch';
|
|
11
10
|
import { useAiInfraStore } from '@/store/aiInfra';
|
12
11
|
import { AiProviderListItem } from '@/types/aiProvider';
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
17
|
-
banner: css`
|
18
|
-
opacity: ${isDarkMode ? 0.9 : 0.4};
|
19
|
-
`,
|
20
|
-
container: css`
|
21
|
-
position: relative;
|
22
|
-
|
23
|
-
overflow: hidden;
|
24
|
-
|
25
|
-
height: 100%;
|
26
|
-
border-radius: 12px;
|
27
|
-
|
28
|
-
background: ${token.colorBgContainer};
|
29
|
-
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillQuaternary : token.colorFillSecondary}
|
30
|
-
inset;
|
13
|
+
import { useStyles } from './style';
|
31
14
|
|
32
|
-
|
33
|
-
|
34
|
-
&:hover {
|
35
|
-
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillSecondary : token.colorFill} inset;
|
36
|
-
}
|
37
|
-
`,
|
38
|
-
desc: css`
|
39
|
-
min-height: 44px;
|
40
|
-
margin-block-end: 0 !important;
|
41
|
-
color: ${token.colorTextDescription};
|
42
|
-
`,
|
43
|
-
tagBlue: css`
|
44
|
-
color: ${token.geekblue};
|
45
|
-
background: ${token.geekblue1};
|
46
|
-
`,
|
47
|
-
tagGreen: css`
|
48
|
-
color: ${token.green};
|
49
|
-
background: ${token.green1};
|
50
|
-
`,
|
51
|
-
time: css`
|
52
|
-
color: ${token.colorTextDescription};
|
53
|
-
`,
|
54
|
-
title: css`
|
55
|
-
zoom: 1.2;
|
56
|
-
margin-block-end: 0 !important;
|
57
|
-
font-size: 18px !important;
|
58
|
-
font-weight: bold;
|
59
|
-
`,
|
60
|
-
token: css`
|
61
|
-
font-family: ${token.fontFamilyCode};
|
62
|
-
`,
|
63
|
-
}));
|
15
|
+
const { Paragraph } = Typography;
|
64
16
|
|
65
17
|
interface ProviderCardProps extends AiProviderListItem {
|
66
18
|
loading?: boolean;
|
@@ -78,6 +30,10 @@ const ProviderCard = memo<ProviderCardProps>(
|
|
78
30
|
</Flexbox>
|
79
31
|
);
|
80
32
|
|
33
|
+
/* ↓ cloud slot ↓ */
|
34
|
+
|
35
|
+
/* ↑ cloud slot ↑ */
|
36
|
+
|
81
37
|
return (
|
82
38
|
<Flexbox className={cx(styles.container)} gap={24}>
|
83
39
|
<Flexbox gap={12} padding={16} width={'100%'}>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { createStyles } from 'antd-style';
|
2
|
+
|
3
|
+
export const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
4
|
+
banner: css`
|
5
|
+
opacity: ${isDarkMode ? 0.9 : 0.4};
|
6
|
+
`,
|
7
|
+
container: css`
|
8
|
+
position: relative;
|
9
|
+
|
10
|
+
overflow: hidden;
|
11
|
+
|
12
|
+
height: 100%;
|
13
|
+
border-radius: 12px;
|
14
|
+
|
15
|
+
background: ${token.colorBgContainer};
|
16
|
+
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillQuaternary : token.colorFillSecondary}
|
17
|
+
inset;
|
18
|
+
|
19
|
+
transition: box-shadow 0.2s ${token.motionEaseInOut};
|
20
|
+
|
21
|
+
&:hover {
|
22
|
+
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillSecondary : token.colorFill} inset;
|
23
|
+
}
|
24
|
+
`,
|
25
|
+
desc: css`
|
26
|
+
min-height: 44px;
|
27
|
+
margin-block-end: 0 !important;
|
28
|
+
color: ${token.colorTextDescription};
|
29
|
+
`,
|
30
|
+
tagBlue: css`
|
31
|
+
color: ${token.geekblue};
|
32
|
+
background: ${token.geekblue1};
|
33
|
+
`,
|
34
|
+
tagGreen: css`
|
35
|
+
color: ${token.green};
|
36
|
+
background: ${token.green1};
|
37
|
+
`,
|
38
|
+
time: css`
|
39
|
+
color: ${token.colorTextDescription};
|
40
|
+
`,
|
41
|
+
title: css`
|
42
|
+
zoom: 1.2;
|
43
|
+
margin-block-end: 0 !important;
|
44
|
+
font-size: 18px !important;
|
45
|
+
font-weight: bold;
|
46
|
+
`,
|
47
|
+
token: css`
|
48
|
+
font-family: ${token.fontFamilyCode};
|
49
|
+
`,
|
50
|
+
}));
|
@@ -5,7 +5,7 @@ import { createStyles } from 'antd-style';
|
|
5
5
|
import Link from 'next/link';
|
6
6
|
import { usePathname } from 'next/navigation';
|
7
7
|
import { memo } from 'react';
|
8
|
-
import { Flexbox } from 'react-layout-kit';
|
8
|
+
import { Center, Flexbox } from 'react-layout-kit';
|
9
9
|
|
10
10
|
import { AiProviderListItem, AiProviderSourceEnum } from '@/types/aiProvider';
|
11
11
|
|
@@ -62,7 +62,16 @@ const ProviderItem = memo<AiProviderListItem>(({ id, name, source, enabled, logo
|
|
62
62
|
)}
|
63
63
|
{name}
|
64
64
|
</Flexbox>
|
65
|
-
|
65
|
+
<Flexbox horizontal>
|
66
|
+
{enabled && (
|
67
|
+
<Center width={24}>
|
68
|
+
<Badge status="success" />
|
69
|
+
</Center>
|
70
|
+
)}
|
71
|
+
{/* cloud slot */}
|
72
|
+
|
73
|
+
{/* cloud slot */}
|
74
|
+
</Flexbox>
|
66
75
|
</Link>
|
67
76
|
);
|
68
77
|
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { Skeleton } from 'antd';
|
2
|
+
import { createStyles } from 'antd-style';
|
3
|
+
import { FC } from 'react';
|
4
|
+
|
5
|
+
import InstantSwitch from '@/components/InstantSwitch';
|
6
|
+
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
7
|
+
|
8
|
+
const useStyles = createStyles(({ css }) => ({
|
9
|
+
switchLoading: css`
|
10
|
+
width: 44px !important;
|
11
|
+
min-width: 44px !important;
|
12
|
+
height: 22px !important;
|
13
|
+
border-radius: 12px !important;
|
14
|
+
`,
|
15
|
+
}));
|
16
|
+
|
17
|
+
interface SwitchProps {
|
18
|
+
Component?: FC<{ id: string }>;
|
19
|
+
id: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
const Switch = ({ id, Component }: SwitchProps) => {
|
23
|
+
const { styles } = useStyles();
|
24
|
+
|
25
|
+
const [toggleProviderEnabled, enabled, isLoading] = useAiInfraStore((s) => [
|
26
|
+
s.toggleProviderEnabled,
|
27
|
+
aiProviderSelectors.isProviderEnabled(id)(s),
|
28
|
+
aiProviderSelectors.isAiProviderConfigLoading(id)(s),
|
29
|
+
]);
|
30
|
+
|
31
|
+
if (isLoading) return <Skeleton.Button active className={styles.switchLoading} />;
|
32
|
+
|
33
|
+
// slot for cloud
|
34
|
+
if (Component) return <Component id={id} />;
|
35
|
+
|
36
|
+
return (
|
37
|
+
<InstantSwitch
|
38
|
+
enabled={enabled}
|
39
|
+
onChange={async (enabled) => {
|
40
|
+
await toggleProviderEnabled(id as any, enabled);
|
41
|
+
}}
|
42
|
+
/>
|
43
|
+
);
|
44
|
+
};
|
45
|
+
|
46
|
+
export default Switch;
|
@@ -12,7 +12,6 @@ import { Trans, useTranslation } from 'react-i18next';
|
|
12
12
|
import { Center, Flexbox } from 'react-layout-kit';
|
13
13
|
import urlJoin from 'url-join';
|
14
14
|
|
15
|
-
import InstantSwitch from '@/components/InstantSwitch';
|
16
15
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
17
16
|
import { AES_GCM_URL, BASE_PROVIDER_DOC_URL } from '@/const/url';
|
18
17
|
import { isServerMode } from '@/const/version';
|
@@ -26,6 +25,7 @@ import {
|
|
26
25
|
import { KeyVaultsConfigKey, LLMProviderApiTokenKey, LLMProviderBaseUrlKey } from '../../const';
|
27
26
|
import Checker from './Checker';
|
28
27
|
import { SkeletonInput } from './SkeletonInput';
|
28
|
+
import EnableSwitch from './EnableSwitch';
|
29
29
|
import UpdateProviderInfo from './UpdateProviderInfo';
|
30
30
|
|
31
31
|
const useStyles = createStyles(({ css, prefixCls, responsive, token }) => ({
|
@@ -131,7 +131,6 @@ const ProviderConfig = memo<ProviderConfigProps>(
|
|
131
131
|
const { cx, styles, theme } = useStyles();
|
132
132
|
|
133
133
|
const [
|
134
|
-
toggleProviderEnabled,
|
135
134
|
useFetchAiProviderItem,
|
136
135
|
updateAiProviderConfig,
|
137
136
|
enabled,
|
@@ -141,7 +140,6 @@ const ProviderConfig = memo<ProviderConfigProps>(
|
|
141
140
|
isProviderEndpointNotEmpty,
|
142
141
|
isProviderApiKeyNotEmpty,
|
143
142
|
] = useAiInfraStore((s) => [
|
144
|
-
s.toggleProviderEnabled,
|
145
143
|
s.useFetchAiProviderItem,
|
146
144
|
s.updateAiProviderConfig,
|
147
145
|
aiProviderSelectors.isProviderEnabled(id)(s),
|
@@ -285,16 +283,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
|
|
285
283
|
{extra}
|
286
284
|
|
287
285
|
{isCustom && <UpdateProviderInfo />}
|
288
|
-
{
|
289
|
-
<Skeleton.Button active className={styles.switchLoading} />
|
290
|
-
) : (
|
291
|
-
<InstantSwitch
|
292
|
-
enabled={enabled}
|
293
|
-
onChange={async (enabled) => {
|
294
|
-
await toggleProviderEnabled(id as any, enabled);
|
295
|
-
}}
|
296
|
-
/>
|
297
|
-
)}
|
286
|
+
<EnableSwitch id={id} />
|
298
287
|
</Flexbox>
|
299
288
|
),
|
300
289
|
title: (
|
package/src/types/llm.ts
CHANGED
@@ -119,13 +119,15 @@ export interface ModelProviderCard {
|
|
119
119
|
* @deprecated
|
120
120
|
*/
|
121
121
|
showApiKey?: boolean;
|
122
|
-
|
123
122
|
/**
|
124
123
|
* whether show checker in the provider config
|
125
124
|
* @deprecated
|
126
125
|
*/
|
127
126
|
showChecker?: boolean;
|
128
|
-
|
127
|
+
/**
|
128
|
+
* whether to show the provider config
|
129
|
+
*/
|
130
|
+
showConfig?: boolean;
|
129
131
|
/**
|
130
132
|
* whether to smoothing the output
|
131
133
|
* @deprecated
|