@lobehub/chat 0.10.0 → 0.10.2

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 CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.10.2](https://github.com/lobehub/lobe-chat/compare/v0.10.1...v0.10.2)
6
+
7
+ <sup>Released on **2023-07-23**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: 优化模型在 list 中的展示逻辑.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: 优化模型在 list 中的展示逻辑 ([4bdf3c5](https://github.com/lobehub/lobe-chat/commit/4bdf3c5))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.10.1](https://github.com/lobehub/lobe-chat/compare/v0.10.0...v0.10.1)
31
+
32
+ <sup>Released on **2023-07-22**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: 修正对话中用户头像的问题.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: 修正对话中用户头像的问题 ([560c8bb](https://github.com/lobehub/lobe-chat/commit/560c8bb))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 0.10.0](https://github.com/lobehub/lobe-chat/compare/v0.9.0...v0.10.0)
6
56
 
7
57
  <sup>Released on **2023-07-22**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -6,8 +6,9 @@ import { useTranslation } from 'react-i18next';
6
6
  import { Flexbox } from 'react-layout-kit';
7
7
  import { shallow } from 'zustand/shallow';
8
8
 
9
- import { sessionSelectors, useSessionStore } from '@/store/session';
9
+ import { chatSelectors, sessionSelectors, useSessionStore } from '@/store/session';
10
10
  import { DEFAULT_TITLE } from '@/store/session/slices/agentConfig';
11
+ import { useSettings } from '@/store/settings';
11
12
 
12
13
  import { useStyles } from './style';
13
14
 
@@ -22,22 +23,37 @@ interface SessionItemProps {
22
23
  const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading }) => {
23
24
  const { t } = useTranslation('common');
24
25
  const { styles, theme, cx } = useStyles();
25
- const [title, description, systemRole, avatar, avatarBackground, updateAt, model, removeSession] =
26
- useSessionStore((s) => {
27
- const session = sessionSelectors.getSessionById(id)(s);
28
- const meta = session.meta;
29
- const systemRole = session.config.systemRole;
30
- return [
31
- meta.title,
32
- meta.description,
33
- systemRole,
34
- sessionSelectors.getAgentAvatar(meta),
35
- meta.backgroundColor,
36
- session?.updateAt,
37
- session.config.model,
38
- s.removeSession,
39
- ];
40
- }, shallow);
26
+ const [defaultModel] = useSettings((s) => [s.settings.model], shallow);
27
+
28
+ const [
29
+ title,
30
+ description,
31
+ systemRole,
32
+ avatar,
33
+ avatarBackground,
34
+ updateAt,
35
+ model,
36
+ chatLength,
37
+ removeSession,
38
+ ] = useSessionStore((s) => {
39
+ const session = sessionSelectors.getSessionById(id)(s);
40
+ const meta = session.meta;
41
+ const systemRole = session.config.systemRole;
42
+ return [
43
+ meta.title,
44
+ meta.description,
45
+ systemRole,
46
+ sessionSelectors.getAgentAvatar(meta),
47
+ meta.backgroundColor,
48
+ session?.updateAt,
49
+ session.config.model,
50
+ chatSelectors.currentChats(s).length,
51
+ s.removeSession,
52
+ ];
53
+ }, shallow);
54
+
55
+ const showModel = model !== defaultModel;
56
+ const showChatLength = chatLength > 0;
41
57
 
42
58
  return (
43
59
  <Flexbox className={styles.container} style={{ position: 'relative' }}>
@@ -57,9 +73,25 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
57
73
  description={
58
74
  <Flexbox gap={4}>
59
75
  <Flexbox>{description || systemRole}</Flexbox>
60
- <Flexbox horizontal>
61
- <Tag bordered={false}>{model}</Tag>
62
- </Flexbox>
76
+
77
+ {!(showModel || showChatLength) ? undefined : (
78
+ <Flexbox horizontal>
79
+ {showModel && (
80
+ <Tag bordered={false} style={{ color: theme.colorTextSecondary }}>
81
+ {model}
82
+ </Tag>
83
+ )}
84
+ {/*{showChatLength && (*/}
85
+ {/* <Tag*/}
86
+ {/* bordered={false}*/}
87
+ {/* style={{ color: theme.colorTextSecondary, display: 'flex', gap: 4 }}*/}
88
+ {/* >*/}
89
+ {/* <Icon icon={LucideMessageCircle} />*/}
90
+ {/* {chatLength}*/}
91
+ {/* </Tag>*/}
92
+ {/*)}*/}
93
+ </Flexbox>
94
+ )}
63
95
  </Flexbox>
64
96
  }
65
97
  loading={loading}
@@ -1,7 +1,9 @@
1
1
  import { agentSelectors } from '@/store/session';
2
+ import { useSettings } from '@/store/settings';
2
3
  import { ChatMessage } from '@/types/chatMessage';
3
4
 
4
5
  import type { SessionStore } from '../../../store';
6
+ import { DEFAULT_AVATAR } from '../../agentConfig';
5
7
  import { sessionSelectors } from '../../session';
6
8
 
7
9
  // 展示在聊天框中的消息
@@ -24,6 +26,10 @@ export const currentChats = (s: SessionStore): ChatMessage[] => {
24
26
  avatar: agentSelectors.currentAgentAvatar(s),
25
27
  title: session.meta.title,
26
28
  }
29
+ : m.role === 'user'
30
+ ? {
31
+ avatar: useSettings.getState().settings.avatar || DEFAULT_AVATAR,
32
+ }
27
33
  : m.meta,
28
34
  };
29
35
  });