@lobehub/chat 1.47.0 → 1.47.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 CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.47.2](https://github.com/lobehub/lobe-chat/compare/v1.47.1...v1.47.2)
6
+
7
+ <sup>Released on **2025-01-17**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix api key in api key form.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix api key in api key form, closes [#5498](https://github.com/lobehub/lobe-chat/issues/5498) ([b4a160b](https://github.com/lobehub/lobe-chat/commit/b4a160b))
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
+
30
+ ### [Version 1.47.1](https://github.com/lobehub/lobe-chat/compare/v1.47.0...v1.47.1)
31
+
32
+ <sup>Released on **2025-01-17**</sup>
33
+
34
+ <br/>
35
+
36
+ <details>
37
+ <summary><kbd>Improvements and Fixes</kbd></summary>
38
+
39
+ </details>
40
+
41
+ <div align="right">
42
+
43
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
44
+
45
+ </div>
46
+
5
47
  ## [Version 1.47.0](https://github.com/lobehub/lobe-chat/compare/v1.46.7...v1.47.0)
6
48
 
7
49
  <sup>Released on **2025-01-17**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Fix api key in api key form."
6
+ ]
7
+ },
8
+ "date": "2025-01-17",
9
+ "version": "1.47.2"
10
+ },
11
+ {
12
+ "children": {},
13
+ "date": "2025-01-17",
14
+ "version": "1.47.1"
15
+ },
2
16
  {
3
17
  "children": {
4
18
  "features": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.47.0",
3
+ "version": "1.47.2",
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,11 +6,10 @@ import { useTranslation } from 'react-i18next';
6
6
 
7
7
  import { useProviderName } from '@/hooks/useProviderName';
8
8
  import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
9
- import { useUserStore } from '@/store/user';
10
- import { keyVaultsConfigSelectors } from '@/store/user/selectors';
11
9
  import { GlobalLLMProviderKey } from '@/types/user/settings';
12
10
 
13
11
  import { FormAction } from '../style';
12
+ import { useApiKey } from './useApiKey';
14
13
 
15
14
  interface ProviderApiKeyFormProps {
16
15
  apiKeyPlaceholder?: string;
@@ -25,11 +24,7 @@ const ProviderApiKeyForm = memo<ProviderApiKeyFormProps>(
25
24
  const { t: errorT } = useTranslation('error');
26
25
  const [showProxy, setShow] = useState(false);
27
26
 
28
- const [apiKey, proxyUrl, setConfig] = useUserStore((s) => [
29
- keyVaultsConfigSelectors.getVaultByProvider(provider)(s)?.apiKey,
30
- keyVaultsConfigSelectors.getVaultByProvider(provider)(s)?.baseURL,
31
- s.updateKeyVaultConfig,
32
- ]);
27
+ const { apiKey, baseURL, setConfig } = useApiKey(provider);
33
28
  const { showOpenAIProxyUrl } = useServerConfigStore(featureFlagsSelectors);
34
29
  const providerName = useProviderName(provider);
35
30
 
@@ -58,7 +53,7 @@ const ProviderApiKeyForm = memo<ProviderApiKeyFormProps>(
58
53
  }}
59
54
  placeholder={'https://api.openai.com/v1'}
60
55
  type={'block'}
61
- value={proxyUrl}
56
+ value={baseURL}
62
57
  />
63
58
  ) : (
64
59
  <Button
@@ -0,0 +1,34 @@
1
+ import isEqual from 'fast-deep-equal';
2
+
3
+ import { isDeprecatedEdition } from '@/const/version';
4
+ import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
5
+ import { useUserStore } from '@/store/user';
6
+ import { keyVaultsConfigSelectors } from '@/store/user/selectors';
7
+
8
+ export const useApiKey = (provider: string) => {
9
+ const [apiKey, baseURL, setConfig] = useUserStore((s) => [
10
+ keyVaultsConfigSelectors.getVaultByProvider(provider as any)(s)?.apiKey,
11
+ keyVaultsConfigSelectors.getVaultByProvider(provider as any)(s)?.baseURL,
12
+ s.updateKeyVaultConfig,
13
+ ]);
14
+
15
+ const updateAiProviderConfig = useAiInfraStore((s) => s.updateAiProviderConfig);
16
+ const data = useAiInfraStore(aiProviderSelectors.providerConfigById(provider), isEqual);
17
+
18
+ // TODO: remove this in V2
19
+ if (isDeprecatedEdition) return { apiKey, baseURL, setConfig };
20
+ //
21
+
22
+ return {
23
+ apiKey: data?.keyVaults.apiKey,
24
+ baseURL: data?.keyVaults?.baseURL,
25
+ setConfig: async (id: string, params: Record<string, string>) => {
26
+ await updateAiProviderConfig(id, {
27
+ keyVaults: {
28
+ ...data?.keyVaults,
29
+ ...params,
30
+ },
31
+ });
32
+ },
33
+ };
34
+ };
@@ -37,6 +37,17 @@ const isActiveProviderApiKeyNotEmpty = (s: AIProviderStoreState) => {
37
37
  return !!vault?.apiKey || !!vault?.accessKeyId || !!vault?.secretAccessKey;
38
38
  };
39
39
 
40
+ const providerConfigById =
41
+ (id: string) =>
42
+ (s: AIProviderStoreState): AiProviderRuntimeConfig | undefined => {
43
+ if (!id) return undefined;
44
+
45
+ return s.aiProviderRuntimeConfig?.[id];
46
+ };
47
+
48
+ const isProviderConfigUpdating = (id: string) => (s: AIProviderStoreState) =>
49
+ s.aiProviderConfigUpdatingIds.includes(id);
50
+
40
51
  /**
41
52
  * @description The conditions to enable client fetch
42
53
  * 1. If no baseUrl and apikey input, force on Server.
@@ -46,7 +57,7 @@ const isActiveProviderApiKeyNotEmpty = (s: AIProviderStoreState) => {
46
57
  */
47
58
  const isProviderFetchOnClient =
48
59
  (provider: GlobalLLMProviderKey | string) => (s: AIProviderStoreState) => {
49
- const config = activeProviderConfig(s);
60
+ const config = providerConfigById(provider)(s);
50
61
 
51
62
  // If the provider already disable broswer request in model config, force on Server.
52
63
  if (isProviderDisableBroswerRequest(provider)) return false;
@@ -56,8 +67,8 @@ const isProviderFetchOnClient =
56
67
  return config?.fetchOnClient;
57
68
 
58
69
  // 1. If no baseUrl and apikey input, force on Server.
59
- const isProviderEndpointNotEmpty = isActiveProviderEndpointNotEmpty(s);
60
- const isProviderApiKeyNotEmpty = isActiveProviderApiKeyNotEmpty(s);
70
+ const isProviderEndpointNotEmpty = !!config?.keyVaults.baseURL;
71
+ const isProviderApiKeyNotEmpty = !!config?.keyVaults.apiKey;
61
72
  if (!isProviderEndpointNotEmpty && !isProviderApiKeyNotEmpty) return false;
62
73
 
63
74
  // 2. If only contains baseUrl, force on Client
@@ -76,17 +87,6 @@ const providerKeyVaults = (provider: string | undefined) => (s: AIProviderStoreS
76
87
  return s.aiProviderRuntimeConfig?.[provider]?.keyVaults;
77
88
  };
78
89
 
79
- const providerConfigById =
80
- (id: string) =>
81
- (s: AIProviderStoreState): AiProviderRuntimeConfig | undefined => {
82
- if (!id) return undefined;
83
-
84
- return s.aiProviderRuntimeConfig?.[id];
85
- };
86
-
87
- const isProviderConfigUpdating = (id: string) => (s: AIProviderStoreState) =>
88
- s.aiProviderConfigUpdatingIds.includes(id);
89
-
90
90
  export const aiProviderSelectors = {
91
91
  activeProviderConfig,
92
92
  disabledAiProviderList,
@@ -201,7 +201,7 @@ export interface EnabledAiModel {
201
201
 
202
202
  export interface AiProviderRuntimeConfig {
203
203
  fetchOnClient?: boolean;
204
- keyVaults: Record<string, object>;
204
+ keyVaults: Record<string, string>;
205
205
  settings: AiProviderSettings;
206
206
  }
207
207
 
package/vercel.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "buildCommand": "NODE_OPTIONS=--max-old-space-size=6144 next build",
2
+ "buildCommand": "NODE_OPTIONS=--max-old-space-size=6144 bun run build",
3
3
  "installCommand": "bun install"
4
4
  }