@lobehub/chat 0.8.2 → 0.10.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 CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.10.0](https://github.com/lobehub/lobe-chat/compare/v0.9.0...v0.10.0)
6
+
7
+ <sup>Released on **2023-07-22**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: 支持复制与编辑会话消息.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: 支持复制与编辑会话消息 ([bebcf9f](https://github.com/lobehub/lobe-chat/commit/bebcf9f))
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.9.0](https://github.com/lobehub/lobe-chat/compare/v0.8.2...v0.9.0)
31
+
32
+ <sup>Released on **2023-07-22**</sup>
33
+
34
+ #### ✨ Features
35
+
36
+ - **misc**: 展示模型类型.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's improved
44
+
45
+ - **misc**: 展示模型类型 ([58ea93c](https://github.com/lobehub/lobe-chat/commit/58ea93c))
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.8.2](https://github.com/lobehub/lobe-chat/compare/v0.8.1...v0.8.2)
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.8.2",
3
+ "version": "0.10.0",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -1,4 +1,5 @@
1
1
  export default {
2
+ 'DefaultSession': '默认对话',
2
3
  'advanceSettings': '高级设置',
3
4
  'agentAvatar': '头像',
4
5
  'agentDescription': '描述',
@@ -1,8 +1,8 @@
1
1
  import { ActionIcon, Avatar, List } from '@lobehub/ui';
2
- import { Popconfirm } from 'antd';
2
+ import { Popconfirm, Tag } from 'antd';
3
3
  import { X } from 'lucide-react';
4
- import { useTranslation } from 'react-i18next';
5
4
  import { FC, memo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
6
  import { Flexbox } from 'react-layout-kit';
7
7
  import { shallow } from 'zustand/shallow';
8
8
 
@@ -22,7 +22,7 @@ interface SessionItemProps {
22
22
  const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading }) => {
23
23
  const { t } = useTranslation('common');
24
24
  const { styles, theme, cx } = useStyles();
25
- const [title, description, systemRole, avatar, avatarBackground, updateAt, removeSession] =
25
+ const [title, description, systemRole, avatar, avatarBackground, updateAt, model, removeSession] =
26
26
  useSessionStore((s) => {
27
27
  const session = sessionSelectors.getSessionById(id)(s);
28
28
  const meta = session.meta;
@@ -34,6 +34,7 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
34
34
  sessionSelectors.getAgentAvatar(meta),
35
35
  meta.backgroundColor,
36
36
  session?.updateAt,
37
+ session.config.model,
37
38
  s.removeSession,
38
39
  ];
39
40
  }, shallow);
@@ -53,13 +54,17 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
53
54
  }
54
55
  classNames={{ time: cx('session-time', styles.time) }}
55
56
  date={updateAt}
56
- description={description || systemRole}
57
+ description={
58
+ <Flexbox gap={4}>
59
+ <Flexbox>{description || systemRole}</Flexbox>
60
+ <Flexbox horizontal>
61
+ <Tag bordered={false}>{model}</Tag>
62
+ </Flexbox>
63
+ </Flexbox>
64
+ }
57
65
  loading={loading}
58
- style={{
59
- alignItems: 'center',
60
- color: theme.colorText,
61
- }}
62
- title={title || DEFAULT_TITLE}
66
+ style={{ color: theme.colorText }}
67
+ title={title || t(DEFAULT_TITLE)}
63
68
  />
64
69
  <Popconfirm
65
70
  arrow={false}
@@ -9,8 +9,8 @@ import MessageExtra from './MessageExtra';
9
9
 
10
10
  const List = () => {
11
11
  const data = useSessionStore(chatSelectors.currentChats, isEqual);
12
- const [deleteMessage, resendMessage] = useSessionStore(
13
- (s) => [s.deleteMessage, s.resendMessage],
12
+ const [deleteMessage, resendMessage, dispatchMessage] = useSessionStore(
13
+ (s) => [s.deleteMessage, s.resendMessage, s.dispatchMessage],
14
14
  shallow,
15
15
  );
16
16
 
@@ -30,6 +30,9 @@ const List = () => {
30
30
  }
31
31
  }
32
32
  }}
33
+ onMessageChange={(id, content) => {
34
+ dispatchMessage({ id, key: 'content', type: 'updateMessage', value: content });
35
+ }}
33
36
  renderMessageExtra={MessageExtra}
34
37
  style={{ marginTop: 24 }}
35
38
  />
@@ -1,4 +1,5 @@
1
1
  import { ActionIcon, Avatar, ChatHeader } from '@lobehub/ui';
2
+ import { Tag } from 'antd';
2
3
  import { createStyles } from 'antd-style';
3
4
  import { ArchiveIcon, MoreVerticalIcon, Share2 } from 'lucide-react';
4
5
  import { memo } from 'react';
@@ -6,7 +7,7 @@ import { useTranslation } from 'react-i18next';
6
7
  import { Flexbox } from 'react-layout-kit';
7
8
  import { shallow } from 'zustand/shallow';
8
9
 
9
- import { sessionSelectors, useSessionStore } from '@/store/session';
10
+ import { agentSelectors, sessionSelectors, useSessionStore } from '@/store/session';
10
11
 
11
12
  const useStyles = createStyles(({ css, token }) => ({
12
13
  desc: css`
@@ -18,8 +19,13 @@ const useStyles = createStyles(({ css, token }) => ({
18
19
  color: ${token.colorText};
19
20
  `,
20
21
  }));
22
+
21
23
  const Header = memo(() => {
22
24
  const { t } = useTranslation('common');
25
+ const [avatar, model] = useSessionStore(
26
+ (s) => [agentSelectors.currentAgentAvatar(s), agentSelectors.currentAgentModel(s)],
27
+ shallow,
28
+ );
23
29
  const [meta, id] = useSessionStore((s) => {
24
30
  const chat = sessionSelectors.currentSession(s);
25
31
  return [chat?.meta, s.activeId];
@@ -42,9 +48,12 @@ const Header = memo(() => {
42
48
  <ChatHeader
43
49
  left={
44
50
  <>
45
- <Avatar avatar={meta && sessionSelectors.getAgentAvatar(meta)} size={40} title={'123'} />
51
+ <Avatar avatar={avatar} size={40} title={meta?.title} />
46
52
  <Flexbox>
47
- <Flexbox className={styles.title}>{meta?.title || t('defaultAgent')}</Flexbox>
53
+ <Flexbox align={'center'} className={styles.title} gap={8} horizontal>
54
+ {meta?.title || t('defaultAgent')}
55
+ <Tag bordered={false}>{model}</Tag>
56
+ </Flexbox>
48
57
  <Flexbox className={styles.desc}>{meta?.description || t('noDescription')}</Flexbox>
49
58
  </Flexbox>
50
59
  </>
@@ -19,18 +19,20 @@ const Chat = memo(() => {
19
19
  const pageTitle = title ? `${title} - LobeChat` : 'LobeChat';
20
20
 
21
21
  return (
22
- <Layout>
22
+ <>
23
23
  <Head>
24
24
  <title>{pageTitle}</title>
25
25
  </Head>
26
- <Flexbox id={'lobe-conversion-container'} style={{ height: '100vh' }}>
27
- <Header />
28
- <Flexbox flex={1} height={'calc(100vh - 64px)'} horizontal>
29
- <Conversation />
30
- <Config />
26
+ <Layout>
27
+ <Flexbox id={'lobe-conversion-container'} style={{ height: '100vh' }}>
28
+ <Header />
29
+ <Flexbox flex={1} height={'calc(100vh - 64px)'} horizontal>
30
+ <Conversation />
31
+ <Config />
32
+ </Flexbox>
31
33
  </Flexbox>
32
- </Flexbox>
33
- </Layout>
34
+ </Layout>
35
+ </>
34
36
  );
35
37
  });
36
38
  export default Chat;
@@ -18,7 +18,7 @@ export const initialLobeAgentConfig: LobeAgentConfig = {
18
18
 
19
19
  export const DEFAULT_AVATAR = 'https://npm.elemecdn.com/@lobehub/assets-logo/assets/logo-3d.webp';
20
20
 
21
- export const DEFAULT_TITLE = '默认对话';
21
+ export const DEFAULT_TITLE = 'DefaultSession';
22
22
 
23
23
  export const initialAgentConfigState: AgentConfigState = {
24
24
  // // loading 中间态
@@ -25,12 +25,12 @@ export interface ChatMessage extends BaseDataModel {
25
25
 
26
26
  // 扩展字段
27
27
  extra?: {
28
+ fromModel?: string;
28
29
  // 翻译
29
- translate: {
30
+ translate?: {
30
31
  target: string;
31
32
  to: string;
32
33
  };
33
- // 语音
34
34
  } & Record<string, any>;
35
35
 
36
36
  parentId?: string;