@lobehub/chat 0.19.0 → 0.21.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 +58 -0
- package/package.json +1 -1
- package/src/{features → components}/SliderWithInput/index.tsx +1 -0
- package/src/locales/default/common.ts +2 -2
- package/src/locales/default/setting.ts +1 -0
- package/src/pages/chat/[id]/Config/SideBar.tsx +9 -5
- package/src/pages/chat/[id]/Config/Topic.tsx +27 -0
- package/src/pages/chat/[id]/Config/TopicItem.tsx +80 -0
- package/src/pages/chat/[id]/Conversation/Input/Action.tsx +66 -7
- package/src/pages/chat/[id]/Conversation/Input/index.tsx +5 -2
- package/src/pages/chat/[id]/Header.tsx +14 -10
- package/src/pages/chat/[id]/edit/AgentConfig/index.tsx +1 -1
- package/src/pages/chat/layout.tsx +10 -4
- package/src/pages/setting/SettingForm.tsx +1 -1
- package/src/prompts/chat.ts +19 -0
- package/src/store/session/selectors.ts +1 -1
- package/src/store/session/slices/agentConfig/selectors.ts +4 -0
- package/src/store/session/slices/chat/actions/index.ts +21 -0
- package/src/store/session/slices/chat/{action.ts → actions/message.ts} +33 -23
- package/src/store/session/slices/chat/actions/topic.ts +98 -0
- package/src/store/session/slices/chat/index.ts +1 -1
- package/src/store/session/slices/chat/initialState.ts +2 -5
- package/src/store/session/slices/chat/reducers/message.test.ts +92 -0
- package/src/store/session/slices/chat/reducers/message.ts +16 -1
- package/src/store/session/slices/chat/reducers/topic.test.ts +179 -0
- package/src/store/session/slices/chat/reducers/topic.ts +59 -0
- package/src/store/session/slices/chat/selectors/chat.ts +8 -4
- package/src/store/session/slices/chat/selectors/index.ts +5 -0
- package/src/store/session/slices/chat/selectors/topic.ts +16 -0
- package/src/store/session/slices/chat/selectors/utils.test.ts +81 -1
- package/src/store/session/slices/chat/selectors/utils.ts +8 -2
- package/src/store/session/slices/session/reducers/session.ts +25 -1
- package/src/types/topic.ts +0 -1
- package/src/pages/chat/[id]/Config/ConfigCell.tsx +0 -68
|
@@ -3,6 +3,7 @@ import { produce } from 'immer';
|
|
|
3
3
|
import { ChatMessageMap } from '@/types/chatMessage';
|
|
4
4
|
import { MetaData } from '@/types/meta';
|
|
5
5
|
import { LobeAgentConfig, LobeAgentSession, LobeSessions } from '@/types/session';
|
|
6
|
+
import { ChatTopicMap } from '@/types/topic';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @title 添加会话
|
|
@@ -37,6 +38,19 @@ interface UpdateSessionChat {
|
|
|
37
38
|
type: 'updateSessionChat';
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @title 更新会话聊天上下文
|
|
43
|
+
*/
|
|
44
|
+
interface UpdateSessionTopic {
|
|
45
|
+
/**
|
|
46
|
+
* 会话 ID
|
|
47
|
+
*/
|
|
48
|
+
id: string;
|
|
49
|
+
topics: ChatTopicMap;
|
|
50
|
+
|
|
51
|
+
type: 'updateSessionTopic';
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
interface UpdateSessionMeta {
|
|
41
55
|
id: string;
|
|
42
56
|
key: keyof MetaData;
|
|
@@ -55,7 +69,8 @@ export type SessionDispatch =
|
|
|
55
69
|
| UpdateSessionChat
|
|
56
70
|
| RemoveSession
|
|
57
71
|
| UpdateSessionMeta
|
|
58
|
-
| UpdateSessionAgentConfig
|
|
72
|
+
| UpdateSessionAgentConfig
|
|
73
|
+
| UpdateSessionTopic;
|
|
59
74
|
|
|
60
75
|
export const sessionsReducer = (state: LobeSessions, payload: SessionDispatch): LobeSessions => {
|
|
61
76
|
switch (payload.type) {
|
|
@@ -96,6 +111,15 @@ export const sessionsReducer = (state: LobeSessions, payload: SessionDispatch):
|
|
|
96
111
|
});
|
|
97
112
|
}
|
|
98
113
|
|
|
114
|
+
case 'updateSessionTopic': {
|
|
115
|
+
return produce(state, (draft) => {
|
|
116
|
+
const chat = draft[payload.id];
|
|
117
|
+
if (!chat) return;
|
|
118
|
+
|
|
119
|
+
chat.topics = payload.topics;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
99
123
|
case 'updateSessionConfig': {
|
|
100
124
|
return produce(state, (draft) => {
|
|
101
125
|
const { id, config } = payload;
|
package/src/types/topic.ts
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Icon } from '@lobehub/ui';
|
|
2
|
-
import { createStyles } from 'antd-style';
|
|
3
|
-
import { LucideChevronRight, LucideIcon } from 'lucide-react';
|
|
4
|
-
import { memo } from 'react';
|
|
5
|
-
import { Flexbox } from 'react-layout-kit';
|
|
6
|
-
|
|
7
|
-
const useStyles = createStyles(({ css, token }) => ({
|
|
8
|
-
container: css`
|
|
9
|
-
background: ${token.colorFillQuaternary};
|
|
10
|
-
border-radius: 6px;
|
|
11
|
-
`,
|
|
12
|
-
split: css`
|
|
13
|
-
border-bottom: 1px solid ${token.colorSplit};
|
|
14
|
-
`,
|
|
15
|
-
}));
|
|
16
|
-
export interface ConfigItem {
|
|
17
|
-
icon: LucideIcon;
|
|
18
|
-
label: string;
|
|
19
|
-
value?: string | number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ConfigCellProps = ConfigItem;
|
|
23
|
-
|
|
24
|
-
export const ConfigCell = memo<ConfigCellProps>(({ icon, label, value }) => {
|
|
25
|
-
const { styles } = useStyles();
|
|
26
|
-
return (
|
|
27
|
-
<Flexbox
|
|
28
|
-
className={styles.container}
|
|
29
|
-
distribution={'space-between'}
|
|
30
|
-
horizontal
|
|
31
|
-
padding={'10px 12px'}
|
|
32
|
-
>
|
|
33
|
-
<Flexbox gap={8} horizontal>
|
|
34
|
-
<Icon icon={icon} />
|
|
35
|
-
<Flexbox>{label}</Flexbox>
|
|
36
|
-
</Flexbox>
|
|
37
|
-
{value ?? <Icon icon={LucideChevronRight} />}
|
|
38
|
-
</Flexbox>
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export interface CellGroupProps {
|
|
43
|
-
items: ConfigItem[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const ConfigCellGroup = memo<CellGroupProps>(({ items }) => {
|
|
47
|
-
const { styles } = useStyles();
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Flexbox className={styles.container}>
|
|
51
|
-
{items.map(({ label, icon, value }, index) => (
|
|
52
|
-
<Flexbox
|
|
53
|
-
className={items.length === index + 1 ? undefined : styles.split}
|
|
54
|
-
distribution={'space-between'}
|
|
55
|
-
horizontal
|
|
56
|
-
key={label}
|
|
57
|
-
padding={'10px 12px'}
|
|
58
|
-
>
|
|
59
|
-
<Flexbox gap={8} horizontal>
|
|
60
|
-
<Icon icon={icon} />
|
|
61
|
-
<Flexbox>{label}</Flexbox>
|
|
62
|
-
</Flexbox>
|
|
63
|
-
{value ?? <Icon icon={LucideChevronRight} />}
|
|
64
|
-
</Flexbox>
|
|
65
|
-
))}
|
|
66
|
-
</Flexbox>
|
|
67
|
-
);
|
|
68
|
-
});
|