@lobehub/chat 0.33.0 → 0.34.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/package.json +2 -2
  3. package/src/components/EmojiPicker/index.tsx +48 -0
  4. package/src/components/EmojiPicker/style.ts +28 -0
  5. package/src/const/meta.ts +3 -0
  6. package/src/const/settings.ts +50 -0
  7. package/src/{pages/chat/[id]/edit → features/AgentSetting}/AgentConfig/index.tsx +13 -11
  8. package/src/{pages/chat/[id]/edit → features/AgentSetting}/AgentMeta/AutoGenerateInput.tsx +16 -14
  9. package/src/features/AgentSetting/AgentMeta/BackgroundSwatches.tsx +27 -0
  10. package/src/features/AgentSetting/AgentMeta/index.tsx +128 -0
  11. package/src/{pages/chat/[id]/edit → features/AgentSetting}/AgentPlugin/index.tsx +12 -12
  12. package/src/{pages/chat/[id]/edit → features/AgentSetting}/AgentPrompt/index.tsx +13 -16
  13. package/src/features/AgentSetting/index.ts +4 -0
  14. package/src/features/AgentSetting/test.json +40 -0
  15. package/src/features/SideBar/{BottomAction.tsx → BottomActions.tsx} +15 -5
  16. package/src/features/SideBar/TopActions.tsx +42 -0
  17. package/src/features/SideBar/index.tsx +5 -30
  18. package/src/hooks/useImportConfig.ts +3 -3
  19. package/src/locales/default/common.ts +4 -0
  20. package/src/locales/default/setting.ts +4 -0
  21. package/src/pages/chat/[id]/Conversation/ChatList/index.tsx +1 -1
  22. package/src/pages/chat/[id]/Conversation/Input/Action.tsx +1 -1
  23. package/src/pages/chat/[id]/Header.tsx +1 -1
  24. package/src/pages/chat/[id]/{Config/SideBar.tsx → Sidebar/Inner.tsx} +2 -2
  25. package/src/pages/chat/[id]/{Config → Sidebar}/Topic/TopicContent.tsx +4 -6
  26. package/src/pages/chat/[id]/{Config → Sidebar}/index.tsx +2 -2
  27. package/src/pages/chat/[id]/index.page.tsx +1 -1
  28. package/src/pages/chat/[id]/{edit → setting}/index.page.tsx +23 -9
  29. package/src/pages/settings/Settings/Agent.tsx +25 -0
  30. package/src/pages/{setting/SettingForm.tsx → settings/Settings/Common.tsx} +7 -113
  31. package/src/pages/settings/Settings/index.tsx +50 -0
  32. package/src/pages/{setting → settings}/index.page.tsx +2 -2
  33. package/src/pages/{setting → settings}/layout.tsx +1 -1
  34. package/src/plugins/searchEngine/Render.tsx +3 -1
  35. package/src/store/session/slices/agentConfig/action.ts +8 -1
  36. package/src/store/session/slices/agentConfig/initialState.ts +2 -13
  37. package/src/store/session/slices/agentConfig/selectors.ts +13 -9
  38. package/src/store/session/slices/chat/actions/message.ts +12 -5
  39. package/src/store/session/slices/chat/actions/topic.ts +4 -2
  40. package/src/store/session/slices/chat/selectors/chat.ts +1 -1
  41. package/src/store/session/slices/session/action.ts +23 -16
  42. package/src/store/session/slices/session/initialState.ts +2 -1
  43. package/src/store/settings/action.ts +82 -11
  44. package/src/store/settings/initialState.ts +4 -27
  45. package/src/store/settings/selectors.ts +12 -7
  46. package/src/store/settings/store.ts +2 -2
  47. package/src/types/settings.ts +16 -8
  48. package/src/utils/storeDebug.ts +11 -0
  49. package/src/pages/chat/[id]/edit/AgentMeta/BackgroundSwatches.tsx +0 -31
  50. package/src/pages/chat/[id]/edit/AgentMeta/EmojiPicker.tsx +0 -78
  51. package/src/pages/chat/[id]/edit/AgentMeta/index.tsx +0 -111
  52. /package/src/pages/chat/[id]/{Config → Sidebar}/Header.tsx +0 -0
  53. /package/src/pages/chat/[id]/{Config → Sidebar}/Topic/DefaultContent.tsx +0 -0
  54. /package/src/pages/chat/[id]/{Config → Sidebar}/Topic/TopicItem.tsx +0 -0
  55. /package/src/pages/chat/[id]/{Config → Sidebar}/Topic/index.tsx +0 -0
  56. /package/src/pages/chat/[id]/{edit → setting}/Header.tsx +0 -0
  57. /package/src/pages/{setting → settings}/Header.tsx +0 -0
  58. /package/src/pages/{setting → settings}/ThemeSwatches/ThemeSwatchesNeutral.tsx +0 -0
  59. /package/src/pages/{setting → settings}/ThemeSwatches/ThemeSwatchesPrimary.tsx +0 -0
  60. /package/src/pages/{setting → settings}/ThemeSwatches/index.ts +0 -0
