@lobehub/chat 0.16.1 → 0.17.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 +25 -0
- package/package.json +1 -1
- package/src/pages/chat/[id]/edit/AgentConfig/index.tsx +12 -22
- package/src/store/session/slices/session/reducers/session.ts +5 -1
- package/src/store/settings/initialState.ts +2 -2
- package/src/types/session.ts +16 -0
- package/src/pages/chat/[id]/edit/FormItem.tsx +0 -26
- package/src/pages/chat/[id]/edit/style.ts +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 0.17.0](https://github.com/lobehub/lobe-chat/compare/v0.16.1...v0.17.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-07-24**</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**: 表单配置支持设定各项高级参数 ([6949cc6](https://github.com/lobehub/lobe-chat/commit/6949cc6))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.16.1](https://github.com/lobehub/lobe-chat/compare/v0.16.0...v0.16.1)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2023-07-24**</sup>
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ import type { LobeAgentConfig } from '@/types/session';
|
|
|
15
15
|
|
|
16
16
|
type SettingItemGroup = ItemGroup & {
|
|
17
17
|
children: {
|
|
18
|
-
name?: keyof LobeAgentConfig;
|
|
18
|
+
name?: keyof LobeAgentConfig | string[];
|
|
19
19
|
}[];
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -26,8 +26,6 @@ const AgentConfig = () => {
|
|
|
26
26
|
|
|
27
27
|
const [updateAgentConfig] = useSessionStore((s) => [s.updateAgentConfig], shallow);
|
|
28
28
|
|
|
29
|
-
// TODO: setting 结构嵌套,现在是扁平的 params: { temperature: 0.6 }
|
|
30
|
-
// @ts-ignore
|
|
31
29
|
const chat: SettingItemGroup = useMemo(
|
|
32
30
|
() => ({
|
|
33
31
|
children: [
|
|
@@ -42,13 +40,13 @@ const AgentConfig = () => {
|
|
|
42
40
|
),
|
|
43
41
|
label: t('settingChat.chatStyleType.title'),
|
|
44
42
|
minWidth: undefined,
|
|
45
|
-
name: '
|
|
43
|
+
name: 'displayMode',
|
|
46
44
|
},
|
|
47
45
|
{
|
|
48
46
|
children: <Input placeholder={t('settingChat.inputTemplate.placeholder')} />,
|
|
49
47
|
desc: t('settingChat.inputTemplate.desc'),
|
|
50
48
|
label: t('settingChat.inputTemplate.title'),
|
|
51
|
-
name: '
|
|
49
|
+
name: 'inputTemplate',
|
|
52
50
|
},
|
|
53
51
|
{
|
|
54
52
|
children: <Switch />,
|
|
@@ -60,8 +58,7 @@ const AgentConfig = () => {
|
|
|
60
58
|
{
|
|
61
59
|
children: <SliderWithInput max={32} min={0} />,
|
|
62
60
|
desc: t('settingChat.historyCount.desc'),
|
|
63
|
-
|
|
64
|
-
hidden: !config.params.enableHistoryCount,
|
|
61
|
+
hidden: !config.enableHistoryCount,
|
|
65
62
|
label: t('settingChat.historyCount.title'),
|
|
66
63
|
name: 'historyCount',
|
|
67
64
|
},
|
|
@@ -75,8 +72,7 @@ const AgentConfig = () => {
|
|
|
75
72
|
{
|
|
76
73
|
children: <SliderWithInput max={32} min={0} />,
|
|
77
74
|
desc: t('settingChat.compressThreshold.desc'),
|
|
78
|
-
|
|
79
|
-
hidden: !config.params.enableCompressThreshold,
|
|
75
|
+
hidden: !config.enableCompressThreshold,
|
|
80
76
|
label: t('settingChat.compressThreshold.title'),
|
|
81
77
|
name: 'compressThreshold',
|
|
82
78
|
},
|
|
@@ -87,8 +83,6 @@ const AgentConfig = () => {
|
|
|
87
83
|
[config],
|
|
88
84
|
);
|
|
89
85
|
|
|
90
|
-
// TODO: setting 结构嵌套,现在是扁平的 params: { temperature: 0.6 }
|
|
91
|
-
// @ts-ignore
|
|
92
86
|
const model: SettingItemGroup = useMemo(
|
|
93
87
|
() => ({
|
|
94
88
|
children: [
|
|
@@ -110,28 +104,28 @@ const AgentConfig = () => {
|
|
|
110
104
|
children: <SliderWithInput max={1} min={0} step={0.1} />,
|
|
111
105
|
desc: t('settingModel.temperature.desc'),
|
|
112
106
|
label: t('settingModel.temperature.title'),
|
|
113
|
-
name: 'temperature',
|
|
107
|
+
name: ['params', 'temperature'],
|
|
114
108
|
tag: 'temperature',
|
|
115
109
|
},
|
|
116
110
|
{
|
|
117
111
|
children: <SliderWithInput max={1} min={0} step={0.1} />,
|
|
118
112
|
desc: t('settingModel.topP.desc'),
|
|
119
113
|
label: t('settingModel.topP.title'),
|
|
120
|
-
name: '
|
|
114
|
+
name: ['params', 'top_p'],
|
|
121
115
|
tag: 'top_p',
|
|
122
116
|
},
|
|
123
117
|
{
|
|
124
118
|
children: <SliderWithInput max={2} min={-2} step={0.1} />,
|
|
125
119
|
desc: t('settingModel.presencePenalty.desc'),
|
|
126
120
|
label: t('settingModel.presencePenalty.title'),
|
|
127
|
-
name: '
|
|
121
|
+
name: ['params', 'presence_penalty'],
|
|
128
122
|
tag: 'presence_penalty',
|
|
129
123
|
},
|
|
130
124
|
{
|
|
131
125
|
children: <SliderWithInput max={2} min={-2} step={0.1} />,
|
|
132
126
|
desc: t('settingModel.frequencyPenalty.desc'),
|
|
133
127
|
label: t('settingModel.frequencyPenalty.title'),
|
|
134
|
-
name: '
|
|
128
|
+
name: ['params', 'frequency_penalty'],
|
|
135
129
|
tag: 'frequency_penalty',
|
|
136
130
|
},
|
|
137
131
|
{
|
|
@@ -144,11 +138,9 @@ const AgentConfig = () => {
|
|
|
144
138
|
{
|
|
145
139
|
children: <SliderWithInput max={32_000} min={0} step={100} />,
|
|
146
140
|
desc: t('settingModel.maxTokens.desc'),
|
|
147
|
-
|
|
148
|
-
// @ts-ignore
|
|
149
|
-
hidden: !config?.params?.enableMaxTokens,
|
|
141
|
+
hidden: !config?.enableMaxTokens,
|
|
150
142
|
label: t('settingModel.maxTokens.title'),
|
|
151
|
-
name: 'params
|
|
143
|
+
name: ['params', 'max_tokens'],
|
|
152
144
|
tag: 'max_tokens',
|
|
153
145
|
},
|
|
154
146
|
],
|
|
@@ -158,12 +150,10 @@ const AgentConfig = () => {
|
|
|
158
150
|
[config],
|
|
159
151
|
);
|
|
160
152
|
|
|
161
|
-
const items = useMemo(() => [chat, model], [config]);
|
|
162
|
-
|
|
163
153
|
return (
|
|
164
154
|
<Form
|
|
165
155
|
initialValues={config}
|
|
166
|
-
items={
|
|
156
|
+
items={[chat, model]}
|
|
167
157
|
onValuesChange={debounce(updateAgentConfig, 100)}
|
|
168
158
|
{...FORM_STYLE}
|
|
169
159
|
/>
|
|
@@ -102,7 +102,11 @@ export const sessionsReducer = (state: LobeSessions, payload: SessionDispatch):
|
|
|
102
102
|
const chat = draft[id];
|
|
103
103
|
if (!chat) return;
|
|
104
104
|
|
|
105
|
-
chat.config = {
|
|
105
|
+
chat.config = {
|
|
106
|
+
...chat.config,
|
|
107
|
+
...config,
|
|
108
|
+
params: { ...chat.config.params, ...config.params },
|
|
109
|
+
};
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -7,8 +7,8 @@ export const DEFAULT_SETTINGS: ConfigSettings = {
|
|
|
7
7
|
accessCode: '',
|
|
8
8
|
avatar: '',
|
|
9
9
|
compressThreshold: 24,
|
|
10
|
-
enableCompressThreshold:
|
|
11
|
-
enableHistoryCount:
|
|
10
|
+
enableCompressThreshold: false,
|
|
11
|
+
enableHistoryCount: false,
|
|
12
12
|
enableMaxTokens: true,
|
|
13
13
|
endpoint: '',
|
|
14
14
|
fontSize: 14,
|
package/src/types/session.ts
CHANGED
|
@@ -26,10 +26,26 @@ interface LobeSessionBase extends BaseDataModel {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface LobeAgentConfig {
|
|
29
|
+
compressThreshold?: number;
|
|
30
|
+
displayMode?: 'chat' | 'docs';
|
|
31
|
+
/**
|
|
32
|
+
* 历史消息长度压缩阈值
|
|
33
|
+
*/
|
|
34
|
+
enableCompressThreshold?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 开启历史记录条数
|
|
37
|
+
*/
|
|
38
|
+
enableHistoryCount?: boolean;
|
|
39
|
+
enableMaxTokens?: boolean;
|
|
29
40
|
/**
|
|
30
41
|
* 语言模型示例
|
|
31
42
|
*/
|
|
32
43
|
example?: LLMExample;
|
|
44
|
+
/**
|
|
45
|
+
* 历史消息条数
|
|
46
|
+
*/
|
|
47
|
+
historyCount?: number;
|
|
48
|
+
inputTemplate?: string;
|
|
33
49
|
/**
|
|
34
50
|
* 角色所使用的语言模型
|
|
35
51
|
* @default gpt-3.5-turbo
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createStyles } from 'antd-style';
|
|
2
|
-
import { ReactNode, memo } from 'react';
|
|
3
|
-
import { Flexbox } from 'react-layout-kit';
|
|
4
|
-
|
|
5
|
-
const useStyles = createStyles(({ css, token }) => ({
|
|
6
|
-
header: css``,
|
|
7
|
-
title: css`
|
|
8
|
-
color: ${token.colorTextSecondary};
|
|
9
|
-
`,
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
interface FormItemProps {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
label: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const FormItem = memo<FormItemProps>(({ label, children }) => {
|
|
18
|
-
const { styles } = useStyles();
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Flexbox className={styles.header} gap={12}>
|
|
22
|
-
<Flexbox className={styles.title}>{label}</Flexbox>
|
|
23
|
-
<Flexbox>{children}</Flexbox>
|
|
24
|
-
</Flexbox>
|
|
25
|
-
);
|
|
26
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { createStyles } from 'antd-style';
|
|
2
|
-
|
|
3
|
-
export const useStyles = createStyles(({ css, token }) => ({
|
|
4
|
-
collapseHeader: css`
|
|
5
|
-
.ant-collapse-header {
|
|
6
|
-
align-items: center !important;
|
|
7
|
-
}
|
|
8
|
-
`,
|
|
9
|
-
footer: css`
|
|
10
|
-
position: sticky;
|
|
11
|
-
bottom: 0;
|
|
12
|
-
border-top: 1px solid ${token.colorBorder};
|
|
13
|
-
`,
|
|
14
|
-
form: css`
|
|
15
|
-
overflow-y: auto;
|
|
16
|
-
`,
|
|
17
|
-
header: css`
|
|
18
|
-
background: ${token.colorBgContainer};
|
|
19
|
-
border-bottom: 1px solid ${token.colorSplit};
|
|
20
|
-
`,
|
|
21
|
-
profile: css`
|
|
22
|
-
font-size: 20px;
|
|
23
|
-
font-weight: bold;
|
|
24
|
-
color: ${token.colorText};
|
|
25
|
-
`,
|
|
26
|
-
prompt: css`
|
|
27
|
-
padding: 12px;
|
|
28
|
-
background: ${token.colorFillTertiary};
|
|
29
|
-
`,
|
|
30
|
-
title: css`
|
|
31
|
-
font-size: 16px;
|
|
32
|
-
font-weight: 500;
|
|
33
|
-
`,
|
|
34
|
-
}));
|