@lobehub/chat 0.40.1 → 0.40.3
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.3](https://github.com/lobehub/lobe-chat/compare/v0.40.2...v0.40.3)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-08-10**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: 修正没有 prompt 的编辑与保存按钮的问题.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: 修正没有 prompt 的编辑与保存按钮的问题 ([b7e1648](https://github.com/lobehub/lobe-chat/commit/b7e1648))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.40.2](https://github.com/lobehub/lobe-chat/compare/v0.40.1...v0.40.2)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2023-08-08**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: 修正 defaults 造成的 config 报错.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: 修正 defaults 造成的 config 报错 ([0857fa7](https://github.com/lobehub/lobe-chat/commit/0857fa7))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
### [Version 0.40.1](https://github.com/lobehub/lobe-chat/compare/v0.40.0...v0.40.1)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2023-08-06**</sup>
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
15
|
-
padding
|
|
16
|
-
background: ${token.
|
|
17
|
-
border: 1px solid ${token.
|
|
18
|
-
border-radius:
|
|
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
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { t } from 'i18next';
|
|
2
|
-
import {
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
3
|
|
|
4
4
|
import { DEFAULT_AVATAR, DEFAULT_BACKGROUND_COLOR } from '@/const/meta';
|
|
5
5
|
import { Autocomplete } from '@/features/AgentSetting/AgentMeta';
|
|
@@ -37,12 +37,13 @@ const currentAgentBackgroundColor = (s: SessionStore) => {
|
|
|
37
37
|
const currentAgentAvatar = (s: SessionStore) => {
|
|
38
38
|
const session = sessionSelectors.currentSession(s);
|
|
39
39
|
if (!session) return DEFAULT_AVATAR;
|
|
40
|
+
|
|
40
41
|
return session.meta.avatar || DEFAULT_AVATAR;
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
const currentAgentConfig = (s: SessionStore) => {
|
|
44
45
|
const session = sessionSelectors.currentSession(s);
|
|
45
|
-
return
|
|
46
|
+
return merge({}, initialLobeAgentConfig, session?.config);
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
const currentAgentSystemRole = (s: SessionStore) => {
|
|
@@ -67,8 +68,8 @@ const hasSystemRole = (s: SessionStore) => {
|
|
|
67
68
|
return !!config.systemRole;
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const getAvatar = (s: MetaData) => s.avatar || DEFAULT_AVATAR;
|
|
72
|
+
const getTitle = (s: MetaData) => s.title || t('defaultSession', { ns: 'common' });
|
|
72
73
|
|
|
73
74
|
export const getDescription = (s: MetaData) =>
|
|
74
75
|
s.description || t('noDescription', { ns: 'common' });
|