@lobehub/chat 1.47.4 → 1.47.5

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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.47.5](https://github.com/lobehub/lobe-chat/compare/v1.47.4...v1.47.5)
6
+
7
+ <sup>Released on **2025-01-20**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Improve ai provider code.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Improve ai provider code, closes [#5514](https://github.com/lobehub/lobe-chat/issues/5514) ([92789cd](https://github.com/lobehub/lobe-chat/commit/92789cd))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 1.47.4](https://github.com/lobehub/lobe-chat/compare/v1.47.3...v1.47.4)
6
31
 
7
32
  <sup>Released on **2025-01-18**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Improve ai provider code."
6
+ ]
7
+ },
8
+ "date": "2025-01-20",
9
+ "version": "1.47.5"
10
+ },
2
11
  {
3
12
  "children": {},
4
13
  "date": "2025-01-18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.47.4",
3
+ "version": "1.47.5",
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",
@@ -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
- {enabled && <Badge status="success" />}
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
- {isLoading ? (
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: (