@lobehub/chat 0.40.2 → 0.40.4

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.4](https://github.com/lobehub/lobe-chat/compare/v0.40.3...v0.40.4)
6
+
7
+ <sup>Released on **2023-08-10**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: 优化 Header 样式.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: 优化 Header 样式 ([edd148a](https://github.com/lobehub/lobe-chat/commit/edd148a))
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.3](https://github.com/lobehub/lobe-chat/compare/v0.40.2...v0.40.3)
31
+
32
+ <sup>Released on **2023-08-10**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: 修正没有 prompt 的编辑与保存按钮的问题.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: 修正没有 prompt 的编辑与保存按钮的问题 ([b7e1648](https://github.com/lobehub/lobe-chat/commit/b7e1648))
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.2](https://github.com/lobehub/lobe-chat/compare/v0.40.1...v0.40.2)
6
56
 
7
57
  <sup>Released on **2023-08-08**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.40.2",
3
+ "version": "0.40.4",
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,9 +1,11 @@
1
- import { CodeEditor, FormGroup, TokenTag } from '@lobehub/ui';
1
+ import { EditableMessage, FormGroup, TokenTag } from '@lobehub/ui';
2
+ import { Button } from 'antd';
2
3
  import { createStyles } from 'antd-style';
3
4
  import { encode } from 'gpt-tokenizer';
4
5
  import { Bot } from 'lucide-react';
5
- import { memo, useMemo } from 'react';
6
+ import { memo, useMemo, useState } from 'react';
6
7
  import { useTranslation } from 'react-i18next';
8
+ import { Flexbox } from 'react-layout-kit';
7
9
 
8
10
  import { FORM_STYLE } from '@/const/layoutTokens';
9
11
  import { ModelTokens } from '@/const/modelTokens';
@@ -11,11 +13,16 @@ import { AgentAction } from '@/store/session/slices/agentConfig';
11
13
  import { LobeAgentConfig } from '@/types/session';
12
14
 
13
15
  export const useStyles = createStyles(({ css, token }) => ({
14
- token: css`
15
- padding-left: 8px;
16
- background: ${token.colorBgLayout};
17
- border: 1px solid ${token.colorBorder};
18
- border-radius: ${token.borderRadiusSM}px;
16
+ input: css`
17
+ padding: 12px;
18
+ background: ${token.colorFillTertiary};
19
+ border: 1px solid ${token.colorPrimaryBorder};
20
+ border-radius: 8px;
21
+ `,
22
+ markdown: css`
23
+ padding: 12px;
24
+ background: ${token.colorFillTertiary};
25
+ border: 1px solid transparent;
19
26
  `,
20
27
  }));
21
28
 
@@ -27,37 +34,55 @@ export interface AgentPromptProps {
27
34
  const AgentPrompt = memo<AgentPromptProps>(({ config, updateConfig }) => {
28
35
  const { t } = useTranslation('setting');
29
36
  const { styles } = useStyles();
37
+ const [editing, setEditing] = useState(false);
30
38
  const { systemRole, model } = config;
31
39
  const systemTokenCount = useMemo(() => encode(systemRole || '').length, [systemRole]);
32
40
 
33
41
  return (
34
42
  <FormGroup
35
43
  extra={
36
- <TokenTag
37
- className={styles.token}
38
- displayMode={'used'}
39
- maxValue={ModelTokens[model]}
40
- text={{
41
- overload: t('tokenTag.overload', { ns: 'common' }),
42
- remained: t('tokenTag.remained', { ns: 'common' }),
43
- used: t('tokenTag.used', { ns: 'common' }),
44
- }}
45
- value={systemTokenCount}
46
- />
44
+ <Flexbox align={'center'} gap={8} horizontal>
45
+ <TokenTag
46
+ displayMode={'used'}
47
+ maxValue={ModelTokens[model]}
48
+ text={{
49
+ overload: t('tokenTag.overload', { ns: 'common' }),
50
+ remained: t('tokenTag.remained', { ns: 'common' }),
51
+ used: t('tokenTag.used', { ns: 'common' }),
52
+ }}
53
+ value={systemTokenCount}
54
+ />
55
+ </Flexbox>
47
56
  }
48
57
  icon={Bot}
49
58
  style={FORM_STYLE.style}
50
59
  title={t('settingAgent.prompt.title')}
51
60
  >
52
- <CodeEditor
53
- language={'md'}
54
- onValueChange={(e) => updateConfig({ systemRole: e })}
55
- placeholder={t('settingAgent.prompt.placeholder')}
56
- resize={false}
57
- style={{ padding: '16px 0' }}
58
- type={'pure'}
59
- value={systemRole}
60
- />
61
+ <Flexbox gap={16} paddingBlock={16}>
62
+ <EditableMessage
63
+ classNames={styles}
64
+ editing={editing}
65
+ onChange={(e) => {
66
+ updateConfig({ systemRole: e });
67
+ }}
68
+ onEditingChange={setEditing}
69
+ showEditWhenEmpty
70
+ value={systemRole}
71
+ />
72
+ {!editing && !!systemRole && (
73
+ <Flexbox direction={'horizontal-reverse'}>
74
+ <Button
75
+ onClick={(e) => {
76
+ e.stopPropagation();
77
+ setEditing(true);
78
+ }}
79
+ type={'primary'}
80
+ >
81
+ {t('edit', { ns: 'common' })}
82
+ </Button>
83
+ </Flexbox>
84
+ )}
85
+ </Flexbox>
61
86
  </FormGroup>
62
87
  );
63
88
  });
@@ -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
  }
@@ -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;