@lobehub/chat 0.18.1 → 0.19.0
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 +59 -0
- package/package.json +1 -1
- package/src/locales/default/common.ts +4 -2
- package/src/pages/chat/[id]/Config/SideBar.tsx +1 -1
- package/src/pages/chat/[id]/Conversation/Input/index.tsx +3 -3
- package/src/store/session/slices/chat/action.ts +2 -10
- package/src/store/session/slices/chat/{messageReducer.test.ts → reducers/message.test.ts} +1 -1
- package/src/store/session/slices/chat/selectors/utils.test.ts +1 -1
- package/src/store/session/slices/chat/selectors/utils.ts +2 -2
- package/src/styles/global.ts +0 -4
- package/src/types/chatMessage.ts +4 -2
- package/src/types/session.ts +2 -1
- package/src/types/topic.ts +9 -0
- /package/src/store/session/slices/chat/{messageReducer.ts → reducers/message.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,65 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 0.19.0](https://github.com/lobehub/lobe-chat/compare/v0.18.2...v0.19.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-07-24**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: 将 message reducer 提取到独立文件夹中, 清理无用代码实现.
|
|
12
|
+
|
|
13
|
+
#### ✨ Features
|
|
14
|
+
|
|
15
|
+
- **misc**: 数据结构层完成 topic 模型改造.
|
|
16
|
+
|
|
17
|
+
<br/>
|
|
18
|
+
|
|
19
|
+
<details>
|
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
21
|
+
|
|
22
|
+
#### Code refactoring
|
|
23
|
+
|
|
24
|
+
- **misc**: 将 message reducer 提取到独立文件夹中 ([64f40ca](https://github.com/lobehub/lobe-chat/commit/64f40ca))
|
|
25
|
+
- **misc**: 清理无用代码实现 ([3655b60](https://github.com/lobehub/lobe-chat/commit/3655b60))
|
|
26
|
+
|
|
27
|
+
#### What's improved
|
|
28
|
+
|
|
29
|
+
- **misc**: 数据结构层完成 topic 模型改造 ([99fa2a6](https://github.com/lobehub/lobe-chat/commit/99fa2a6))
|
|
30
|
+
|
|
31
|
+
</details>
|
|
32
|
+
|
|
33
|
+
<div align="right">
|
|
34
|
+
|
|
35
|
+
[](#readme-top)
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
### [Version 0.18.2](https://github.com/lobehub/lobe-chat/compare/v0.18.1...v0.18.2)
|
|
40
|
+
|
|
41
|
+
<sup>Released on **2023-07-24**</sup>
|
|
42
|
+
|
|
43
|
+
#### 💄 Styles
|
|
44
|
+
|
|
45
|
+
- **misc**: 修正 markdown li 丢失的问题.
|
|
46
|
+
|
|
47
|
+
<br/>
|
|
48
|
+
|
|
49
|
+
<details>
|
|
50
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
51
|
+
|
|
52
|
+
#### Styles
|
|
53
|
+
|
|
54
|
+
- **misc**: 修正 markdown li 丢失的问题 ([eb6e831](https://github.com/lobehub/lobe-chat/commit/eb6e831))
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
<div align="right">
|
|
59
|
+
|
|
60
|
+
[](#readme-top)
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
5
64
|
### [Version 0.18.1](https://github.com/lobehub/lobe-chat/compare/v0.18.0...v0.18.1)
|
|
6
65
|
|
|
7
66
|
<sup>Released on **2023-07-24**</sup>
|
package/package.json
CHANGED
|
@@ -4,8 +4,6 @@ export default {
|
|
|
4
4
|
agentModel: '模型',
|
|
5
5
|
agentProfile: '助手信息',
|
|
6
6
|
archive: '归档',
|
|
7
|
-
archiveCurrentMessages: '归档当前会话',
|
|
8
|
-
archiveSearchPlaceholder: '搜索归档对话...',
|
|
9
7
|
autoGenerate: '自动补全',
|
|
10
8
|
autoGenerateTooltip: '基于提示词自动补全助手描述',
|
|
11
9
|
cancel: '取消',
|
|
@@ -28,6 +26,10 @@ export default {
|
|
|
28
26
|
setting: '设置',
|
|
29
27
|
share: '分享',
|
|
30
28
|
tokenDetail: '系统设定: {{systemRoleToken}} 历史消息: {{chatsToken}}',
|
|
29
|
+
topic: {
|
|
30
|
+
saveCurrentMessages: '保存当前对话为话题',
|
|
31
|
+
searchPlaceholder: '搜索归档对话...',
|
|
32
|
+
},
|
|
31
33
|
updateAgent: '更新助理信息',
|
|
32
34
|
updatePrompt: '更新提示词',
|
|
33
35
|
};
|
|
@@ -77,7 +77,7 @@ const SideBar = memo(() => {
|
|
|
77
77
|
value={systemRole}
|
|
78
78
|
/>
|
|
79
79
|
<Flexbox style={{ padding: 16 }}>
|
|
80
|
-
<SearchBar placeholder={t('
|
|
80
|
+
<SearchBar placeholder={t('topic.searchPlaceholder')} type={'block'} />
|
|
81
81
|
</Flexbox>
|
|
82
82
|
</DraggablePanelBody>
|
|
83
83
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChatInputArea, DraggablePanel, Icon, Tooltip } from '@lobehub/ui';
|
|
2
2
|
import { Button } from 'antd';
|
|
3
|
-
import {
|
|
3
|
+
import { LucideGalleryVerticalEnd } from 'lucide-react';
|
|
4
4
|
import { memo, useMemo, useState } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { shallow } from 'zustand/shallow';
|
|
@@ -22,8 +22,8 @@ const ChatInput = () => {
|
|
|
22
22
|
|
|
23
23
|
const footer = useMemo(
|
|
24
24
|
() => (
|
|
25
|
-
<Tooltip title={t('
|
|
26
|
-
<Button icon={<Icon icon={
|
|
25
|
+
<Tooltip title={t('topic.saveCurrentMessages')}>
|
|
26
|
+
<Button icon={<Icon icon={LucideGalleryVerticalEnd} />} />
|
|
27
27
|
</Tooltip>
|
|
28
28
|
),
|
|
29
29
|
[],
|
|
@@ -7,7 +7,7 @@ import { fetchSSE } from '@/utils/fetch';
|
|
|
7
7
|
import { isFunctionMessage } from '@/utils/message';
|
|
8
8
|
import { nanoid } from '@/utils/uuid';
|
|
9
9
|
|
|
10
|
-
import { MessageDispatch, messagesReducer } from './
|
|
10
|
+
import { MessageDispatch, messagesReducer } from './reducers/message';
|
|
11
11
|
|
|
12
12
|
const LOADING_FLAT = '...';
|
|
13
13
|
|
|
@@ -44,11 +44,7 @@ export interface ChatAction {
|
|
|
44
44
|
assistantMessageId: string,
|
|
45
45
|
withPlugin?: boolean,
|
|
46
46
|
) => Promise<{ isFunctionCall: boolean; output: string }>;
|
|
47
|
-
|
|
48
|
-
* 处理消息编辑
|
|
49
|
-
* @param messageId - 消息 ID,可选
|
|
50
|
-
*/
|
|
51
|
-
handleMessageEditing: (messageId: string | undefined) => void;
|
|
47
|
+
|
|
52
48
|
/**
|
|
53
49
|
* 实际获取 AI 响应
|
|
54
50
|
*
|
|
@@ -158,10 +154,6 @@ export const createChatSlice: StateCreator<
|
|
|
158
154
|
return { isFunctionCall, output };
|
|
159
155
|
},
|
|
160
156
|
|
|
161
|
-
handleMessageEditing: (messageId) => {
|
|
162
|
-
set({ editingMessageId: messageId });
|
|
163
|
-
},
|
|
164
|
-
|
|
165
157
|
realFetchAIResponse: async (messages, userMessageId) => {
|
|
166
158
|
const { dispatchMessage, generateMessage } = get();
|
|
167
159
|
|
|
@@ -67,7 +67,7 @@ describe('organizeChats', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it('should filter out archived messages', () => {
|
|
70
|
-
session.chats['2'].
|
|
70
|
+
session.chats['2'].topicId = '123';
|
|
71
71
|
const result = organizeChats(session, { assistant: '', user: '' });
|
|
72
72
|
expect(result.length).toBe(2);
|
|
73
73
|
expect(result[0].id).toBe('1');
|
|
@@ -38,8 +38,8 @@ export const organizeChats = (
|
|
|
38
38
|
const basic = Object.values<ChatMessage>(session.chats)
|
|
39
39
|
// 首先按照时间顺序排序,越早的在越前面
|
|
40
40
|
.sort((pre, next) => pre.createAt - next.createAt)
|
|
41
|
-
//
|
|
42
|
-
.filter((m) => !m.
|
|
41
|
+
// 过滤掉包含 topicId 的消息,有主题的消息不应该出现在聊天框中
|
|
42
|
+
.filter((m) => !m.topicId)
|
|
43
43
|
// 映射头像关系
|
|
44
44
|
.map((m) => {
|
|
45
45
|
return {
|
package/src/styles/global.ts
CHANGED
package/src/types/chatMessage.ts
CHANGED
|
@@ -14,8 +14,6 @@ export interface ChatMessageError {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface ChatMessage extends BaseDataModel {
|
|
17
|
-
archive?: boolean;
|
|
18
|
-
|
|
19
17
|
/**
|
|
20
18
|
* @title 内容
|
|
21
19
|
* @description 消息内容
|
|
@@ -43,6 +41,10 @@ export interface ChatMessage extends BaseDataModel {
|
|
|
43
41
|
* @description 消息发送者的角色
|
|
44
42
|
*/
|
|
45
43
|
role: LLMRoleType;
|
|
44
|
+
/**
|
|
45
|
+
* 保存到主题的消息
|
|
46
|
+
*/
|
|
47
|
+
topicId?: string;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export type ChatMessageMap = Record<string, ChatMessage>;
|
package/src/types/session.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatMessageMap } from './chatMessage';
|
|
2
2
|
import { LLMExample, LLMParams, LanguageModel } from './llm';
|
|
3
3
|
import { BaseDataModel } from './meta';
|
|
4
|
+
import { ChatTopicMap } from './topic';
|
|
4
5
|
|
|
5
6
|
export enum LobeSessionType {
|
|
6
7
|
/**
|
|
@@ -18,7 +19,7 @@ interface LobeSessionBase extends BaseDataModel {
|
|
|
18
19
|
* 聊天记录
|
|
19
20
|
*/
|
|
20
21
|
chats: ChatMessageMap;
|
|
21
|
-
|
|
22
|
+
topics?: ChatTopicMap;
|
|
22
23
|
/**
|
|
23
24
|
* 每个会话的类别
|
|
24
25
|
*/
|
|
File without changes
|