@@ -0,0 +1,42 @@
1
+ import { ActionIcon } from '@lobehub/ui';
2
+ import { MessageSquare, Sticker } from 'lucide-react';
3
+ import Router from 'next/router';
4
+ import { memo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+
7
+ import { SettingsStore } from '@/store/settings';
8
+
9
+ export interface TopActionProps {
10
+ setTab: SettingsStore['switchSideBar'];
11
+ tab: SettingsStore['sidebarKey'];
12
+ }
13
+
14
+ const TopActions = memo<TopActionProps>(({ tab, setTab }) => {
15
+ const { t } = useTranslation('common');
16
+
17
+ return (
18
+ <>
19
+ <ActionIcon
20
+ active={tab === 'chat'}
21
+ icon={MessageSquare}
22
+ onClick={() => {
23
+ // 如果已经在 chat 路径下了,那么就不用再跳转了
24
+ if (Router.asPath.startsWith('/chat')) return;
25
+
26
+ Router.push('/');
27
+ }}
28
+ size="large"
29
+ title={t('tab.chat')}
30
+ />
31
+ <ActionIcon
32
+ active={tab === 'market'}
33
+ icon={Sticker}
34
+ onClick={() => setTab('market')}
35
+ size="large"
36
+ title={t('tab.market')}
37
+ />
38
+ </>
39
+ );
40
+ });
41
+
42
+ export default TopActions;
@@ -1,13 +1,12 @@
1
- import { ActionIcon, SideNav } from '@lobehub/ui';
2
- import { MessageSquare, Settings2, Sticker } from 'lucide-react';
3
- import Router from 'next/router';
1
+ import { SideNav } from '@lobehub/ui';
4
2
  import { memo } from 'react';
5
3
  import { shallow } from 'zustand/shallow';
6
4
 
7
5
  import AvatarWithUpload from '@/features/AvatarWithUpload';
8
6
  import { useSettings } from '@/store/settings';
9
7
 
10
- import BottomAction from './BottomAction';
8
+ import BottomActions from './BottomActions';
9
+ import TopActions from './TopActions';
11
10
 
12
11
  export default memo(() => {
13
12
  const [tab, setTab] = useSettings((s) => [s.sidebarKey, s.switchSideBar], shallow);
@@ -15,33 +14,9 @@ export default memo(() => {
15
14
  return (
16
15
  <SideNav
17
16
  avatar={<AvatarWithUpload />}
18
- bottomActions={
19
- <BottomAction>
20
- <ActionIcon active={tab === 'setting'} icon={Settings2} />
21
- </BottomAction>
22
- }
17
+ bottomActions={<BottomActions setTab={setTab} tab={tab} />}
23
18
  style={{ height: '100vh' }}
24
- topActions={
25
- <>
26
- <ActionIcon
27
- active={tab === 'chat'}
28
- icon={MessageSquare}
29
- onClick={() => {
30
- // 如果已经在 chat 路径下了,那么就不用再跳转了
31
- if (Router.asPath.startsWith('/chat')) return;
32
-
33
- Router.push('/');
34
- }}
35
- size="large"
36
- />
37
- <ActionIcon
38
- active={tab === 'market'}
39
- icon={Sticker}
40
- onClick={() => setTab('market')}
41
- size="large"
42
- />
43
- </>
44
- }
19
+ topActions={<TopActions setTab={setTab} tab={tab} />}
45
20
  />
46
21
  );
47
22
  });
@@ -6,13 +6,13 @@ import { importConfigFile } from '@/utils/config';
6
6
 
7
7
  export const useImportConfig = () => {
8
8
  const importSessions = useSessionStore((s) => s.importSessions);
9
- const importSettings = useSettings((s) => s.importSettings);
9
+ const importAppSettings = useSettings((s) => s.importAppSettings);
10
10
 
11
11
  const importConfig = (info: any) => {
12
12
  importConfigFile(info, (config) => {
13
13
  switch (config.exportType) {
14
14
  case 'settings': {
15
- importSettings(config.state.settings);
15
+ importAppSettings(config.state.settings);
16
16
  break;
17
17
  }
18
18
 
@@ -24,7 +24,7 @@ export const useImportConfig = () => {
24
24
 
25
25
  case 'all': {
26
26
  importSessions(config.state.sessions);
27
- importSettings(config.state.settings);
27
+ importAppSettings(config.state.settings);
28
28
 
29
29
  break;
30
30
  }
@@ -49,6 +49,10 @@ export default {
49
49
  sendPlaceholder: '输入聊天内容...',
50
50
  setting: '设置',
51
51
  share: '分享',
52
+ tab: {
53
+ chat: '会话',
54
+ market: '助手市场',
55
+ },
52
56
  temp: '临时',
53
57
  tokenDetail: '系统设定: {{systemRoleToken}} 历史消息: {{chatsToken}}',
54
58
  topic: {
@@ -162,4 +162,8 @@ export default {
162
162
  },
163
163
  title: '主题设置',
164
164
  },
165
+ tab: {
166
+ agent: '默认角色',
167
+ common: '通用设置',
168
+ },
165
169
  };
@@ -33,7 +33,7 @@ const List = () => {
33
33
  const [displayMode, chatLoadingId, deleteMessage, resendMessage, dispatchMessage] =
34
34
  useSessionStore(
35
35
  (s) => [
36
- agentSelectors.currentAgentConfigSafe(s).displayMode,
36
+ agentSelectors.currentAgentConfig(s).displayMode,
37
37
  s.chatLoadingId,
38
38
  s.deleteMessage,
39
39
  s.resendMessage,
@@ -16,7 +16,7 @@ const InputActions = memo(() => {
16
16
  shallow,
17
17
  );
18
18
  const [model, temperature] = useSessionStore((s) => {
19
- const config = agentSelectors.currentAgentConfigSafe(s);
19
+ const config = agentSelectors.currentAgentConfig(s);
20
20
  return [
21
21
  config.model,
22
22
  config.params.temperature,
@@ -67,7 +67,7 @@ const Header = memo(() => {
67
67
  <ActionIcon
68
68
  icon={Settings}
69
69
  onClick={() => {
70
- Router.push(`/chat/${id}/edit`);
70
+ Router.push(`/chat/${id}/setting`);
71
71
  }}
72
72
  size={{ fontSize: 24 }}
73
73
  title={t('header.session', { ns: 'setting' })}
@@ -40,7 +40,7 @@ const useStyles = createStyles(({ css, token }) => ({
40
40
  `,
41
41
  }));
42
42
 
43
- const SideBar = memo(() => {
43
+ const Inner = memo(() => {
44
44
  const [openModal, setOpenModal] = useState(false);
45
45
  const { styles } = useStyles();
46
46
  const [systemRole, updateAgentConfig] = useSessionStore(
@@ -87,4 +87,4 @@ const SideBar = memo(() => {
87
87
  );
88
88
  });
89
89
 
90
- export default SideBar;
90
+ export default Inner;
@@ -4,6 +4,7 @@ import { createStyles } from 'antd-style';
4
4
  import { MoreVertical, PencilLine, Star, Trash } from 'lucide-react';
5
5
  import { memo, useMemo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
+ import { Flexbox } from 'react-layout-kit';
7
8
  import { shallow } from 'zustand/shallow';
8
9
 
9
10
  import { useSessionStore } from '@/store/session';
@@ -82,7 +83,7 @@ const TopicContent = memo<TopicContentProps>(({ id, title, fav }) => {
82
83
  );
83
84
 
84
85
  return (
85
- <>
86
+ <Flexbox align={'center'} gap={8} horizontal justify={'space-between'}>
86
87
  <ActionIcon
87
88
  color={fav ? theme.colorWarning : undefined}
88
89
  fill={fav ? theme.colorWarning : 'transparent'}
@@ -93,7 +94,6 @@ const TopicContent = memo<TopicContentProps>(({ id, title, fav }) => {
93
94
  }}
94
95
  size={'small'}
95
96
  />
96
-
97
97
  {!editing ? (
98
98
  <Paragraph
99
99
  className={styles.title}
@@ -115,11 +115,9 @@ const TopicContent = memo<TopicContentProps>(({ id, title, fav }) => {
115
115
  showEditIcon={false}
116
116
  size={'small'}
117
117
  style={{
118
- background: theme.colorBgContainer,
119
- borderRadius: 6,
120
118
  height: 28,
121
- padding: '0 2px',
122
119
  }}
120
+ type={'pure'}
123
121
  value={title}
124
122
  />
125
123
  )}
@@ -144,7 +142,7 @@ const TopicContent = memo<TopicContentProps>(({ id, title, fav }) => {
144
142
  />
145
143
  </Dropdown>
146
144
  )}
147
- </>
145
+ </Flexbox>
148
146
  );
149
147
  });
150
148
 
@@ -7,7 +7,7 @@ import HeaderSpacing from '@/components/HeaderSpacing';
7
7
  import { CHAT_SIDEBAR_WIDTH } from '@/const/layoutTokens';
8
8
  import { useSettings } from '@/store/settings';
9
9
 
10
- import SideBar from './SideBar';
10
+ import Inner from './Inner';
11
11
 
12
12
  const useStyles = createStyles(({ cx, css, token, stylish }) => ({
13
13
  drawer: cx(
@@ -38,7 +38,7 @@ const Config = () => {
38
38
  >
39
39
  <HeaderSpacing />
40
40
  <DraggablePanelContainer style={{ flex: 'none', minWidth: CHAT_SIDEBAR_WIDTH }}>
41
- <SideBar />
41
+ <Inner />
42
42
  </DraggablePanelContainer>
43
43
  </DraggablePanel>
44
44
  );
@@ -7,9 +7,9 @@ import { sessionSelectors, useSessionStore } from '@/store/session';
7
7
  import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
8
8
 
9
9
  import Layout from '../layout';
10
- import Config from './Config';
11
10
  import Conversation from './Conversation';
12
11
  import Header from './Header';
12
+ import Config from './Sidebar';
13
13
 
14
14
  const Chat = memo(() => {
15
15
  const [title] = useSessionStore((s) => {
@@ -1,3 +1,4 @@
1
+ import isEqual from 'fast-deep-equal';
1
2
  import Head from 'next/head';
2
3
  import { memo } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
@@ -6,20 +7,28 @@ import { shallow } from 'zustand/shallow';
6
7
 
7
8
  import HeaderSpacing from '@/components/HeaderSpacing';
8
9
  import { HEADER_HEIGHT } from '@/const/layoutTokens';
10
+ import { AgentConfig, AgentMeta, AgentPlugin, AgentPrompt } from '@/features/AgentSetting';
9
11
  import { agentSelectors, useSessionStore } from '@/store/session';
10
12
  import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
11
13
 
12
14
  import ChatLayout from '../../layout';
13
- import AgentConfig from './AgentConfig';
14
- import AgentMeta from './AgentMeta';
15
- import AgentPlugin from './AgentPlugin';
16
- import AgentPrompt from './AgentPrompt';
17
15
  import Header from './Header';
18
16
 
19
17
  const EditPage = memo(() => {
20
18
  const { t } = useTranslation('setting');
19
+ const config = useSessionStore(agentSelectors.currentAgentConfig, isEqual);
20
+ const meta = useSessionStore(agentSelectors.currentAgentMeta, isEqual);
21
+ const autocomplete = useSessionStore(agentSelectors.currentAutocomplete, shallow);
22
+ const [updateAgentConfig, toggleAgentPlugin, updateAgentMeta, title] = useSessionStore(
23
+ (s) => [
24
+ s.updateAgentConfig,
25
+ s.toggleAgentPlugin,
26
+ s.updateAgentMeta,
27
+ agentSelectors.currentAgentTitle(s),
28
+ ],
29
+ shallow,
30
+ );
21
31
 
22
- const title = useSessionStore(agentSelectors.currentAgentTitle, shallow);
23
32
  const pageTitle = genSiteHeadTitle(t('header.sessionWithName', { name: title }));
24
33
 
25
34
  return (
@@ -31,10 +40,15 @@ const EditPage = memo(() => {
31
40
  <Header />
32
41
  <Flexbox align={'center'} flex={1} gap={16} padding={24} style={{ overflow: 'auto' }}>
33
42
  <HeaderSpacing height={HEADER_HEIGHT - 16} />
34
- <AgentPrompt />
35
- <AgentMeta />
36
- <AgentConfig />
37
- <AgentPlugin />
43
+ <AgentPrompt config={config} updateConfig={updateAgentConfig} />
44
+ <AgentMeta
45
+ autocomplete={autocomplete}
46
+ config={config}
47
+ meta={meta}
48
+ updateMeta={updateAgentMeta}
49
+ />
50
+ <AgentConfig config={config} updateConfig={updateAgentConfig} />
51
+ <AgentPlugin config={config} updateConfig={toggleAgentPlugin} />
38
52
  </Flexbox>
39
53
  </ChatLayout>
40
54
  </>
@@ -0,0 +1,25 @@
1
+ import isEqual from 'fast-deep-equal';
2
+ import { memo } from 'react';
3
+ import { shallow } from 'zustand/shallow';
4
+
5
+ import { AgentConfig, AgentMeta, AgentPlugin, AgentPrompt } from '@/features/AgentSetting';
6
+ import { settingsSelectors, useSettings } from '@/store/settings';
7
+
8
+ const Agent = memo(() => {
9
+ const config = useSettings(settingsSelectors.currentAgentConfig, isEqual);
10
+ const meta = useSettings(settingsSelectors.currentAgentMeta, isEqual);
11
+ const [setAgentConfig, setAgentMeta, toggleAgentPlugin] = useSettings(
12
+ (s) => [s.setAgentConfig, s.setAgentMeta, s.toggleAgentPlugin],
13
+ shallow,
14
+ );
15
+ return (
16
+ <>
17
+ <AgentPrompt config={config} updateConfig={setAgentConfig} />
18
+ <AgentMeta config={config} meta={meta} updateMeta={setAgentMeta} />
19
+ <AgentConfig config={config} updateConfig={setAgentConfig} />
20
+ <AgentPlugin config={config} updateConfig={toggleAgentPlugin} />
21
+ </>
22
+ );
23
+ });
24
+
25
+ export default Agent;
@@ -1,23 +1,22 @@
1
1
  import { Form, type ItemGroup, ThemeSwitch } from '@lobehub/ui';
2
- import { Form as AntForm, App, Button, Input, Select, Switch } from 'antd';
2
+ import { Form as AntForm, App, Button, Input, Select } from 'antd';
3
3
  import isEqual from 'fast-deep-equal';
4
4
  import { debounce } from 'lodash-es';
5
- import { AppWindow, BrainCog, MessagesSquare, Palette, Webhook } from 'lucide-react';
5
+ import { AppWindow, Palette, Webhook } from 'lucide-react';
6
6
  import { memo, useCallback, useMemo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import SliderWithInput from 'src/components/SliderWithInput';
9
9
  import { shallow } from 'zustand/shallow';
10
10
 
11
11
  import { FORM_STYLE } from '@/const/layoutTokens';
12
+ import { DEFAULT_SETTINGS } from '@/const/settings';
12
13
  import AvatarWithUpload from '@/features/AvatarWithUpload';
13
14
  import { options } from '@/locales/options';
14
15
  import { useSessionStore } from '@/store/session';
15
16
  import { settingsSelectors, useSettings } from '@/store/settings';
16
- import { DEFAULT_SETTINGS } from '@/store/settings/initialState';
17
- import { LanguageModel } from '@/types/llm';
18
17
  import { ConfigKeys } from '@/types/settings';
19
18
 
20
- import { ThemeSwatchesNeutral, ThemeSwatchesPrimary } from './ThemeSwatches';
19
+ import { ThemeSwatchesNeutral, ThemeSwatchesPrimary } from '../ThemeSwatches';
21
20
 
22
21
  type SettingItemGroup = ItemGroup & {
23
22
  children: {
@@ -25,7 +24,7 @@ type SettingItemGroup = ItemGroup & {
25
24
  }[];
26
25
  };
27
26
 
28
- const SettingForm = memo(() => {
27
+ const Common = memo(() => {
29
28
  const { t } = useTranslation('setting');
30
29
  const [form] = AntForm.useForm();
31
30
  const clearSessions = useSessionStore((s) => s.clearSessions);
@@ -147,111 +146,6 @@ const SettingForm = memo(() => {
147
146
  [settings],
148
147
  );
149
148
 
150
- const chat: SettingItemGroup = useMemo(
151
- () => ({
152
- children: [
153
- {
154
- children: <Switch />,
155
- label: t('settingChat.enableHistoryCount.title'),
156
- minWidth: undefined,
157
- name: 'enableHistoryCount',
158
- valuePropName: 'checked',
159
- },
160
- {
161
- children: <SliderWithInput max={32} min={0} />,
162
- desc: t('settingChat.historyCount.desc'),
163
- hidden: !settings.enableHistoryCount,
164
- label: t('settingChat.historyCount.title'),
165
- name: 'historyCount',
166
- },
167
- {
168
- children: <Switch />,
169
- label: t('settingChat.enableCompressThreshold.title'),
170
- minWidth: undefined,
171
- name: 'enableCompressThreshold',
172
- valuePropName: 'checked',
173
- },
174
- {
175
- children: <SliderWithInput max={32} min={0} />,
176
- desc: t('settingChat.compressThreshold.desc'),
177
- hidden: !settings.enableCompressThreshold,
178
- label: t('settingChat.compressThreshold.title'),
179
- name: 'compressThreshold',
180
- },
181
- ],
182
- icon: MessagesSquare,
183
- title: t('settingChat.title'),
184
- }),
185
- [settings],
186
- );
187
-
188
- const model: SettingItemGroup = useMemo(
189
- () => ({
190
- children: [
191
- {
192
- children: (
193
- <Select
194
- options={Object.values(LanguageModel).map((value) => ({
195
- label: value,
196
- value,
197
- }))}
198
- />
199
- ),
200
- desc: t('settingModel.model.desc'),
201
- label: t('settingModel.model.title'),
202
- name: 'model',
203
- tag: 'model',
204
- },
205
- {
206
- children: <SliderWithInput max={1} min={0} step={0.1} />,
207
- desc: t('settingModel.temperature.desc'),
208
- label: t('settingModel.temperature.title'),
209
- name: 'temperature',
210
- tag: 'temperature',
211
- },
212
- {
213
- children: <SliderWithInput max={1} min={0} step={0.1} />,
214
- desc: t('settingModel.topP.desc'),
215
- label: t('settingModel.topP.title'),
216
- name: 'topP',
217
- tag: 'top_p',
218
- },
219
- {
220
- children: <SliderWithInput max={2} min={-2} step={0.1} />,
221
- desc: t('settingModel.presencePenalty.desc'),
222
- label: t('settingModel.presencePenalty.title'),
223
- name: 'presencePenalty',
224
- tag: 'presence_penalty',
225
- },
226
- {
227
- children: <SliderWithInput max={2} min={-2} step={0.1} />,
228
- desc: t('settingModel.frequencyPenalty.desc'),
229
- label: t('settingModel.frequencyPenalty.title'),
230
- name: 'frequencyPenalty',
231
- tag: 'frequency_penalty',
232
- },
233
- {
234
- children: <Switch />,
235
- label: t('settingModel.enableMaxTokens.title'),
236
- minWidth: undefined,
237
- name: 'enableMaxTokens',
238
- valuePropName: 'checked',
239
- },
240
- {
241
- children: <SliderWithInput max={32_000} min={0} step={100} />,
242
- desc: t('settingModel.maxTokens.desc'),
243
- hidden: !settings.enableMaxTokens,
244
- label: t('settingModel.maxTokens.title'),
245
- name: 'maxTokens',
246
- tag: 'max_tokens',
247
- },
248
- ],
249
- icon: BrainCog,
250
- title: t('settingModel.title'),
251
- }),
252
- [settings],
253
- );
254
-
255
149
  const system: SettingItemGroup = useMemo(
256
150
  () => ({
257
151
  children: [
@@ -288,7 +182,7 @@ const SettingForm = memo(() => {
288
182
  [settings],
289
183
  );
290
184
 
291
- const items = useMemo(() => [theme, openAI, chat, model, system], [settings]);
185
+ const items = useMemo(() => [theme, openAI, system], [settings]);
292
186
 
293
187
  return (
294
188
  <Form
@@ -301,4 +195,4 @@ const SettingForm = memo(() => {
301
195
  );
302
196
  });
303
197
 
304
- export default SettingForm;
198
+ export default Common;
@@ -0,0 +1,50 @@
1
+ import { Segmented } from 'antd';
2
+ import { createStyles } from 'antd-style';
3
+ import { memo, useState } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { Center } from 'react-layout-kit';
6
+
7
+ import Agent from './Agent';
8
+ import Common from './Common';
9
+
10
+ const useStyles = createStyles(({ css, token }) => ({
11
+ tabs: css`
12
+ padding: 4px;
13
+ border: 1px solid ${token.colorBorderSecondary};
14
+ border-radius: ${token.borderRadiusLG}px;
15
+
16
+ &:hover {
17
+ border-color: ${token.colorBorder};
18
+ }
19
+ `,
20
+ }));
21
+
22
+ enum Tabs {
23
+ common,
24
+ agent,
25
+ }
26
+
27
+ const Settings = memo(() => {
28
+ const [tab, setTab] = useState<Tabs>(Tabs.common);
29
+ const { styles } = useStyles();
30
+ const { t } = useTranslation('setting');
31
+
32
+ return (
33
+ <Center gap={16} width={'100%'}>
34
+ <div className={styles.tabs}>
35
+ <Segmented
36
+ onChange={(e) => setTab(e as Tabs)}
37
+ options={[
38
+ { label: t('tab.common'), value: Tabs.common },
39
+ { label: t('tab.agent'), value: Tabs.agent },
40
+ ]}
41
+ value={tab}
42
+ />
43
+ </div>
44
+ {tab === Tabs.common && <Common />}
45
+ {tab === Tabs.agent && <Agent />}
46
+ </Center>
47
+ );
48
+ });
49
+
50
+ export default Settings;
@@ -4,7 +4,7 @@ import { Flexbox } from 'react-layout-kit';
4
4
  import HeaderSpacing from '@/components/HeaderSpacing';
5
5
 
6
6
  import Header from './Header';
7
- import SettingForm from './SettingForm';
7
+ import Settings from './Settings';
8
8
  import SettingLayout from './layout';
9
9
 
10
10
  const Setting = memo(() => {
@@ -13,7 +13,7 @@ const Setting = memo(() => {
13
13
  <Header />
14
14
  <Flexbox align={'center'} flex={1} padding={24} style={{ overflow: 'auto' }}>
15
15
  <HeaderSpacing />
16
- <SettingForm />
16
+ <Settings />
17
17
  </Flexbox>
18
18
  </SettingLayout>
19
19
  );
@@ -21,7 +21,7 @@ const SettingLayout = memo<{ children: ReactNode }>(({ children }) => {
21
21
  useEffect(() => {
22
22
  const hasRehydrated = useSettings.persist.hasHydrated();
23
23
  if (hasRehydrated) {
24
- useSettings.setState({ sidebarKey: 'setting' });
24
+ useSettings.setState({ sidebarKey: 'settings' });
25
25
  }
26
26
  }, []);
27
27
 
@@ -1,4 +1,5 @@
1
1
  import { createStyles } from 'antd-style';
2
+ import Image from 'next/image';
2
3
  import Link from 'next/link';
3
4
  import { memo } from 'react';
4
5
  import { Flexbox } from 'react-layout-kit';
@@ -59,11 +60,12 @@ const Render = memo<PluginRenderProps<Result>>(({ content }) => {
59
60
  <Flexbox>
60
61
  <Flexbox align={'center'} gap={12} horizontal>
61
62
  {item.favicon && (
62
- <img
63
+ <Image
63
64
  alt={item.title || item.link}
64
65
  className={styles.favicon}
65
66
  height={24}
66
67
  src={item.favicon}
68
+ unoptimized
67
69
  width={24}
68
70
  />
69
71
  )}
@@ -6,9 +6,12 @@ import { SessionStore, sessionSelectors } from '@/store/session';
6
6
  import { MetaData } from '@/types/meta';
7
7
  import { LobeAgentConfig } from '@/types/session';
8
8
  import { fetchPresetTaskResult } from '@/utils/fetch';
9
+ import { setNamespace } from '@/utils/storeDebug';
9
10
 
10
11
  import { SessionLoadingState } from './initialState';
11
12
 
13
+ const t = setNamespace('agentConfig');
14
+
12
15
  /**
13
16
  * 代理行为接口
14
17
  */
@@ -234,6 +237,10 @@ export const createAgentSlice: StateCreator<
234
237
  }
235
238
  },
236
239
  updateLoadingState: (key, value) => {
237
- set({ autocompleteLoading: { ...get().autocompleteLoading, [key]: value } });
240
+ set(
241
+ { autocompleteLoading: { ...get().autocompleteLoading, [key]: value } },
242
+ false,
243
+ t('updateLoadingState', { key, value }),
244
+ );
238
245
  },
239
246
  });
@@ -1,4 +1,4 @@
1
- import { LanguageModel } from '@/types/llm';
1
+ import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
2
2
  import { MetaData } from '@/types/meta';
3
3
  import { LobeAgentConfig } from '@/types/session';
4
4
 
@@ -8,18 +8,7 @@ export interface AgentConfigState {
8
8
  autocompleteLoading: SessionLoadingState;
9
9
  }
10
10
 
11
- export const initialLobeAgentConfig: LobeAgentConfig = {
12
- displayMode: 'chat',
13
- model: LanguageModel.GPT3_5,
14
- params: {
15
- frequency_penalty: 0,
16
- presence_penalty: 0,
17
- temperature: 0.6,
18
- top_p: 1,
19
- },
20
- plugins: [],
21
- systemRole: '',
22
- };
11
+ export const initialLobeAgentConfig: LobeAgentConfig = DEFAULT_AGENT_CONFIG;
23
12
 
24
13
  export const initialAgentConfigState: AgentConfigState = {
25
14
  // // loading 中间态