@lobehub/chat 0.149.3 → 0.149.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/.github/FUNDING.yml +1 -1
- package/CHANGELOG.md +58 -0
- package/package.json +1 -1
- package/src/app/chat/(desktop)/features/ChatHeader/Main.tsx +5 -5
- package/src/app/chat/(desktop)/features/ChatHeader/Tags.tsx +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/Footer/DragUpload.tsx +9 -9
- package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +3 -3
- package/src/app/chat/(desktop)/features/SideBar/SystemRole/index.tsx +8 -3
- package/src/app/chat/(mobile)/mobile/ChatHeader/ChatHeaderTitle.tsx +2 -2
- package/src/app/chat/(mobile)/mobile/page.tsx +0 -6
- package/src/app/chat/_layout/Desktop/SessionList.tsx +2 -0
- package/src/app/chat/features/PageTitle/index.tsx +3 -3
- package/src/app/chat/features/PluginTag/PluginStatus.tsx +2 -2
- package/src/app/chat/features/SessionListContent/DefaultMode.tsx +4 -2
- package/src/app/chat/features/SessionListContent/List/Item/index.tsx +10 -17
- package/src/app/chat/features/SessionListContent/index.tsx +2 -0
- package/src/app/chat/features/ShareButton/Preview.tsx +15 -11
- package/src/app/chat/features/ShareButton/useScreenshot.ts +2 -2
- package/src/app/chat/settings/features/EditPage.tsx +10 -7
- package/src/app/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +5 -3
- package/src/app/metadata.ts +3 -3
- package/src/app/settings/(mobile)/features/AvatarBanner.tsx +1 -0
- package/src/config/modelProviders/ollama.ts +11 -12
- package/src/const/session.ts +1 -0
- package/src/database/client/models/session.ts +1 -0
- package/src/database/client/models/user.ts +6 -0
- package/src/features/ChatInput/ActionBar/FileUpload.tsx +11 -5
- package/src/features/ChatInput/ActionBar/History.tsx +3 -3
- package/src/features/ChatInput/ActionBar/ModelSwitch.tsx +2 -0
- package/src/features/ChatInput/ActionBar/Temperature.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +4 -4
- package/src/features/ChatInput/ActionBar/Token/index.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Tools/ToolItem.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Tools/index.tsx +4 -4
- package/src/features/ChatInput/STT/browser.tsx +3 -3
- package/src/features/ChatInput/STT/openai.tsx +3 -3
- package/src/features/ChatInput/useChatInput.ts +3 -3
- package/src/features/Conversation/Extras/Assistant.test.tsx +7 -7
- package/src/features/Conversation/Extras/Assistant.tsx +3 -3
- package/src/features/Conversation/Extras/TTS/index.tsx +3 -3
- package/src/features/Conversation/components/ChatItem/ActionsBar.tsx +2 -2
- package/src/features/Conversation/components/ChatItem/index.tsx +6 -4
- package/src/features/Conversation/hooks/useInitConversation.ts +10 -7
- package/src/features/Conversation/index.tsx +6 -3
- package/src/features/ModelSwitchPanel/index.tsx +6 -4
- package/src/hooks/useTTS.ts +4 -4
- package/src/libs/agent-runtime/anthropic/index.test.ts +44 -32
- package/src/libs/agent-runtime/anthropic/index.ts +12 -9
- package/src/libs/agent-runtime/azureOpenai/index.ts +3 -4
- package/src/libs/agent-runtime/bedrock/index.ts +1 -1
- package/src/libs/agent-runtime/ollama/index.ts +7 -0
- package/src/libs/agent-runtime/perplexity/index.ts +1 -0
- package/src/libs/agent-runtime/types/chat.ts +2 -1
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +1 -0
- package/src/services/chat.ts +18 -15
- package/src/services/session/client.ts +19 -0
- package/src/services/session/type.ts +2 -0
- package/src/store/agent/index.ts +2 -0
- package/src/store/agent/initialState.ts +7 -0
- package/src/store/agent/selectors.ts +1 -0
- package/src/store/{session/slices/agent → agent/slices/chat}/action.test.ts +26 -63
- package/src/store/agent/slices/chat/action.ts +107 -0
- package/src/store/agent/slices/chat/initialState.ts +14 -0
- package/src/store/agent/slices/chat/selectors.test.ts +82 -0
- package/src/store/agent/slices/chat/selectors.ts +81 -0
- package/src/store/agent/store.ts +27 -0
- package/src/store/chat/slices/message/action.test.ts +3 -2
- package/src/store/chat/slices/message/action.ts +3 -3
- package/src/store/chat/slices/message/selectors.test.ts +9 -2
- package/src/store/chat/slices/message/selectors.ts +6 -4
- package/src/store/chat/slices/share/action.ts +5 -3
- package/src/store/global/slices/preference/selectors.ts +3 -1
- package/src/store/session/selectors.ts +1 -2
- package/src/store/session/slices/session/action.test.ts +43 -0
- package/src/store/session/slices/session/action.ts +28 -18
- package/src/store/session/slices/session/helpers.ts +2 -3
- package/src/store/session/slices/session/initialState.ts +1 -17
- package/src/store/session/slices/session/selectors/index.ts +1 -0
- package/src/store/session/slices/session/selectors/list.test.ts +5 -3
- package/src/store/session/slices/session/selectors/list.ts +2 -3
- package/src/store/session/slices/session/selectors/meta.test.ts +108 -0
- package/src/store/session/slices/session/selectors/meta.ts +45 -0
- package/src/store/session/store.ts +1 -7
- package/src/types/session.ts +1 -0
- package/src/store/session/slices/agent/action.ts +0 -84
- package/src/store/session/slices/agent/selectors.test.ts +0 -180
- package/src/store/session/slices/agent/selectors.ts +0 -129
- /package/src/store/{session/slices/agent → agent/slices/chat}/index.ts +0 -0
package/.github/FUNDING.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# These are supported funding model platforms
|
|
2
2
|
|
|
3
|
-
github:
|
|
3
|
+
github: lobehub
|
|
4
4
|
patreon: # Replace with a single Patreon username
|
|
5
5
|
open_collective: lobehub
|
|
6
6
|
ko_fi: # Replace with a single Ko-fi username
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.149.5](https://github.com/lobehub/lobe-chat/compare/v0.149.4...v0.149.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-04-25**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Sperate SessionStore to a new AgentStore.
|
|
12
|
+
|
|
13
|
+
#### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **misc**: Fix not handle ollama error correctly.
|
|
16
|
+
|
|
17
|
+
<br/>
|
|
18
|
+
|
|
19
|
+
<details>
|
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
21
|
+
|
|
22
|
+
#### Code refactoring
|
|
23
|
+
|
|
24
|
+
- **misc**: Sperate SessionStore to a new AgentStore, closes [#2197](https://github.com/lobehub/lobe-chat/issues/2197) ([49c0ba6](https://github.com/lobehub/lobe-chat/commit/49c0ba6))
|
|
25
|
+
|
|
26
|
+
#### What's fixed
|
|
27
|
+
|
|
28
|
+
- **misc**: Fix not handle ollama error correctly ([efdf174](https://github.com/lobehub/lobe-chat/commit/efdf174))
|
|
29
|
+
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
<div align="right">
|
|
33
|
+
|
|
34
|
+
[](#readme-top)
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
### [Version 0.149.4](https://github.com/lobehub/lobe-chat/compare/v0.149.3...v0.149.4)
|
|
39
|
+
|
|
40
|
+
<sup>Released on **2024-04-25**</sup>
|
|
41
|
+
|
|
42
|
+
#### 🐛 Bug Fixes
|
|
43
|
+
|
|
44
|
+
- **misc**: Fix chat client request not support abort.
|
|
45
|
+
|
|
46
|
+
<br/>
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
50
|
+
|
|
51
|
+
#### What's fixed
|
|
52
|
+
|
|
53
|
+
- **misc**: Fix chat client request not support abort, closes [#2193](https://github.com/lobehub/lobe-chat/issues/2193) ([d22ef2c](https://github.com/lobehub/lobe-chat/commit/d22ef2c))
|
|
54
|
+
|
|
55
|
+
</details>
|
|
56
|
+
|
|
57
|
+
<div align="right">
|
|
58
|
+
|
|
59
|
+
[](#readme-top)
|
|
60
|
+
|
|
61
|
+
</div>
|
|
62
|
+
|
|
5
63
|
### [Version 0.149.3](https://github.com/lobehub/lobe-chat/compare/v0.149.2...v0.149.3)
|
|
6
64
|
|
|
7
65
|
<sup>Released on **2024-04-25**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.149.
|
|
3
|
+
"version": "0.149.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",
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import { Flexbox } from 'react-layout-kit';
|
|
7
7
|
|
|
8
8
|
import { useSessionStore } from '@/store/session';
|
|
9
|
-
import {
|
|
9
|
+
import { sessionMetaSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
10
10
|
import { pathString } from '@/utils/url';
|
|
11
11
|
|
|
12
12
|
import Tags from './Tags';
|
|
@@ -19,10 +19,10 @@ const Main = memo(() => {
|
|
|
19
19
|
const [init, isInbox, title, description, avatar, backgroundColor] = useSessionStore((s) => [
|
|
20
20
|
sessionSelectors.isSomeSessionActive(s),
|
|
21
21
|
sessionSelectors.isInboxSession(s),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
sessionMetaSelectors.currentAgentTitle(s),
|
|
23
|
+
sessionMetaSelectors.currentAgentDescription(s),
|
|
24
|
+
sessionMetaSelectors.currentAgentAvatar(s),
|
|
25
|
+
sessionMetaSelectors.currentAgentBackgroundColor(s),
|
|
26
26
|
]);
|
|
27
27
|
|
|
28
28
|
const displayTitle = isInbox ? t('inbox.title') : title;
|
|
@@ -3,15 +3,15 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
3
3
|
|
|
4
4
|
import ModelTag from '@/components/ModelTag';
|
|
5
5
|
import ModelSwitchPanel from '@/features/ModelSwitchPanel';
|
|
6
|
+
import { useAgentStore } from '@/store/agent';
|
|
7
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
|
6
8
|
import { useGlobalStore } from '@/store/global';
|
|
7
9
|
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
8
|
-
import { useSessionStore } from '@/store/session';
|
|
9
|
-
import { agentSelectors } from '@/store/session/selectors';
|
|
10
10
|
|
|
11
11
|
import PluginTag from '../../../features/PluginTag';
|
|
12
12
|
|
|
13
13
|
const TitleTags = memo(() => {
|
|
14
|
-
const [model, plugins] =
|
|
14
|
+
const [model, plugins] = useAgentStore((s) => [
|
|
15
15
|
agentSelectors.currentAgentModel(s),
|
|
16
16
|
agentSelectors.currentAgentPlugins(s),
|
|
17
17
|
]);
|
|
@@ -6,11 +6,11 @@ import { memo, useEffect, useRef, useState } from 'react';
|
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
|
+
import { useAgentStore } from '@/store/agent';
|
|
10
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
|
9
11
|
import { useFileStore } from '@/store/file';
|
|
10
12
|
import { useGlobalStore } from '@/store/global';
|
|
11
13
|
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
12
|
-
import { useSessionStore } from '@/store/session';
|
|
13
|
-
import { agentSelectors } from '@/store/session/selectors';
|
|
14
14
|
|
|
15
15
|
const useStyles = createStyles(({ css, token, stylish }) => {
|
|
16
16
|
return {
|
|
@@ -60,8 +60,6 @@ const useStyles = createStyles(({ css, token, stylish }) => {
|
|
|
60
60
|
};
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
63
|
const handleDragOver = (e: DragEvent) => {
|
|
66
64
|
e.preventDefault();
|
|
67
65
|
};
|
|
@@ -77,7 +75,7 @@ const DragUpload = memo(() => {
|
|
|
77
75
|
|
|
78
76
|
const uploadFile = useFileStore((s) => s.uploadFile);
|
|
79
77
|
|
|
80
|
-
const model =
|
|
78
|
+
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
81
79
|
|
|
82
80
|
const enabledFiles = useGlobalStore(modelProviderSelectors.isModelEnabledFiles(model));
|
|
83
81
|
|
|
@@ -136,7 +134,6 @@ const DragUpload = memo(() => {
|
|
|
136
134
|
uploadImages(files);
|
|
137
135
|
};
|
|
138
136
|
|
|
139
|
-
|
|
140
137
|
useEffect(() => {
|
|
141
138
|
window.addEventListener('dragenter', handleDragEnter);
|
|
142
139
|
window.addEventListener('dragover', handleDragOver);
|
|
@@ -164,8 +161,12 @@ const DragUpload = memo(() => {
|
|
|
164
161
|
<Icon icon={FileText} size={{ fontSize: 64, strokeWidth: 1 }} />
|
|
165
162
|
</Flexbox>
|
|
166
163
|
<Flexbox align={'center'} gap={8} style={{ textAlign: 'center' }}>
|
|
167
|
-
<Flexbox className={styles.title}>
|
|
168
|
-
|
|
164
|
+
<Flexbox className={styles.title}>
|
|
165
|
+
{t(enabledFiles ? 'upload.dragFileTitle' : 'upload.dragTitle')}
|
|
166
|
+
</Flexbox>
|
|
167
|
+
<Flexbox className={styles.desc}>
|
|
168
|
+
{t(enabledFiles ? 'upload.dragFileDesc' : 'upload.dragDesc')}
|
|
169
|
+
</Flexbox>
|
|
169
170
|
</Flexbox>
|
|
170
171
|
</Center>
|
|
171
172
|
</div>
|
|
@@ -175,4 +176,3 @@ const DragUpload = memo(() => {
|
|
|
175
176
|
});
|
|
176
177
|
|
|
177
178
|
export default DragUpload;
|
|
178
|
-
|
|
@@ -10,11 +10,11 @@ import { Center, Flexbox } from 'react-layout-kit';
|
|
|
10
10
|
import StopLoadingIcon from '@/components/StopLoading';
|
|
11
11
|
import SaveTopic from '@/features/ChatInput/Topic';
|
|
12
12
|
import { useSendMessage } from '@/features/ChatInput/useSend';
|
|
13
|
+
import { useAgentStore } from '@/store/agent';
|
|
14
|
+
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
13
15
|
import { useChatStore } from '@/store/chat';
|
|
14
16
|
import { useGlobalStore } from '@/store/global';
|
|
15
17
|
import { modelProviderSelectors, preferenceSelectors } from '@/store/global/selectors';
|
|
16
|
-
import { useSessionStore } from '@/store/session';
|
|
17
|
-
import { agentSelectors } from '@/store/session/selectors';
|
|
18
18
|
import { isMacOS } from '@/utils/platform';
|
|
19
19
|
|
|
20
20
|
import DragUpload from './DragUpload';
|
|
@@ -64,7 +64,7 @@ const Footer = memo<FooterProps>(({ setExpand }) => {
|
|
|
64
64
|
s.stopGenerateMessage,
|
|
65
65
|
]);
|
|
66
66
|
|
|
67
|
-
const model =
|
|
67
|
+
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
68
68
|
|
|
69
69
|
const [useCmdEnterToSend, canUpload] = useGlobalStore((s) => [
|
|
70
70
|
preferenceSelectors.useCmdEnterToSend(s),
|
|
@@ -8,9 +8,11 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
8
8
|
import useMergeState from 'use-merge-value';
|
|
9
9
|
|
|
10
10
|
import AgentInfo from '@/features/AgentInfo';
|
|
11
|
+
import { useAgentStore } from '@/store/agent';
|
|
12
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
|
11
13
|
import { useGlobalStore } from '@/store/global';
|
|
12
14
|
import { useSessionStore } from '@/store/session';
|
|
13
|
-
import {
|
|
15
|
+
import { sessionMetaSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
14
16
|
import { pathString } from '@/utils/url';
|
|
15
17
|
|
|
16
18
|
import SidebarHeader from '../../../../components/SidebarHeader';
|
|
@@ -21,10 +23,13 @@ const SystemRole = memo(() => {
|
|
|
21
23
|
const [editing, setEditing] = useState(false);
|
|
22
24
|
const { styles } = useStyles();
|
|
23
25
|
|
|
24
|
-
const [init,
|
|
26
|
+
const [init, meta] = useSessionStore((s) => [
|
|
25
27
|
sessionSelectors.isSomeSessionActive(s),
|
|
28
|
+
sessionMetaSelectors.currentAgentMeta(s),
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const [systemRole, updateAgentConfig] = useAgentStore((s) => [
|
|
26
32
|
agentSelectors.currentAgentSystemRole(s),
|
|
27
|
-
agentSelectors.currentAgentMeta(s),
|
|
28
33
|
s.updateAgentConfig,
|
|
29
34
|
]);
|
|
30
35
|
|
|
@@ -9,7 +9,7 @@ import { useChatStore } from '@/store/chat';
|
|
|
9
9
|
import { topicSelectors } from '@/store/chat/selectors';
|
|
10
10
|
import { useGlobalStore } from '@/store/global';
|
|
11
11
|
import { useSessionStore } from '@/store/session';
|
|
12
|
-
import {
|
|
12
|
+
import { sessionMetaSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
13
13
|
|
|
14
14
|
const ChatHeaderTitle = memo(() => {
|
|
15
15
|
const { t } = useTranslation('chat');
|
|
@@ -20,7 +20,7 @@ const ChatHeaderTitle = memo(() => {
|
|
|
20
20
|
]);
|
|
21
21
|
const [isInbox, title] = useSessionStore((s) => [
|
|
22
22
|
sessionSelectors.isInboxSession(s),
|
|
23
|
-
|
|
23
|
+
sessionMetaSelectors.currentAgentTitle(s),
|
|
24
24
|
]);
|
|
25
25
|
const theme = useTheme();
|
|
26
26
|
|
|
@@ -5,7 +5,6 @@ import { memo } from 'react';
|
|
|
5
5
|
import { Flexbox } from 'react-layout-kit';
|
|
6
6
|
|
|
7
7
|
import Conversation from '@/features/Conversation';
|
|
8
|
-
import { useSessionStore } from '@/store/session';
|
|
9
8
|
|
|
10
9
|
import SessionHydration from '../../components/SessionHydration';
|
|
11
10
|
import TelemetryNotification from '../../features/TelemetryNotification';
|
|
@@ -15,11 +14,6 @@ import ChatHeader from './ChatHeader';
|
|
|
15
14
|
const TopicList = dynamic(() => import('../features/TopicList'));
|
|
16
15
|
|
|
17
16
|
const Chat = memo(() => {
|
|
18
|
-
// due to mobile side don't have sessionList, so we need to fetch sessions here
|
|
19
|
-
// refs: https://github.com/lobehub/lobe-chat/pull/541
|
|
20
|
-
const useFetchSessions = useSessionStore((s) => s.useFetchSessions);
|
|
21
|
-
useFetchSessions();
|
|
22
|
-
|
|
23
17
|
return (
|
|
24
18
|
<>
|
|
25
19
|
<ChatHeader />
|
|
@@ -4,12 +4,12 @@ import { memo } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import PageTitle from '@/components/PageTitle';
|
|
6
6
|
import { useSessionStore } from '@/store/session';
|
|
7
|
-
import {
|
|
7
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
8
8
|
|
|
9
9
|
const Title = memo(() => {
|
|
10
10
|
const [avatar, title] = useSessionStore((s) => [
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
sessionMetaSelectors.currentAgentAvatar(s),
|
|
12
|
+
sessionMetaSelectors.currentAgentTitle(s),
|
|
13
13
|
]);
|
|
14
14
|
|
|
15
15
|
return <PageTitle title={[avatar, title].filter(Boolean).join(' ')} />;
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import ManifestPreviewer from '@/components/ManifestPreviewer';
|
|
10
|
-
import {
|
|
10
|
+
import { useAgentStore } from '@/store/agent';
|
|
11
11
|
import { useToolStore } from '@/store/tool';
|
|
12
12
|
import { customPluginSelectors, toolSelectors } from '@/store/tool/selectors';
|
|
13
13
|
|
|
@@ -26,7 +26,7 @@ const PluginStatus = memo<PluginStatusProps>(({ title, id, deprecated }) => {
|
|
|
26
26
|
|
|
27
27
|
const manifest = useToolStore(toolSelectors.getManifestById(id), isEqual);
|
|
28
28
|
|
|
29
|
-
const removePlugin =
|
|
29
|
+
const removePlugin = useAgentStore((s) => s.removePlugin);
|
|
30
30
|
|
|
31
31
|
const renderStatus = useMemo(() => {
|
|
32
32
|
switch (status) {
|
|
@@ -16,7 +16,7 @@ import SessionList from './List';
|
|
|
16
16
|
import ConfigGroupModal from './Modals/ConfigGroupModal';
|
|
17
17
|
import RenameGroupModal from './Modals/RenameGroupModal';
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const SessionDefaultMode = memo(() => {
|
|
20
20
|
const { t } = useTranslation('chat');
|
|
21
21
|
|
|
22
22
|
const [activeGroupId, setActiveGroupId] = useState<string>();
|
|
@@ -98,4 +98,6 @@ const SessionListContent = memo(() => {
|
|
|
98
98
|
);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
SessionDefaultMode.displayName = 'SessionDefaultMode';
|
|
102
|
+
|
|
103
|
+
export default SessionDefaultMode;
|
|
@@ -4,11 +4,9 @@ import { shallow } from 'zustand/shallow';
|
|
|
4
4
|
|
|
5
5
|
import ModelTag from '@/components/ModelTag';
|
|
6
6
|
import { useChatStore } from '@/store/chat';
|
|
7
|
-
import { useGlobalStore } from '@/store/global';
|
|
8
|
-
import { settingsSelectors } from '@/store/global/selectors';
|
|
9
7
|
import { useSessionStore } from '@/store/session';
|
|
10
8
|
import { sessionHelpers } from '@/store/session/helpers';
|
|
11
|
-
import {
|
|
9
|
+
import { sessionMetaSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
12
10
|
|
|
13
11
|
import ListItem from '../../ListItem';
|
|
14
12
|
import CreateGroupModal from '../../Modals/CreateGroupModal';
|
|
@@ -22,31 +20,26 @@ const SessionItem = memo<SessionItemProps>(({ id }) => {
|
|
|
22
20
|
const [open, setOpen] = useState(false);
|
|
23
21
|
const [createGroupModalOpen, setCreateGroupModalOpen] = useState(false);
|
|
24
22
|
|
|
25
|
-
const [defaultModel] = useGlobalStore((s) => [settingsSelectors.defaultAgentConfig(s).model]);
|
|
26
23
|
const [active] = useSessionStore((s) => [s.activeId === id]);
|
|
27
24
|
const [loading] = useChatStore((s) => [!!s.chatLoadingId && id === s.activeId]);
|
|
28
25
|
|
|
29
|
-
const [pin, title, description,
|
|
26
|
+
const [pin, title, description, avatar, avatarBackground, updateAt, model, group] =
|
|
30
27
|
useSessionStore((s) => {
|
|
31
28
|
const session = sessionSelectors.getSessionById(id)(s);
|
|
32
29
|
const meta = session.meta;
|
|
33
|
-
const systemRole = session.config.systemRole;
|
|
34
30
|
|
|
35
31
|
return [
|
|
36
32
|
sessionHelpers.getSessionPinned(session),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
agentSelectors.getAvatar(meta),
|
|
33
|
+
sessionMetaSelectors.getTitle(meta),
|
|
34
|
+
sessionMetaSelectors.getDescription(meta),
|
|
35
|
+
sessionMetaSelectors.getAvatar(meta),
|
|
41
36
|
meta.backgroundColor,
|
|
42
37
|
session?.updatedAt,
|
|
43
|
-
session.
|
|
38
|
+
session.model,
|
|
44
39
|
session?.group,
|
|
45
40
|
];
|
|
46
41
|
});
|
|
47
42
|
|
|
48
|
-
const showModel = model !== defaultModel;
|
|
49
|
-
|
|
50
43
|
const actions = useMemo(
|
|
51
44
|
() => (
|
|
52
45
|
<Actions
|
|
@@ -61,12 +54,12 @@ const SessionItem = memo<SessionItemProps>(({ id }) => {
|
|
|
61
54
|
|
|
62
55
|
const addon = useMemo(
|
|
63
56
|
() =>
|
|
64
|
-
|
|
57
|
+
model && (
|
|
65
58
|
<Flexbox gap={4} horizontal style={{ flexWrap: 'wrap' }}>
|
|
66
|
-
|
|
59
|
+
<ModelTag model={model} />
|
|
67
60
|
</Flexbox>
|
|
68
61
|
),
|
|
69
|
-
[
|
|
62
|
+
[model],
|
|
70
63
|
);
|
|
71
64
|
|
|
72
65
|
return (
|
|
@@ -78,7 +71,7 @@ const SessionItem = memo<SessionItemProps>(({ id }) => {
|
|
|
78
71
|
avatar={avatar}
|
|
79
72
|
avatarBackground={avatarBackground}
|
|
80
73
|
date={updateAt}
|
|
81
|
-
description={description
|
|
74
|
+
description={description}
|
|
82
75
|
loading={loading}
|
|
83
76
|
pin={pin}
|
|
84
77
|
showAction={open}
|
|
@@ -6,8 +6,10 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
6
6
|
import pkg from '@/../package.json';
|
|
7
7
|
import ModelTag from '@/components/ModelTag';
|
|
8
8
|
import ChatList from '@/features/Conversation/components/ChatList';
|
|
9
|
+
import { useAgentStore } from '@/store/agent';
|
|
10
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
|
9
11
|
import { useSessionStore } from '@/store/session';
|
|
10
|
-
import {
|
|
12
|
+
import { sessionMetaSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
11
13
|
|
|
12
14
|
import PluginTag from '../PluginTag';
|
|
13
15
|
import { useStyles } from './style';
|
|
@@ -15,16 +17,18 @@ import { FieldType } from './type';
|
|
|
15
17
|
|
|
16
18
|
const Preview = memo<FieldType & { title?: string }>(
|
|
17
19
|
({ title, withSystemRole, withBackground, withFooter }) => {
|
|
18
|
-
const [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const [model, plugins, systemRole] = useAgentStore((s) => [
|
|
21
|
+
agentSelectors.currentAgentModel(s),
|
|
22
|
+
agentSelectors.currentAgentPlugins(s),
|
|
23
|
+
agentSelectors.currentAgentSystemRole(s),
|
|
24
|
+
]);
|
|
25
|
+
const [isInbox, description, avatar, backgroundColor] = useSessionStore((s) => [
|
|
26
|
+
sessionSelectors.isInboxSession(s),
|
|
27
|
+
sessionMetaSelectors.currentAgentDescription(s),
|
|
28
|
+
sessionMetaSelectors.currentAgentAvatar(s),
|
|
29
|
+
sessionMetaSelectors.currentAgentBackgroundColor(s),
|
|
30
|
+
]);
|
|
31
|
+
|
|
28
32
|
const { t } = useTranslation('chat');
|
|
29
33
|
const { styles } = useStyles(withBackground);
|
|
30
34
|
|
|
@@ -3,13 +3,13 @@ import { domToJpeg, domToPng, domToSvg, domToWebp } from 'modern-screenshot';
|
|
|
3
3
|
import { useCallback, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { useSessionStore } from '@/store/session';
|
|
6
|
-
import {
|
|
6
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
7
7
|
|
|
8
8
|
import { ImageType } from './type';
|
|
9
9
|
|
|
10
10
|
export const useScreenshot = (imageType: ImageType) => {
|
|
11
11
|
const [loading, setLoading] = useState(false);
|
|
12
|
-
const title = useSessionStore(
|
|
12
|
+
const title = useSessionStore(sessionMetaSelectors.currentAgentTitle);
|
|
13
13
|
|
|
14
14
|
const handleDownload = useCallback(async () => {
|
|
15
15
|
setLoading(true);
|
|
@@ -6,18 +6,21 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
|
|
7
7
|
import PageTitle from '@/components/PageTitle';
|
|
8
8
|
import AgentSetting from '@/features/AgentSetting';
|
|
9
|
+
import { useAgentStore } from '@/store/agent';
|
|
10
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
|
9
11
|
import { useSessionStore } from '@/store/session';
|
|
10
|
-
import {
|
|
12
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
11
13
|
|
|
12
14
|
const EditPage = memo(() => {
|
|
13
15
|
const { t } = useTranslation('setting');
|
|
14
16
|
const id = useSessionStore((s) => s.activeId);
|
|
15
|
-
const config =
|
|
16
|
-
const meta = useSessionStore(
|
|
17
|
-
const [updateAgentConfig
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const config = useAgentStore(agentSelectors.currentAgentConfig, isEqual);
|
|
18
|
+
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
|
19
|
+
const [updateAgentConfig] = useAgentStore((s) => [s.updateAgentConfig]);
|
|
20
|
+
|
|
21
|
+
const [updateAgentMeta, title] = useSessionStore((s) => [
|
|
22
|
+
s.updateSessionMeta,
|
|
23
|
+
sessionMetaSelectors.currentAgentTitle(s),
|
|
21
24
|
]);
|
|
22
25
|
|
|
23
26
|
return (
|
|
@@ -10,17 +10,19 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
10
10
|
|
|
11
11
|
import { AGENTS_INDEX_GITHUB_ISSUE } from '@/const/url';
|
|
12
12
|
import AgentInfo from '@/features/AgentInfo';
|
|
13
|
+
import { useAgentStore } from '@/store/agent';
|
|
14
|
+
import { agentSelectors } from '@/store/agent/selectors';
|
|
13
15
|
import { useGlobalStore } from '@/store/global';
|
|
14
16
|
import { settingsSelectors } from '@/store/global/selectors';
|
|
15
17
|
import { useSessionStore } from '@/store/session';
|
|
16
|
-
import {
|
|
18
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
17
19
|
|
|
18
20
|
const SubmitAgentModal = memo<ModalProps>(({ open, onCancel }) => {
|
|
19
21
|
const { t } = useTranslation('setting');
|
|
20
22
|
const [identifier, setIdentifier] = useState('');
|
|
21
|
-
const systemRole =
|
|
23
|
+
const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
|
|
22
24
|
const theme = useTheme();
|
|
23
|
-
const meta = useSessionStore(
|
|
25
|
+
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
|
24
26
|
const language = useGlobalStore((s) => settingsSelectors.currentSettings(s).language);
|
|
25
27
|
|
|
26
28
|
const isMetaPass = Boolean(
|
package/src/app/metadata.ts
CHANGED
|
@@ -22,9 +22,9 @@ const metadata: Metadata = {
|
|
|
22
22
|
},
|
|
23
23
|
description,
|
|
24
24
|
icons: {
|
|
25
|
-
apple:'icons/apple-touch-icon.png',
|
|
26
|
-
icon:'favicon.ico',
|
|
27
|
-
shortcut:'favicon-32x32.ico',
|
|
25
|
+
apple: '/icons/apple-touch-icon.png',
|
|
26
|
+
icon: '/favicon.ico',
|
|
27
|
+
shortcut: '/favicon-32x32.ico',
|
|
28
28
|
},
|
|
29
29
|
manifest: noManifest ? undefined : '/manifest.json',
|
|
30
30
|
metadataBase: new URL(SITE_URL),
|
|
@@ -2,6 +2,17 @@ import { ModelProviderCard } from '@/types/llm';
|
|
|
2
2
|
|
|
3
3
|
const Ollama: ModelProviderCard = {
|
|
4
4
|
chatModels: [
|
|
5
|
+
{
|
|
6
|
+
displayName: 'Llama3 8B',
|
|
7
|
+
enabled: true,
|
|
8
|
+
id: 'llama3',
|
|
9
|
+
tokens: 8000,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Llama3 70B',
|
|
13
|
+
id: 'llama3:70b',
|
|
14
|
+
tokens: 8000,
|
|
15
|
+
},
|
|
5
16
|
{
|
|
6
17
|
displayName: 'Command R 35B',
|
|
7
18
|
enabled: true,
|
|
@@ -21,7 +32,6 @@ const Ollama: ModelProviderCard = {
|
|
|
21
32
|
},
|
|
22
33
|
{
|
|
23
34
|
displayName: 'Gemma 2B',
|
|
24
|
-
enabled: true,
|
|
25
35
|
id: 'gemma:2b',
|
|
26
36
|
tokens: 4000,
|
|
27
37
|
},
|
|
@@ -50,17 +60,6 @@ const Ollama: ModelProviderCard = {
|
|
|
50
60
|
id: 'llama2-chinese',
|
|
51
61
|
tokens: 4000,
|
|
52
62
|
},
|
|
53
|
-
{
|
|
54
|
-
displayName: 'Llama3 8B',
|
|
55
|
-
enabled: true,
|
|
56
|
-
id: 'llama3',
|
|
57
|
-
tokens: 8000,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
displayName: 'Llama3 70B',
|
|
61
|
-
id: 'llama3:70b',
|
|
62
|
-
tokens: 8000,
|
|
63
|
-
},
|
|
64
63
|
{
|
|
65
64
|
displayName: 'WizardLM 2 7B',
|
|
66
65
|
enabled: true,
|
package/src/const/session.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DeepPartial } from 'utility-types';
|
|
2
2
|
|
|
3
3
|
import { BaseModel } from '@/database/client/core';
|
|
4
|
+
import { LobeAgentConfig } from '@/types/agent';
|
|
4
5
|
import { GlobalSettings } from '@/types/settings';
|
|
5
6
|
import { uuid } from '@/utils/uuid';
|
|
6
7
|
|
|
@@ -22,6 +23,11 @@ class _UserModel extends BaseModel {
|
|
|
22
23
|
return list[0];
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
getAgentConfig = async () => {
|
|
27
|
+
const user = await this.getUser();
|
|
28
|
+
|
|
29
|
+
return user.settings?.defaultAgent?.config as LobeAgentConfig;
|
|
30
|
+
};
|
|
25
31
|
// **************** Create *************** //
|
|
26
32
|
|
|
27
33
|
create = async (user: DB_User) => {
|