@lobehub/chat 0.40.2 → 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,31 @@
|
|
|
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
|
+
|
|
5
30
|
### [Version 0.40.2](https://github.com/lobehub/lobe-chat/compare/v0.40.1...v0.40.2)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2023-08-08**</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
|
});
|