@lobehub/chat 0.15.1 → 0.16.1
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 +66 -0
- package/package.json +1 -1
- package/src/locales/default/setting.ts +1 -0
- package/src/pages/chat/SessionList/List/SessionItem.tsx +4 -4
- package/src/pages/chat/SessionList/List/index.tsx +1 -1
- package/src/pages/chat/[id]/Conversation/MessageExtra.tsx +1 -1
- package/src/pages/chat/[id]/edit/index.page.tsx +4 -1
- package/src/pages/chat/index.page.tsx +24 -1
- package/src/store/session/slices/agentConfig/selectors.ts +9 -1
- package/src/store/session/slices/session/selectors/index.ts +2 -7
- package/src/store/session/slices/session/selectors/list.ts +1 -1
- package/src/utils/genSiteHeadTitle.ts +1 -1
- package/src/store/session/slices/session/selectors/chat.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.16.1](https://github.com/lobehub/lobe-chat/compare/v0.16.0...v0.16.1)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-07-24**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: 重构优化 selectors 实现.
|
|
12
|
+
|
|
13
|
+
#### 💄 Styles
|
|
14
|
+
|
|
15
|
+
- **misc**: 优化 document title.
|
|
16
|
+
|
|
17
|
+
<br/>
|
|
18
|
+
|
|
19
|
+
<details>
|
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
21
|
+
|
|
22
|
+
#### Code refactoring
|
|
23
|
+
|
|
24
|
+
- **misc**: 重构优化 selectors 实现 ([97fe1cd](https://github.com/lobehub/lobe-chat/commit/97fe1cd))
|
|
25
|
+
|
|
26
|
+
#### Styles
|
|
27
|
+
|
|
28
|
+
- **misc**: 优化 document title ([c3cda00](https://github.com/lobehub/lobe-chat/commit/c3cda00))
|
|
29
|
+
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
<div align="right">
|
|
33
|
+
|
|
34
|
+
[](#readme-top)
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
## [Version 0.16.0](https://github.com/lobehub/lobe-chat/compare/v0.15.1...v0.16.0)
|
|
39
|
+
|
|
40
|
+
<sup>Released on **2023-07-24**</sup>
|
|
41
|
+
|
|
42
|
+
#### ✨ Features
|
|
43
|
+
|
|
44
|
+
- **misc**: 支持自动跳转到第一条会话.
|
|
45
|
+
|
|
46
|
+
#### 💄 Styles
|
|
47
|
+
|
|
48
|
+
- **misc**: 修正插件的展示文案.
|
|
49
|
+
|
|
50
|
+
<br/>
|
|
51
|
+
|
|
52
|
+
<details>
|
|
53
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
54
|
+
|
|
55
|
+
#### What's improved
|
|
56
|
+
|
|
57
|
+
- **misc**: 支持自动跳转到第一条会话 ([54f01c7](https://github.com/lobehub/lobe-chat/commit/54f01c7))
|
|
58
|
+
|
|
59
|
+
#### Styles
|
|
60
|
+
|
|
61
|
+
- **misc**: 修正插件的展示文案 ([53c81ae](https://github.com/lobehub/lobe-chat/commit/53c81ae))
|
|
62
|
+
|
|
63
|
+
</details>
|
|
64
|
+
|
|
65
|
+
<div align="right">
|
|
66
|
+
|
|
67
|
+
[](#readme-top)
|
|
68
|
+
|
|
69
|
+
</div>
|
|
70
|
+
|
|
5
71
|
### [Version 0.15.1](https://github.com/lobehub/lobe-chat/compare/v0.15.0...v0.15.1)
|
|
6
72
|
|
|
7
73
|
<sup>Released on **2023-07-24**</sup>
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import { Flexbox } from 'react-layout-kit';
|
|
7
7
|
import { shallow } from 'zustand/shallow';
|
|
8
8
|
|
|
9
|
-
import { chatSelectors, sessionSelectors, useSessionStore } from '@/store/session';
|
|
9
|
+
import { agentSelectors, chatSelectors, sessionSelectors, useSessionStore } from '@/store/session';
|
|
10
10
|
import { useSettings } from '@/store/settings';
|
|
11
11
|
|
|
12
12
|
import { useStyles } from './style';
|
|
@@ -39,10 +39,10 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
|
|
|
39
39
|
const meta = session.meta;
|
|
40
40
|
const systemRole = session.config.systemRole;
|
|
41
41
|
return [
|
|
42
|
-
meta
|
|
42
|
+
agentSelectors.getTitle(meta),
|
|
43
43
|
meta.description,
|
|
44
44
|
systemRole,
|
|
45
|
-
|
|
45
|
+
agentSelectors.getAvatar(meta),
|
|
46
46
|
meta.backgroundColor,
|
|
47
47
|
session?.updateAt,
|
|
48
48
|
session.config.model,
|
|
@@ -95,7 +95,7 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
|
|
|
95
95
|
}
|
|
96
96
|
loading={loading}
|
|
97
97
|
style={{ color: theme.colorText }}
|
|
98
|
-
title={title
|
|
98
|
+
title={title}
|
|
99
99
|
/>
|
|
100
100
|
<Popconfirm
|
|
101
101
|
arrow={false}
|
|
@@ -8,7 +8,7 @@ import { sessionSelectors, useSessionStore } from '@/store/session';
|
|
|
8
8
|
import SessionItem from './SessionItem';
|
|
9
9
|
|
|
10
10
|
const SessionList = memo(() => {
|
|
11
|
-
const list = useSessionStore((s) => sessionSelectors.
|
|
11
|
+
const list = useSessionStore((s) => sessionSelectors.sessionList(s), isEqual);
|
|
12
12
|
const [activeId, loading] = useSessionStore(
|
|
13
13
|
(s) => [s.activeId, s.autocompleteLoading.title],
|
|
14
14
|
shallow,
|
|
@@ -38,7 +38,7 @@ const MessageExtra = ({ role, extra, function_call }: ChatMessage): ReactNode =>
|
|
|
38
38
|
) : (
|
|
39
39
|
<Icon icon={LucideToyBrick} />
|
|
40
40
|
)}
|
|
41
|
-
{t(`plugins
|
|
41
|
+
{t(`plugins.${function_call?.name}` as any, { ns: 'plugin' })}
|
|
42
42
|
</Tag>
|
|
43
43
|
</Tooltip>
|
|
44
44
|
);
|
|
@@ -2,9 +2,11 @@ import Head from 'next/head';
|
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
|
5
|
+
import { shallow } from 'zustand/shallow';
|
|
5
6
|
|
|
6
7
|
import HeaderSpacing from '@/components/HeaderSpacing';
|
|
7
8
|
import { HEADER_HEIGHT } from '@/const/layoutTokens';
|
|
9
|
+
import { agentSelectors, useSessionStore } from '@/store/session';
|
|
8
10
|
import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
|
|
9
11
|
|
|
10
12
|
import ChatLayout from '../../layout';
|
|
@@ -17,7 +19,8 @@ import Header from './Header';
|
|
|
17
19
|
const EditPage = memo(() => {
|
|
18
20
|
const { t } = useTranslation('setting');
|
|
19
21
|
|
|
20
|
-
const
|
|
22
|
+
const title = useSessionStore(agentSelectors.currentAgentTitle, shallow);
|
|
23
|
+
const pageTitle = genSiteHeadTitle(t('header.sessionWithName', { name: title }));
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
26
|
<>
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import Router from 'next/router';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
import { sessionSelectors, useSessionStore } from '@/store/session';
|
|
5
|
+
|
|
6
|
+
import Chat from './[id]/index.page';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
// 支持用户在进到首页时,自动激活列表中的第一个角色
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const hasRehydrated = useSessionStore.persist.hasHydrated();
|
|
12
|
+
// 只有当水合完毕后,才往下走
|
|
13
|
+
if (!hasRehydrated) return;
|
|
14
|
+
|
|
15
|
+
// 如果当前有会话,那么就激活第一个会话
|
|
16
|
+
const list = sessionSelectors.sessionList(useSessionStore.getState());
|
|
17
|
+
if (list.length > 0) {
|
|
18
|
+
const sessionId = list[0].id;
|
|
19
|
+
Router.push(`/chat/${sessionId}`);
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
return <Chat />;
|
|
24
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { t } from 'i18next';
|
|
2
|
+
|
|
1
3
|
import { DEFAULT_AVATAR, DEFAULT_BACKGROUND_COLOR } from '@/const/meta';
|
|
2
4
|
import { SessionStore } from '@/store/session';
|
|
3
5
|
import { LanguageModel } from '@/types/llm';
|
|
@@ -13,7 +15,7 @@ const currentAgentMeta = (s: SessionStore): MetaData => {
|
|
|
13
15
|
return { avatar: DEFAULT_AVATAR, backgroundColor: DEFAULT_BACKGROUND_COLOR, ...session?.meta };
|
|
14
16
|
};
|
|
15
17
|
|
|
16
|
-
const currentAgentTitle = (s: SessionStore) => currentAgentMeta(s)?.title;
|
|
18
|
+
const currentAgentTitle = (s: SessionStore) => currentAgentMeta(s)?.title || t('defaultSession');
|
|
17
19
|
|
|
18
20
|
const currentAgentBackgroundColor = (s: SessionStore) => {
|
|
19
21
|
const session = sessionSelectors.currentSession(s);
|
|
@@ -51,6 +53,10 @@ const hasSystemRole = (s: SessionStore) => {
|
|
|
51
53
|
|
|
52
54
|
return !!config.systemRole;
|
|
53
55
|
};
|
|
56
|
+
|
|
57
|
+
export const getAvatar = (s: MetaData) => s.avatar || DEFAULT_AVATAR;
|
|
58
|
+
export const getTitle = (s: MetaData) => s.title || t('defaultSession');
|
|
59
|
+
|
|
54
60
|
export const agentSelectors = {
|
|
55
61
|
currentAgentAvatar,
|
|
56
62
|
currentAgentBackgroundColor,
|
|
@@ -60,5 +66,7 @@ export const agentSelectors = {
|
|
|
60
66
|
currentAgentModel,
|
|
61
67
|
currentAgentSystemRole,
|
|
62
68
|
currentAgentTitle,
|
|
69
|
+
getAvatar,
|
|
70
|
+
getTitle,
|
|
63
71
|
hasSystemRole,
|
|
64
72
|
};
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { getAgentAvatar } from './chat';
|
|
2
1
|
import {
|
|
3
|
-
chatListSel,
|
|
4
2
|
currentSessionSafe,
|
|
5
3
|
currentSessionSel,
|
|
6
4
|
getSessionById,
|
|
7
5
|
getSessionMetaById,
|
|
6
|
+
sessionList,
|
|
8
7
|
} from './list';
|
|
9
8
|
|
|
10
9
|
export const sessionSelectors = {
|
|
11
|
-
chatList: chatListSel,
|
|
12
10
|
currentSession: currentSessionSel,
|
|
13
11
|
currentSessionSafe,
|
|
14
|
-
|
|
15
|
-
getAgentAvatar,
|
|
16
|
-
|
|
17
12
|
getSessionById,
|
|
18
|
-
// sessionTree: sessionTreeSel,
|
|
19
13
|
getSessionMetaById,
|
|
14
|
+
sessionList,
|
|
20
15
|
};
|
|
@@ -14,7 +14,7 @@ export const currentSessionSafe = (s: SessionStore): LobeAgentSession => {
|
|
|
14
14
|
return currentSessionSel(s) || initLobeSession;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const
|
|
17
|
+
export const sessionList = (s: SessionStore) => {
|
|
18
18
|
const filterChats = filterWithKeywords(s.sessions, s.searchKeywords, (item) => [
|
|
19
19
|
Object.values(item.chats)
|
|
20
20
|
.map((c) => c.content)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const genSiteHeadTitle = (title?: string) => (title ? `${title}
|
|
1
|
+
export const genSiteHeadTitle = (title?: string) => (title ? `${title} · LobeChat` : 'LobeChat');
|