@lobehub/chat 0.161.21 → 0.161.22
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/(main)/settings/llm/Bedrock/index.tsx +1 -1
- package/src/app/(main)/settings/llm/components/Checker.tsx +10 -6
- package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +1 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/CustomModelOption.tsx +1 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +1 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/Option.tsx +1 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/index.tsx +1 -1
- package/src/const/settings/agent.ts +2 -2
- package/src/const/settings/common.ts +2 -2
- package/src/const/settings/index.ts +2 -2
- package/src/const/settings/llm.ts +2 -2
- package/src/const/settings/sync.ts +2 -2
- package/src/const/settings/systemAgent.ts +2 -2
- package/src/const/settings/tts.ts +2 -2
- package/src/database/client/core/migrations/migrateSettingsToUser/type.ts +1 -1
- package/src/database/client/models/__tests__/user.test.ts +1 -1
- package/src/database/client/models/user.ts +2 -2
- package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +1 -1
- package/src/features/Conversation/Error/APIKeyForm/index.tsx +1 -1
- package/src/features/Conversation/components/BubblesLoading.tsx +49 -41
- package/src/services/__tests__/share.test.ts +2 -2
- package/src/services/_auth.test.ts +2 -2
- package/src/services/config.ts +2 -2
- package/src/services/share.ts +3 -3
- package/src/services/user/client.test.ts +3 -3
- package/src/services/user/client.ts +3 -3
- package/src/services/user/type.ts +2 -2
- package/src/store/agent/store.ts +4 -9
- package/src/store/chat/store.ts +4 -8
- package/src/store/file/store.ts +3 -9
- package/src/store/global/store.ts +5 -8
- package/src/store/market/store.ts +5 -8
- package/src/store/middleware/createDevtools.ts +23 -0
- package/src/store/serverConfig/store.ts +5 -11
- package/src/store/session/store.ts +3 -1
- package/src/store/tool/store.ts +4 -9
- package/src/store/user/slices/common/action.ts +2 -2
- package/src/store/user/slices/modelList/action.test.ts +2 -2
- package/src/store/user/slices/modelList/action.ts +2 -2
- package/src/store/user/slices/modelList/selectors/modelConfig.ts +1 -1
- package/src/store/user/slices/modelList/selectors/modelProvider.ts +1 -1
- package/src/store/user/slices/settings/action.test.ts +4 -4
- package/src/store/user/slices/settings/action.ts +3 -3
- package/src/store/user/slices/settings/initialState.ts +3 -3
- package/src/store/user/slices/settings/selectors/settings.ts +8 -5
- package/src/store/user/store.ts +5 -8
- package/src/types/exportConfig.ts +2 -2
- package/src/types/serverConfig.ts +2 -2
- package/src/types/user/index.ts +2 -2
- package/src/types/{settings/base.ts → user/settings/general.ts} +4 -1
- package/src/types/user/settings/index.ts +54 -0
- package/src/types/user/settings/modelProvider.ts +70 -0
- package/src/types/{settings → user/settings}/sync.ts +1 -1
- package/src/types/{settings → user/settings}/systemAgent.ts +1 -1
- package/src/types/user/settings/tool.ts +5 -0
- package/src/types/{settings → user/settings}/tts.ts +1 -1
- package/src/types/settings/index.ts +0 -33
- package/src/types/settings/modelProvider.ts +0 -62
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.161.22](https://github.com/lobehub/lobe-chat/compare/v0.161.21...v0.161.22)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-05-26**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix connection checker.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix connection checker, closes [#2672](https://github.com/lobehub/lobe-chat/issues/2672) ([bef8926](https://github.com/lobehub/lobe-chat/commit/bef8926))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.161.21](https://github.com/lobehub/lobe-chat/compare/v0.161.20...v0.161.21)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-05-26**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.161.
|
|
3
|
+
"version": "0.161.22",
|
|
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",
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
10
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
10
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
11
11
|
|
|
12
12
|
import ProviderConfig from '../components/ProviderConfig';
|
|
13
13
|
import { LLMProviderConfigKey } from '../const';
|
|
@@ -50,10 +50,19 @@ const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
|
|
|
50
50
|
const [error, setError] = useState<ChatMessageError | undefined>();
|
|
51
51
|
|
|
52
52
|
const checkConnection = async () => {
|
|
53
|
-
|
|
53
|
+
let isError = false;
|
|
54
|
+
|
|
55
|
+
await chatService.fetchPresetTaskResult({
|
|
54
56
|
onError: (_, rawError) => {
|
|
55
57
|
setError(rawError);
|
|
56
58
|
setPass(false);
|
|
59
|
+
isError = true;
|
|
60
|
+
},
|
|
61
|
+
onFinish: async () => {
|
|
62
|
+
if (!isError) {
|
|
63
|
+
setError(undefined);
|
|
64
|
+
setPass(true);
|
|
65
|
+
}
|
|
57
66
|
},
|
|
58
67
|
onLoadingChange: (loading) => {
|
|
59
68
|
setLoading(loading);
|
|
@@ -74,11 +83,6 @@ const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
|
|
|
74
83
|
traceName: TraceNameMap.ConnectivityChecker,
|
|
75
84
|
},
|
|
76
85
|
});
|
|
77
|
-
|
|
78
|
-
if (data) {
|
|
79
|
-
setError(undefined);
|
|
80
|
-
setPass(true);
|
|
81
|
-
}
|
|
82
86
|
};
|
|
83
87
|
const isMobile = useIsMobile();
|
|
84
88
|
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
19
19
|
import { useUserStore } from '@/store/user';
|
|
20
20
|
import { modelConfigSelectors } from '@/store/user/selectors';
|
|
21
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
21
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
22
22
|
|
|
23
23
|
import Checker from '../Checker';
|
|
24
24
|
import ProviderModelListSelect from '../ProviderModelList';
|
|
@@ -10,7 +10,7 @@ import ModelIcon from '@/components/ModelIcon';
|
|
|
10
10
|
import { ModelInfoTags } from '@/components/ModelSelect';
|
|
11
11
|
import { useUserStore } from '@/store/user';
|
|
12
12
|
import { modelConfigSelectors } from '@/store/user/selectors';
|
|
13
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
13
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
14
14
|
|
|
15
15
|
interface CustomModelOptionProps {
|
|
16
16
|
id: string;
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
modelProviderSelectors,
|
|
14
14
|
settingsSelectors,
|
|
15
15
|
} from '@/store/user/selectors';
|
|
16
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
16
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
17
17
|
|
|
18
18
|
const useStyles = createStyles(({ css, token }) => ({
|
|
19
19
|
hover: css`
|
|
@@ -11,7 +11,7 @@ import ModelIcon from '@/components/ModelIcon';
|
|
|
11
11
|
import { ModelInfoTags } from '@/components/ModelSelect';
|
|
12
12
|
import { useUserStore } from '@/store/user';
|
|
13
13
|
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
14
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
14
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
15
15
|
|
|
16
16
|
import CustomModelOption from './CustomModelOption';
|
|
17
17
|
|
|
@@ -9,7 +9,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
9
9
|
|
|
10
10
|
import { useUserStore } from '@/store/user';
|
|
11
11
|
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
12
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
12
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
13
13
|
|
|
14
14
|
import ModelConfigModal from './ModelConfigModal';
|
|
15
15
|
import ModelFetcher from './ModelFetcher';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_AGENT_META } from '@/const/meta';
|
|
2
2
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
3
3
|
import { LobeAgentChatConfig, LobeAgentConfig, LobeAgentTTSConfig } from '@/types/agent';
|
|
4
|
-
import {
|
|
4
|
+
import { UserDefaultAgent } from '@/types/user/settings';
|
|
5
5
|
|
|
6
6
|
export const DEFAUTT_AGENT_TTS_CONFIG: LobeAgentTTSConfig = {
|
|
7
7
|
showAllLocaleVoice: false,
|
|
@@ -34,7 +34,7 @@ export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
|
|
|
34
34
|
tts: DEFAUTT_AGENT_TTS_CONFIG,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export const DEFAULT_AGENT:
|
|
37
|
+
export const DEFAULT_AGENT: UserDefaultAgent = {
|
|
38
38
|
config: DEFAULT_AGENT_CONFIG,
|
|
39
39
|
meta: DEFAULT_AGENT_META,
|
|
40
40
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserGeneralSettings } from '@/types/user/settings';
|
|
2
2
|
|
|
3
|
-
export const DEFAULT_COMMON_SETTINGS:
|
|
3
|
+
export const DEFAULT_COMMON_SETTINGS: UserGeneralSettings = {
|
|
4
4
|
fontSize: 14,
|
|
5
5
|
language: 'auto',
|
|
6
6
|
password: '',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserSettings } from '@/types/user/settings';
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_AGENT } from './agent';
|
|
4
4
|
import { DEFAULT_COMMON_SETTINGS } from './common';
|
|
@@ -16,7 +16,7 @@ export * from './systemAgent';
|
|
|
16
16
|
export * from './tool';
|
|
17
17
|
export * from './tts';
|
|
18
18
|
|
|
19
|
-
export const DEFAULT_SETTINGS:
|
|
19
|
+
export const DEFAULT_SETTINGS: UserSettings = {
|
|
20
20
|
defaultAgent: DEFAULT_AGENT,
|
|
21
21
|
languageModel: DEFAULT_LLM_CONFIG,
|
|
22
22
|
sync: DEFAULT_SYNC_CONFIG,
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
filterEnabledModels,
|
|
18
18
|
} from '@/config/modelProviders';
|
|
19
19
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
20
|
-
import {
|
|
20
|
+
import { UserModelProviderConfig } from '@/types/user/settings';
|
|
21
21
|
|
|
22
|
-
export const DEFAULT_LLM_CONFIG:
|
|
22
|
+
export const DEFAULT_LLM_CONFIG: UserModelProviderConfig = {
|
|
23
23
|
anthropic: {
|
|
24
24
|
apiKey: '',
|
|
25
25
|
enabled: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserSystemAgentConfig, GlobalTranslationConfig } from '@/types/user/settings';
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from './llm';
|
|
4
4
|
|
|
@@ -7,6 +7,6 @@ export const DEFAULT_TRANSLATION_CONFIG: GlobalTranslationConfig = {
|
|
|
7
7
|
provider: DEFAULT_PROVIDER,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export const DEFAULT_SYSTEM_AGENT_CONFIG:
|
|
10
|
+
export const DEFAULT_SYSTEM_AGENT_CONFIG: UserSystemAgentConfig = {
|
|
11
11
|
translation: DEFAULT_TRANSLATION_CONFIG,
|
|
12
12
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserTTSConfig } from '@/types/user/settings';
|
|
2
2
|
|
|
3
|
-
export const DEFAULT_TTS_CONFIG:
|
|
3
|
+
export const DEFAULT_TTS_CONFIG: UserTTSConfig = {
|
|
4
4
|
openAI: {
|
|
5
5
|
sttModel: 'whisper-1',
|
|
6
6
|
ttsModel: 'tts-1',
|
|
@@ -3,7 +3,7 @@ import type { ThemeMode } from 'antd-style';
|
|
|
3
3
|
import { LobeAgentTTSConfig } from '@/types/agent';
|
|
4
4
|
import { FewShots, LLMParams } from '@/types/llm';
|
|
5
5
|
import { MetaData } from '@/types/meta';
|
|
6
|
-
import { STTServer } from '@/types/settings';
|
|
6
|
+
import { STTServer } from '@/types/user/settings';
|
|
7
7
|
|
|
8
8
|
interface V4LobeAgentConfig {
|
|
9
9
|
autoCreateTopicThreshold: number;
|
|
@@ -2,7 +2,7 @@ import { DeepPartial } from 'utility-types';
|
|
|
2
2
|
|
|
3
3
|
import { BaseModel } from '@/database/client/core';
|
|
4
4
|
import { LobeAgentConfig } from '@/types/agent';
|
|
5
|
-
import {
|
|
5
|
+
import { UserSettings } from '@/types/user/settings';
|
|
6
6
|
import { uuid } from '@/utils/uuid';
|
|
7
7
|
|
|
8
8
|
import { DB_User, DB_UserSchema } from '../schemas/user';
|
|
@@ -42,7 +42,7 @@ class _UserModel extends BaseModel {
|
|
|
42
42
|
|
|
43
43
|
// **************** Update *************** //
|
|
44
44
|
|
|
45
|
-
async updateSettings(settings: DeepPartial<
|
|
45
|
+
async updateSettings(settings: DeepPartial<UserSettings>) {
|
|
46
46
|
const user = await this.getUser();
|
|
47
47
|
|
|
48
48
|
return this.update(user.id, { settings: settings as any });
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
|
|
7
7
|
import { useUserStore } from '@/store/user';
|
|
8
8
|
import { settingsSelectors } from '@/store/user/selectors';
|
|
9
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
9
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
10
10
|
|
|
11
11
|
import { FormAction } from '../style';
|
|
12
12
|
|
|
@@ -5,7 +5,7 @@ import { Center, Flexbox } from 'react-layout-kit';
|
|
|
5
5
|
|
|
6
6
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
7
7
|
import { useChatStore } from '@/store/chat';
|
|
8
|
-
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
8
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
|
9
9
|
|
|
10
10
|
import BedrockForm from './Bedrock';
|
|
11
11
|
import ProviderApiKeyForm from './ProviderApiKeyForm';
|
|
@@ -1,52 +1,60 @@
|
|
|
1
|
-
import { useTheme } from 'antd-style';
|
|
1
|
+
import { css, cx, useTheme } from 'antd-style';
|
|
2
|
+
import { Center } from 'react-layout-kit';
|
|
3
|
+
|
|
4
|
+
const container = css`
|
|
5
|
+
circle {
|
|
6
|
+
animation: bubble 1.5s cubic-bezier(0.05, 0.2, 0.35, 1) infinite;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
circle:nth-child(2) {
|
|
10
|
+
animation-delay: 0.3s;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
circle:nth-child(3) {
|
|
14
|
+
animation-delay: 0.6s;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@keyframes bubble {
|
|
18
|
+
0% {
|
|
19
|
+
opacity: 1;
|
|
20
|
+
|
|
21
|
+
/* transform: translateY(0); */
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
25% {
|
|
25
|
+
opacity: 0.5;
|
|
26
|
+
|
|
27
|
+
/* transform: translateY(-4px); */
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
75% {
|
|
31
|
+
opacity: 0.25;
|
|
32
|
+
|
|
33
|
+
/* transform: translateY(4px); */
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
to {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
|
|
39
|
+
/* transform: translateY(0); */
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
2
43
|
|
|
3
44
|
const Svg = () => (
|
|
4
|
-
<svg viewBox="0 0 32
|
|
5
|
-
<circle cx="
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
begin="0"
|
|
9
|
-
calcMode="spline"
|
|
10
|
-
dur="1.2s"
|
|
11
|
-
keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8"
|
|
12
|
-
keyTimes="0;0.2;0.7;1"
|
|
13
|
-
repeatCount="indefinite"
|
|
14
|
-
values="0; 4; 0; 0"
|
|
15
|
-
/>
|
|
16
|
-
</circle>
|
|
17
|
-
<circle cx="0" cy="12" r="0" transform="translate(16 0)">
|
|
18
|
-
<animate
|
|
19
|
-
attributeName="r"
|
|
20
|
-
begin="0.3"
|
|
21
|
-
calcMode="spline"
|
|
22
|
-
dur="1.2s"
|
|
23
|
-
keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8"
|
|
24
|
-
keyTimes="0;0.2;0.7;1"
|
|
25
|
-
repeatCount="indefinite"
|
|
26
|
-
values="0; 4; 0; 0"
|
|
27
|
-
/>
|
|
28
|
-
</circle>
|
|
29
|
-
<circle cx="0" cy="12" r="0" transform="translate(24 0)">
|
|
30
|
-
<animate
|
|
31
|
-
attributeName="r"
|
|
32
|
-
begin="0.6"
|
|
33
|
-
calcMode="spline"
|
|
34
|
-
dur="1.2s"
|
|
35
|
-
keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8"
|
|
36
|
-
keyTimes="0;0.2;0.7;1"
|
|
37
|
-
repeatCount="indefinite"
|
|
38
|
-
values="0; 4; 0; 0"
|
|
39
|
-
/>
|
|
40
|
-
</circle>
|
|
45
|
+
<svg className={cx(container)} viewBox="0 0 60 32" xmlns="http://www.w3.org/2000/svg">
|
|
46
|
+
<circle cx="7" cy="16" r="6"></circle>
|
|
47
|
+
<circle cx="30" cy="16" r="6"></circle>
|
|
48
|
+
<circle cx="53" cy="16" r="6"></circle>
|
|
41
49
|
</svg>
|
|
42
50
|
);
|
|
43
51
|
|
|
44
52
|
const BubblesLoading = () => {
|
|
45
|
-
const
|
|
53
|
+
const theme = useTheme();
|
|
46
54
|
return (
|
|
47
|
-
<
|
|
55
|
+
<Center style={{ fill: theme.colorTextSecondary, height: 24, width: 32 }}>
|
|
48
56
|
<Svg />
|
|
49
|
-
</
|
|
57
|
+
</Center>
|
|
50
58
|
);
|
|
51
59
|
};
|
|
52
60
|
|
|
@@ -2,8 +2,8 @@ import { DeepPartial } from 'utility-types';
|
|
|
2
2
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { LOBE_URL_IMPORT_NAME } from '@/const/url';
|
|
5
|
-
import { GlobalSettings } from '@/types/settings';
|
|
6
5
|
import { ShareGPTConversation } from '@/types/share';
|
|
6
|
+
import { UserSettings } from '@/types/user/settings';
|
|
7
7
|
import { parseMarkdown } from '@/utils/parseMarkdown';
|
|
8
8
|
|
|
9
9
|
import { SHARE_GPT_URL, shareService } from '../share';
|
|
@@ -91,7 +91,7 @@ describe('ShareGPTService', () => {
|
|
|
91
91
|
describe('ShareViaUrl', () => {
|
|
92
92
|
describe('createShareSettingsUrl', () => {
|
|
93
93
|
it('should create a share settings URL with the provided settings', () => {
|
|
94
|
-
const settings: DeepPartial<
|
|
94
|
+
const settings: DeepPartial<UserSettings> = {
|
|
95
95
|
languageModel: {
|
|
96
96
|
openai: {
|
|
97
97
|
apiKey: 'user-key',
|
|
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
|
|
4
4
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
5
5
|
import { useUserStore } from '@/store/user';
|
|
6
|
-
import {
|
|
6
|
+
import { UserModelProviderConfig, GlobalLLMProviderKey } from '@/types/user/settings';
|
|
7
7
|
|
|
8
8
|
import { getProviderAuthPayload } from './_auth';
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ vi.mock('zustand/traditional');
|
|
|
21
21
|
|
|
22
22
|
const setModelProviderConfig = <T extends GlobalLLMProviderKey>(
|
|
23
23
|
provider: T,
|
|
24
|
-
config: Partial<
|
|
24
|
+
config: Partial<UserModelProviderConfig[T]>,
|
|
25
25
|
) => {
|
|
26
26
|
useUserStore.setState({
|
|
27
27
|
settings: { languageModel: { [provider]: config } },
|
package/src/services/config.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { settingsSelectors } from '@/store/user/selectors';
|
|
|
8
8
|
import { ConfigFile } from '@/types/exportConfig';
|
|
9
9
|
import { ChatMessage } from '@/types/message';
|
|
10
10
|
import { LobeSessions, SessionGroupItem } from '@/types/session';
|
|
11
|
-
import { GlobalSettings } from '@/types/settings';
|
|
12
11
|
import { ChatTopic } from '@/types/topic';
|
|
12
|
+
import { UserSettings } from '@/types/user/settings';
|
|
13
13
|
import { createConfigFile, exportConfigFile } from '@/utils/config';
|
|
14
14
|
|
|
15
15
|
export interface ImportResult {
|
|
@@ -35,7 +35,7 @@ class ConfigService {
|
|
|
35
35
|
importMessages = async (messages: ChatMessage[]) => {
|
|
36
36
|
return messageService.batchCreateMessages(messages);
|
|
37
37
|
};
|
|
38
|
-
importSettings = async (settings:
|
|
38
|
+
importSettings = async (settings: UserSettings) => {
|
|
39
39
|
useUserStore.getState().importAppSettings(settings);
|
|
40
40
|
};
|
|
41
41
|
importTopics = async (topics: ChatTopic[]) => {
|
package/src/services/share.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DeepPartial } from 'utility-types';
|
|
2
2
|
|
|
3
3
|
import { LOBE_URL_IMPORT_NAME } from '@/const/url';
|
|
4
|
-
import { GlobalSettings } from '@/types/settings';
|
|
5
4
|
import { ShareGPTConversation } from '@/types/share';
|
|
5
|
+
import { UserSettings } from '@/types/user/settings';
|
|
6
6
|
import { withBasePath } from '@/utils/basePath';
|
|
7
7
|
import { parseMarkdown } from '@/utils/parseMarkdown';
|
|
8
8
|
|
|
@@ -40,7 +40,7 @@ class ShareService {
|
|
|
40
40
|
* @param settings - The settings object to be encoded in the URL.
|
|
41
41
|
* @returns The share settings URL.
|
|
42
42
|
*/
|
|
43
|
-
public createShareSettingsUrl(settings: DeepPartial<
|
|
43
|
+
public createShareSettingsUrl(settings: DeepPartial<UserSettings>) {
|
|
44
44
|
return withBasePath(`/?${LOBE_URL_IMPORT_NAME}=${encodeURI(JSON.stringify(settings))}`);
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -51,7 +51,7 @@ class ShareService {
|
|
|
51
51
|
*/
|
|
52
52
|
public decodeShareSettings(settings: string) {
|
|
53
53
|
try {
|
|
54
|
-
return { data: JSON.parse(settings) as DeepPartial<
|
|
54
|
+
return { data: JSON.parse(settings) as DeepPartial<UserSettings> };
|
|
55
55
|
} catch (e) {
|
|
56
56
|
return { message: JSON.stringify(e) };
|
|
57
57
|
}
|
|
@@ -2,8 +2,8 @@ import { DeepPartial } from 'utility-types';
|
|
|
2
2
|
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { UserModel } from '@/database/client/models/user';
|
|
5
|
-
import { GlobalSettings } from '@/types/settings';
|
|
6
5
|
import { UserPreference } from '@/types/user';
|
|
6
|
+
import { UserSettings } from '@/types/user/settings';
|
|
7
7
|
import { AsyncLocalStorage } from '@/utils/localStorage';
|
|
8
8
|
|
|
9
9
|
import { ClientService } from './client';
|
|
@@ -19,7 +19,7 @@ vi.mock('@/database/client/models/user', () => ({
|
|
|
19
19
|
|
|
20
20
|
const mockUser = {
|
|
21
21
|
avatar: 'avatar.png',
|
|
22
|
-
settings: { themeMode: 'light' } as unknown as
|
|
22
|
+
settings: { themeMode: 'light' } as unknown as UserSettings,
|
|
23
23
|
uuid: 'user-id',
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -58,7 +58,7 @@ describe('ClientService', () => {
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
it('should update user settings correctly', async () => {
|
|
61
|
-
const settingsPatch: DeepPartial<
|
|
61
|
+
const settingsPatch: DeepPartial<UserSettings> = { themeMode: 'dark' };
|
|
62
62
|
(UserModel.updateSettings as Mock).mockResolvedValue(undefined);
|
|
63
63
|
|
|
64
64
|
await clientService.updateUserSettings(settingsPatch);
|
|
@@ -3,8 +3,8 @@ import { DeepPartial } from 'utility-types';
|
|
|
3
3
|
import { MessageModel } from '@/database/client/models/message';
|
|
4
4
|
import { SessionModel } from '@/database/client/models/session';
|
|
5
5
|
import { UserModel } from '@/database/client/models/user';
|
|
6
|
-
import { GlobalSettings } from '@/types/settings';
|
|
7
6
|
import { UserInitializationState, UserPreference } from '@/types/user';
|
|
7
|
+
import { UserSettings } from '@/types/user/settings';
|
|
8
8
|
import { AsyncLocalStorage } from '@/utils/localStorage';
|
|
9
9
|
|
|
10
10
|
import { IUserService } from './type';
|
|
@@ -28,12 +28,12 @@ export class ClientService implements IUserService {
|
|
|
28
28
|
hasConversation: messageCount > 0 || sessionCount > 0,
|
|
29
29
|
isOnboard: true,
|
|
30
30
|
preference: await this.preferenceStorage.getFromLocalStorage(),
|
|
31
|
-
settings: user.settings as
|
|
31
|
+
settings: user.settings as UserSettings,
|
|
32
32
|
userId: user.uuid,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
updateUserSettings = async (patch: DeepPartial<
|
|
36
|
+
updateUserSettings = async (patch: DeepPartial<UserSettings>) => {
|
|
37
37
|
return UserModel.updateSettings(patch);
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DeepPartial } from 'utility-types';
|
|
2
2
|
|
|
3
|
-
import { GlobalSettings } from '@/types/settings';
|
|
4
3
|
import { UserInitializationState, UserPreference } from '@/types/user';
|
|
4
|
+
import { UserSettings } from '@/types/user/settings';
|
|
5
5
|
|
|
6
6
|
export interface IUserService {
|
|
7
7
|
getUserState: () => Promise<UserInitializationState>;
|
|
8
8
|
resetUserSettings: () => Promise<any>;
|
|
9
9
|
updatePreference: (preference: UserPreference) => Promise<any>;
|
|
10
|
-
updateUserSettings: (patch: DeepPartial<
|
|
10
|
+
updateUserSettings: (patch: DeepPartial<UserSettings>) => Promise<any>;
|
|
11
11
|
}
|
package/src/store/agent/store.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { devtools } from 'zustand/middleware';
|
|
2
1
|
import { shallow } from 'zustand/shallow';
|
|
3
2
|
import { createWithEqualityFn } from 'zustand/traditional';
|
|
4
3
|
import { StateCreator } from 'zustand/vanilla';
|
|
5
4
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { createDevtools } from '../middleware/createDevtools';
|
|
8
6
|
import { SessionStoreState, initialState } from './initialState';
|
|
9
7
|
import { AgentChatAction, createChatSlice } from './slices/chat/action';
|
|
10
8
|
|
|
@@ -19,9 +17,6 @@ const createStore: StateCreator<AgentStore, [['zustand/devtools', never]]> = (..
|
|
|
19
17
|
|
|
20
18
|
// =============== implement useStore ============ //
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
shallow,
|
|
27
|
-
);
|
|
20
|
+
const devtools = createDevtools('agent');
|
|
21
|
+
|
|
22
|
+
export const useAgentStore = createWithEqualityFn<AgentStore>()(devtools(createStore), shallow);
|
package/src/store/chat/store.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subscribeWithSelector } from 'zustand/middleware';
|
|
2
2
|
import { shallow } from 'zustand/shallow';
|
|
3
3
|
import { createWithEqualityFn } from 'zustand/traditional';
|
|
4
4
|
import { StateCreator } from 'zustand/vanilla';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { createDevtools } from '../middleware/createDevtools';
|
|
8
7
|
import { ChatStoreState, initialState } from './initialState';
|
|
9
8
|
import { ChatBuiltinToolAction, chatToolSlice } from './slices/builtinTool/action';
|
|
10
9
|
import { ChatEnhanceAction, chatEnhance } from './slices/enchance/action';
|
|
@@ -37,12 +36,9 @@ const createStore: StateCreator<ChatStore, [['zustand/devtools', never]]> = (...
|
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
// =============== 实装 useStore ============ //
|
|
39
|
+
const devtools = createDevtools('chat');
|
|
40
40
|
|
|
41
41
|
export const useChatStore = createWithEqualityFn<ChatStore>()(
|
|
42
|
-
subscribeWithSelector(
|
|
43
|
-
devtools(createStore, {
|
|
44
|
-
name: 'LobeChat_Chat' + (isDev ? '_DEV' : ''),
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
42
|
+
subscribeWithSelector(devtools(createStore)),
|
|
47
43
|
shallow,
|
|
48
44
|
);
|
package/src/store/file/store.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { devtools } from 'zustand/middleware';
|
|
2
1
|
import { shallow } from 'zustand/shallow';
|
|
3
2
|
import { createWithEqualityFn } from 'zustand/traditional';
|
|
4
3
|
import { StateCreator } from 'zustand/vanilla';
|
|
5
4
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { createDevtools } from '../middleware/createDevtools';
|
|
8
6
|
import { FilesStoreState, initialState } from './initialState';
|
|
9
7
|
import { FileAction, createFileSlice } from './slices/images';
|
|
10
8
|
import { TTSFileAction, createTTSFileSlice } from './slices/tts';
|
|
@@ -20,10 +18,6 @@ const createStore: StateCreator<FileStore, [['zustand/devtools', never]]> = (...
|
|
|
20
18
|
});
|
|
21
19
|
|
|
22
20
|
// =============== 实装 useStore ============ //
|
|
21
|
+
const devtools = createDevtools('file');
|
|
23
22
|
|
|
24
|
-
export const useFileStore = createWithEqualityFn<FileStore>()(
|
|
25
|
-
devtools(createStore, {
|
|
26
|
-
name: 'LobeChat_File' + (isDev ? '_DEV' : ''),
|
|
27
|
-
}),
|
|
28
|
-
shallow,
|
|
29
|
-
);
|
|
23
|
+
export const useFileStore = createWithEqualityFn<FileStore>()(devtools(createStore), shallow);
|