@lobehub/chat 0.40.3 → 0.40.5

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.40.5](https://github.com/lobehub/lobe-chat/compare/v0.40.4...v0.40.5)
6
+
7
+ <sup>Released on **2023-08-10**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: 增加未初始化的 loading 态.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: 增加未初始化的 loading 态 ([dcb7c07](https://github.com/lobehub/lobe-chat/commit/dcb7c07))
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.40.4](https://github.com/lobehub/lobe-chat/compare/v0.40.3...v0.40.4)
31
+
32
+ <sup>Released on **2023-08-10**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: 优化 Header 样式.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: 优化 Header 样式 ([edd148a](https://github.com/lobehub/lobe-chat/commit/edd148a))
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.40.3](https://github.com/lobehub/lobe-chat/compare/v0.40.2...v0.40.3)
6
56
 
7
57
  <sup>Released on **2023-08-10**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.40.3",
3
+ "version": "0.40.5",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -1,2 +1,51 @@
1
- export { default as PluginTag } from './PluginTag';
2
- export { default } from './Tag';
1
+ import { Tag as AntTag, type TagProps as AntTagProps } from 'antd';
2
+ import { createStyles } from 'antd-style';
3
+ import { ReactNode, memo } from 'react';
4
+ import { Flexbox } from 'react-layout-kit';
5
+
6
+ const useStyles = createStyles(({ cx, css, token }) => ({
7
+ count: css`
8
+ display: flex;
9
+ align-items: center;
10
+
11
+ height: 20px;
12
+ padding: 0 8px;
13
+
14
+ font-size: 12px;
15
+ line-height: 1;
16
+
17
+ background: ${token.colorFillTertiary};
18
+ border: ${token.borderRadius}px;
19
+ `,
20
+ tag: cx(
21
+ css`
22
+ color: ${token.colorTextSecondary} !important;
23
+ background: ${token.colorFillSecondary};
24
+ border: ${token.borderRadius}px;
25
+
26
+ &:hover {
27
+ color: ${token.colorText};
28
+ background: ${token.colorFill};
29
+ }
30
+ `,
31
+ ),
32
+ }));
33
+
34
+ export interface TagProps extends AntTagProps {
35
+ icon?: ReactNode;
36
+ }
37
+
38
+ const Tag = memo<TagProps>(({ icon, children, ...props }) => {
39
+ const { styles } = useStyles();
40
+
41
+ return (
42
+ <AntTag bordered={false} className={styles.tag} {...props}>
43
+ <Flexbox align={'center'} gap={4} horizontal>
44
+ {icon}
45
+ {children}
46
+ </Flexbox>
47
+ </AntTag>
48
+ );
49
+ });
50
+
51
+ export default Tag;
@@ -1,13 +1,12 @@
1
1
  import { ActionIcon, Avatar, Icon, List } from '@lobehub/ui';
2
2
  import { useHover } from 'ahooks';
3
- import { App, Dropdown, type MenuProps } from 'antd';
3
+ import { App, Dropdown, type MenuProps, Tag } from 'antd';
4
4
  import { FolderOutput, MoreVertical, Pin, PinOff, Trash } from 'lucide-react';
5
5
  import { FC, memo, useMemo, useRef, useState } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
  import { shallow } from 'zustand/shallow';
9
9
 
10
- import Tag from '@/components/Tag';
11
10
  import { exportSingleAgent, exportSingleSession } from '@/helpers/export';
12
11
  import { agentSelectors, chatSelectors, sessionSelectors, useSessionStore } from '@/store/session';
13
12
  import { useSettings } from '@/store/settings';
@@ -150,11 +149,7 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
150
149
  addon={
151
150
  !(showModel || showChatLength) ? undefined : (
152
151
  <Flexbox gap={4} horizontal style={{ flexWrap: 'wrap' }}>
153
- {showModel && (
154
- <Tag capitalize type={'openai'}>
155
- {model}
156
- </Tag>
157
- )}
152
+ {showModel && <Tag bordered={false}>{model}</Tag>}
158
153
  </Flexbox>
159
154
  )
160
155
  }
@@ -0,0 +1,47 @@
1
+ import { Skeleton } from 'antd';
2
+ import { createStyles } from 'antd-style';
3
+ import { Flexbox } from 'react-layout-kit';
4
+
5
+ const useStyles = createStyles(({ css }) => ({
6
+ avatar: css``,
7
+ paragraph: css`
8
+ height: 12px !important;
9
+ margin-top: 12px !important;
10
+
11
+ > li {
12
+ height: 12px !important;
13
+ }
14
+ `,
15
+ title: css`
16
+ height: 14px !important;
17
+ margin-top: 4px !important;
18
+ margin-bottom: 12px !important;
19
+
20
+ > li {
21
+ height: 14px !important;
22
+ }
23
+ `,
24
+ }));
25
+
26
+ // 从 3~10 随机取一个整数
27
+
28
+ const SkeletonItem = () => {
29
+ const { styles } = useStyles();
30
+
31
+ const list = Array.from({ length: 4 }).fill('');
32
+ return (
33
+ <Flexbox gap={8} paddingInline={16}>
34
+ {list.map((_, index) => (
35
+ <Skeleton
36
+ active
37
+ avatar
38
+ key={index}
39
+ paragraph={{ className: styles.paragraph, rows: 1 }}
40
+ round
41
+ title={{ className: styles.title }}
42
+ />
43
+ ))}
44
+ </Flexbox>
45
+ );
46
+ };
47
+ export default SkeletonItem;
@@ -1,20 +1,32 @@
1
1
  import isEqual from 'fast-deep-equal';
2
2
  import Link from 'next/link';
3
- import { memo } from 'react';
3
+ import { memo, useEffect, useState } from 'react';
4
4
  import { shallow } from 'zustand/shallow';
5
5
 
6
6
  import { sessionSelectors, useSessionStore } from '@/store/session';
7
7
 
8
8
  import SessionItem from './SessionItem';
9
+ import SkeletonItem from './SkeletonItem';
9
10
 
10
11
  const SessionList = memo(() => {
12
+ const [isInit, setInit] = useState(false);
11
13
  const list = useSessionStore((s) => sessionSelectors.sessionList(s), isEqual);
12
14
  const [activeId, loading] = useSessionStore(
13
15
  (s) => [s.activeId, s.autocompleteLoading.title],
14
16
  shallow,
15
17
  );
16
18
 
17
- return (
19
+ useEffect(() => {
20
+ const hasRehydrated = useSessionStore.persist.hasHydrated();
21
+
22
+ if (hasRehydrated) {
23
+ setInit(true);
24
+ }
25
+ }, []);
26
+
27
+ return !isInit ? (
28
+ <SkeletonItem />
29
+ ) : (
18
30
  <>
19
31
  {list.map(({ id }) => (
20
32
  <Link href={`/chat/${id}`} key={id}>
@@ -45,9 +45,7 @@ const MessageExtra = ({
45
45
 
46
46
  const modelTag = (
47
47
  <div>
48
- <Tag capitalize type={'openai'}>
49
- {extra?.fromModel as string}
50
- </Tag>
48
+ <Tag>{extra?.fromModel as string}</Tag>
51
49
  </div>
52
50
  );
53
51
 
@@ -74,6 +74,7 @@ const FunctionCall = memo<FunctionCallProps>(({ function_call, loading, content
74
74
  label: t('debug.response'),
75
75
  },
76
76
  ]}
77
+ style={{ maxWidth: 800 }}
77
78
  />
78
79
  )}
79
80
  </Flexbox>
@@ -1,13 +1,13 @@
1
- import { Avatar } from '@lobehub/ui';
1
+ import { Avatar, Icon } from '@lobehub/ui';
2
2
  import type { MenuProps } from 'antd';
3
3
  import { Dropdown } from 'antd';
4
+ import { LucideToyBrick } from 'lucide-react';
4
5
  import { memo } from 'react';
5
6
  import { useTranslation } from 'react-i18next';
6
7
 
8
+ import Tag from '@/components/Tag';
7
9
  import { PluginsMap } from '@/plugins';
8
10
 
9
- import Tag from './index';
10
-
11
11
  export interface PluginTagProps {
12
12
  plugins: string[];
13
13
  }
@@ -15,7 +15,7 @@ export interface PluginTagProps {
15
15
  const PluginTag = memo<PluginTagProps>(({ plugins }) => {
16
16
  const { t } = useTranslation('plugin');
17
17
 
18
- if (plugins.length === 0) return <Tag type={'plugin'}>{t(`plugins.${plugins[0]}` as any)}</Tag>;
18
+ if (plugins.length === 0) return null;
19
19
 
20
20
  const items: MenuProps['items'] = plugins.map((id) => ({
21
21
  icon: (
@@ -24,11 +24,15 @@ const PluginTag = memo<PluginTagProps>(({ plugins }) => {
24
24
  key: id,
25
25
  label: t(`plugins.${id}` as any),
26
26
  }));
27
+ const count = plugins.length;
28
+
27
29
  return (
28
30
  <Dropdown menu={{ items }}>
29
- <div style={{ height: 20 }}>
30
- <Tag count={plugins.length} type={'plugin'}>
31
+ <div>
32
+ <Tag>
33
+ {<Icon icon={LucideToyBrick} />}
31
34
  {t(`plugins.${plugins[0]}` as any)}
35
+ {count > 1 && <div>({plugins.length - 1}+)</div>}
32
36
  </Tag>
33
37
  </div>
34
38
  </Dropdown>
@@ -1,15 +1,19 @@
1
+ import { SiOpenai } from '@icons-pack/react-simple-icons';
1
2
  import { ActionIcon, Avatar, ChatHeader } from '@lobehub/ui';
2
- import { PanelRightClose, PanelRightOpen, Settings, Share2 } from 'lucide-react';
3
+ import { PanelRightClose, PanelRightOpen, Settings } from 'lucide-react';
3
4
  import Router from 'next/router';
4
5
  import { memo } from 'react';
5
6
  import { useTranslation } from 'react-i18next';
7
+ import { Flexbox } from 'react-layout-kit';
6
8
  import { shallow } from 'zustand/shallow';
7
9
 
8
10
  import HeaderTitle from '@/components/HeaderTitle';
9
- import Tag, { PluginTag } from '@/components/Tag';
11
+ import Tag from '@/components/Tag';
10
12
  import { agentSelectors, useSessionStore } from '@/store/session';
11
13
  import { useSettings } from '@/store/settings';
12
14
 
15
+ import PluginTag from './PluginTag';
16
+
13
17
  const Header = memo(() => {
14
18
  const { t } = useTranslation('common');
15
19
 
@@ -34,7 +38,7 @@ const Header = memo(() => {
34
38
  return (
35
39
  <ChatHeader
36
40
  left={
37
- <>
41
+ <Flexbox align={'flex-start'} horizontal>
38
42
  <Avatar
39
43
  avatar={avatar}
40
44
  background={backgroundColor}
@@ -49,27 +53,28 @@ const Header = memo(() => {
49
53
  desc={description}
50
54
  tag={
51
55
  <>
52
- <Tag capitalize type={'openai'}>
56
+ <Tag>
57
+ <SiOpenai size={'11px'} style={{ marginTop: 3 }} />
53
58
  {model}
54
59
  </Tag>
55
- {plugins?.length > 1 && <PluginTag plugins={plugins} />}
60
+ {plugins?.length > 0 && <PluginTag plugins={plugins} />}
56
61
  </>
57
62
  }
58
63
  title={title}
59
64
  />
60
- </>
65
+ </Flexbox>
61
66
  }
62
67
  right={
63
68
  id && (
64
69
  <>
65
- <ActionIcon
66
- icon={Share2}
67
- onClick={() => {
68
- // genShareUrl();
69
- }}
70
- size={{ fontSize: 24 }}
71
- title={t('share')}
72
- />
70
+ {/*<ActionIcon*/}
71
+ {/* icon={Share2}*/}
72
+ {/* onClick={() => {*/}
73
+ {/* // genShareUrl();*/}
74
+ {/* }}*/}
75
+ {/* size={{ fontSize: 24 }}*/}
76
+ {/* title={t('share')}*/}
77
+ {/*/>*/}
73
78
  <ActionIcon
74
79
  icon={showAgentSettings ? PanelRightClose : PanelRightOpen}
75
80
  onClick={() => toggleConfig()}
@@ -12,12 +12,7 @@ const Header = memo(() => {
12
12
 
13
13
  return (
14
14
  <ChatHeader
15
- left={
16
- <HeaderTitle
17
- tag={<Tag type={'version'}>{`v${pkg.version}`}</Tag>}
18
- title={t('header.global')}
19
- />
20
- }
15
+ left={<HeaderTitle tag={<Tag>{`v${pkg.version}`}</Tag>} title={t('header.global')} />}
21
16
  onBackClick={() => Router.back()}
22
17
  showBackButton
23
18
  />
@@ -1,79 +0,0 @@
1
- import { SiOpenai } from '@icons-pack/react-simple-icons';
2
- import { Tag as AntTag, type TagProps as AntTagProps } from 'antd';
3
- import { createStyles } from 'antd-style';
4
- import { capitalize as cap } from 'lodash-es';
5
- import { type LucideIcon, Milestone, ToyBrick } from 'lucide-react';
6
- import { ReactNode, memo } from 'react';
7
- import { Flexbox } from 'react-layout-kit';
8
-
9
- const useStyles = createStyles(({ cx, css, token }, hasCount?: boolean) => ({
10
- count: css`
11
- display: flex;
12
- align-items: center;
13
-
14
- height: 20px;
15
- padding: 0 8px;
16
-
17
- font-size: 12px;
18
- line-height: 1;
19
-
20
- background: ${token.colorFillTertiary};
21
- border: ${token.borderRadius}px;
22
- `,
23
- tag: cx(
24
- css`
25
- color: ${token.colorTextSecondary} !important;
26
- background: ${token.colorFillSecondary};
27
- border: ${token.borderRadius}px;
28
-
29
- &:hover {
30
- color: ${token.colorText};
31
- background: ${token.colorFill};
32
- }
33
- `,
34
- hasCount &&
35
- css`
36
- padding-right: 0 !important;
37
- `,
38
- ),
39
- }));
40
-
41
- export interface TagProps extends AntTagProps {
42
- capitalize?: boolean;
43
- children: string;
44
- count?: number;
45
- icon?: ReactNode;
46
- type?: 'openai' | 'plugin' | 'version';
47
- }
48
-
49
- const Tag = memo<TagProps>(({ type = 'openai', icon, capitalize, count, children, ...props }) => {
50
- const { styles } = useStyles(Boolean(count && count > 1));
51
- let IconRender: LucideIcon | any;
52
-
53
- switch (type) {
54
- case 'openai': {
55
- IconRender = SiOpenai;
56
- break;
57
- }
58
- case 'version': {
59
- IconRender = Milestone;
60
- break;
61
- }
62
- case 'plugin': {
63
- IconRender = ToyBrick;
64
- break;
65
- }
66
- }
67
-
68
- return (
69
- <AntTag bordered={false} className={styles.tag} {...props}>
70
- <Flexbox align={'center'} gap={4} horizontal>
71
- {icon ? icon : <IconRender size={'1em'} />}
72
- {capitalize ? cap(children) : children}
73
- {count && <div className={styles.count}>{`${count}+`}</div>}
74
- </Flexbox>
75
- </AntTag>
76
- );
77
- });
78
-
79
- export default Tag;