@lobehub/chat 0.152.3 → 0.152.5

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 (211) hide show
  1. package/CHANGELOG.md +4 -29
  2. package/locales/ar/common.json +0 -14
  3. package/locales/ar/setting.json +1 -4
  4. package/locales/bg-BG/common.json +0 -14
  5. package/locales/bg-BG/setting.json +1 -4
  6. package/locales/de-DE/common.json +0 -14
  7. package/locales/de-DE/setting.json +1 -4
  8. package/locales/en-US/common.json +0 -14
  9. package/locales/en-US/setting.json +1 -4
  10. package/locales/es-ES/common.json +0 -14
  11. package/locales/es-ES/setting.json +1 -4
  12. package/locales/fr-FR/common.json +0 -14
  13. package/locales/fr-FR/setting.json +1 -4
  14. package/locales/it-IT/common.json +0 -14
  15. package/locales/it-IT/setting.json +1 -4
  16. package/locales/ja-JP/common.json +0 -14
  17. package/locales/ja-JP/setting.json +1 -4
  18. package/locales/ko-KR/common.json +0 -14
  19. package/locales/ko-KR/setting.json +1 -4
  20. package/locales/nl-NL/common.json +0 -14
  21. package/locales/nl-NL/setting.json +1 -4
  22. package/locales/pl-PL/common.json +0 -14
  23. package/locales/pl-PL/setting.json +1 -4
  24. package/locales/pt-BR/common.json +0 -14
  25. package/locales/pt-BR/setting.json +1 -4
  26. package/locales/ru-RU/common.json +0 -14
  27. package/locales/ru-RU/setting.json +1 -4
  28. package/locales/tr-TR/common.json +0 -14
  29. package/locales/tr-TR/setting.json +1 -4
  30. package/locales/vi-VN/common.json +0 -14
  31. package/locales/vi-VN/setting.json +1 -4
  32. package/locales/zh-CN/common.json +0 -14
  33. package/locales/zh-CN/setting.json +1 -4
  34. package/locales/zh-TW/common.json +0 -14
  35. package/locales/zh-TW/setting.json +1 -4
  36. package/package.json +1 -1
  37. package/src/app/(main)/@nav/_layout/Desktop/Avatar.tsx +11 -0
  38. package/src/app/(main)/@nav/_layout/Desktop/BottomActions.tsx +120 -7
  39. package/src/app/(main)/@nav/_layout/Desktop/index.tsx +2 -7
  40. package/src/app/(main)/@nav/_layout/Mobile.tsx +3 -3
  41. package/src/app/(main)/chat/(mobile)/features/SessionHeader.tsx +1 -1
  42. package/src/app/(main)/chat/_layout/Desktop/index.tsx +8 -6
  43. package/src/app/(main)/chat/_layout/Mobile/index.tsx +3 -5
  44. package/src/app/(main)/chat/features/SettingButton.tsx +5 -4
  45. package/src/app/(main)/chat/layout.ts +2 -5
  46. package/src/app/(main)/chat/settings/{_layout/Desktop → (desktop)}/Header.tsx +0 -2
  47. package/src/app/(main)/chat/settings/(desktop)/index.tsx +23 -0
  48. package/src/app/(main)/chat/settings/{_layout/Mobile → (mobile)}/Header.tsx +2 -3
  49. package/src/app/(main)/chat/settings/(mobile)/index.tsx +16 -0
  50. package/src/app/(main)/chat/settings/features/HeaderContent.tsx +9 -15
  51. package/src/app/(main)/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +0 -2
  52. package/src/app/(main)/chat/settings/features/SubmitAgentButton/index.tsx +8 -16
  53. package/src/app/(main)/chat/settings/layout.tsx +2 -9
  54. package/src/app/(main)/chat/settings/page.tsx +9 -2
  55. package/src/app/(main)/market/{_layout/Desktop/DetailSidebar.tsx → @detail/_layout/Desktop.tsx} +2 -2
  56. package/src/app/(main)/market/{_layout/Mobile/DetailModal.tsx → @detail/_layout/Mobile.tsx} +2 -2
  57. package/src/app/(main)/market/@detail/default.tsx +10 -1
  58. package/src/app/(main)/market/_layout/Desktop/index.tsx +1 -2
  59. package/src/app/(main)/market/_layout/Mobile/index.tsx +1 -3
  60. package/src/app/(main)/settings/(desktop)/index.tsx +23 -0
  61. package/src/app/(main)/settings/(mobile)/features/AvatarBanner.tsx +68 -0
  62. package/src/app/(main)/settings/(mobile)/features/ExtraList.tsx +65 -0
  63. package/src/app/(main)/settings/(mobile)/index.tsx +53 -0
  64. package/src/app/(main)/settings/_layout/Desktop/Header.tsx +23 -78
  65. package/src/app/(main)/settings/_layout/Desktop/SideBar.tsx +27 -39
  66. package/src/app/(main)/settings/_layout/Desktop/index.tsx +17 -41
  67. package/src/app/(main)/settings/_layout/Mobile/{Header.tsx → SubSettingHeader.tsx} +1 -3
  68. package/src/app/(main)/settings/_layout/Mobile/index.tsx +18 -7
  69. package/src/app/(main)/settings/about/AboutList.tsx +53 -0
  70. package/src/app/(main)/settings/about/Analytics.tsx +40 -0
  71. package/src/app/(main)/settings/about/page.tsx +33 -13
  72. package/src/app/(main)/settings/about/style.ts +22 -0
  73. package/src/app/(main)/settings/agent/Agent.tsx +29 -0
  74. package/src/app/(main)/settings/agent/loading.tsx +3 -0
  75. package/src/app/(main)/settings/agent/page.tsx +16 -8
  76. package/src/app/(main)/settings/common/{features/Common.tsx → Common.tsx} +5 -7
  77. package/src/app/(main)/settings/common/{features/Theme/index.tsx → Theme.tsx} +6 -8
  78. package/src/app/(main)/settings/common/index.tsx +16 -11
  79. package/src/app/(main)/settings/common/loading.tsx +3 -0
  80. package/src/app/(main)/settings/common/page.tsx +7 -8
  81. package/src/app/(main)/settings/features/Footer.tsx +0 -2
  82. package/src/app/(main)/settings/features/SettingList/index.tsx +47 -0
  83. package/src/app/(main)/settings/features/UpgradeAlert.tsx +13 -21
  84. package/src/app/(main)/settings/hooks/useSyncSettings.ts +2 -2
  85. package/src/app/(main)/settings/layout.ts +1 -4
  86. package/src/app/(main)/settings/llm/Anthropic/index.tsx +10 -4
  87. package/src/app/(main)/settings/llm/Azure/index.tsx +1 -3
  88. package/src/app/(main)/settings/llm/Bedrock/index.tsx +1 -3
  89. package/src/app/(main)/settings/llm/Google/index.tsx +2 -4
  90. package/src/app/(main)/settings/llm/Groq/index.tsx +1 -3
  91. package/src/app/(main)/settings/llm/Minimax/index.tsx +9 -3
  92. package/src/app/(main)/settings/llm/Mistral/index.tsx +9 -3
  93. package/src/app/(main)/settings/llm/Moonshot/index.tsx +1 -3
  94. package/src/app/(main)/settings/llm/Ollama/index.tsx +1 -3
  95. package/src/app/(main)/settings/llm/OpenAI/index.tsx +0 -2
  96. package/src/app/(main)/settings/llm/OpenRouter/index.tsx +9 -3
  97. package/src/app/(main)/settings/llm/Perplexity/index.tsx +9 -3
  98. package/src/app/(main)/settings/llm/TogetherAI/index.tsx +9 -3
  99. package/src/app/(main)/settings/llm/ZeroOne/index.tsx +9 -3
  100. package/src/app/(main)/settings/llm/Zhipu/index.tsx +10 -3
  101. package/src/app/(main)/settings/llm/components/Checker.tsx +0 -2
  102. package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +1 -16
  103. package/src/app/(main)/settings/llm/index.tsx +24 -12
  104. package/src/app/(main)/settings/llm/layout.tsx +11 -0
  105. package/src/app/(main)/settings/llm/loading.tsx +3 -0
  106. package/src/app/(main)/settings/llm/page.tsx +0 -15
  107. package/src/app/(main)/settings/page.tsx +14 -2
  108. package/src/app/(main)/settings/sync/{features/DeviceInfo → DeviceInfo}/Card.tsx +5 -6
  109. package/src/app/(main)/settings/sync/DeviceInfo/DeviceName.tsx +66 -0
  110. package/src/app/(main)/settings/sync/{features/DeviceInfo → DeviceInfo}/index.tsx +36 -22
  111. package/src/app/(main)/settings/sync/PageTitle.tsx +11 -0
  112. package/src/app/(main)/settings/sync/{features/WebRTC → WebRTC}/ChannelNameInput.tsx +3 -3
  113. package/src/app/(main)/settings/sync/{features/WebRTC → WebRTC}/index.tsx +9 -10
  114. package/src/app/(main)/settings/sync/{features/DeviceInfo → components}/SystemIcon.tsx +14 -6
  115. package/src/app/(main)/settings/sync/layout.tsx +12 -0
  116. package/src/app/(main)/settings/sync/loading.tsx +3 -0
  117. package/src/app/(main)/settings/sync/page.tsx +15 -11
  118. package/src/app/(main)/settings/tts/{features/STT.tsx → TTS/index.tsx} +27 -11
  119. package/src/app/(main)/settings/tts/loading.tsx +3 -0
  120. package/src/app/(main)/settings/tts/page.tsx +16 -8
  121. package/src/app/layout.tsx +3 -11
  122. package/src/const/url.ts +0 -1
  123. package/src/features/AgentSetting/AgentConfig/index.tsx +202 -0
  124. package/src/features/AgentSetting/AgentConfig/useSyncConfig.ts +23 -0
  125. package/src/features/AgentSetting/AgentMeta/index.tsx +3 -4
  126. package/src/features/AgentSetting/AgentPlugin/index.tsx +66 -65
  127. package/src/features/AgentSetting/AgentPrompt/index.tsx +47 -101
  128. package/src/features/AgentSetting/AgentTTS/index.tsx +0 -4
  129. package/src/features/AgentSetting/StoreUpdater.tsx +0 -2
  130. package/src/features/AgentSetting/index.tsx +6 -6
  131. package/src/features/AgentSetting/store/index.ts +0 -2
  132. package/src/features/AvatarWithUpload/index.tsx +0 -2
  133. package/src/locales/default/common.ts +0 -14
  134. package/src/locales/default/setting.ts +0 -3
  135. package/src/store/global/initialState.ts +0 -1
  136. package/src/app/(main)/(mobile)/me/features/AvatarBanner.tsx +0 -52
  137. package/src/app/(main)/(mobile)/me/features/Cate.tsx +0 -35
  138. package/src/app/(main)/(mobile)/me/features/ExtraCate.tsx +0 -26
  139. package/src/app/(main)/(mobile)/me/features/useExtraCate.tsx +0 -68
  140. package/src/app/(main)/(mobile)/me/layout.tsx +0 -11
  141. package/src/app/(main)/(mobile)/me/loading.tsx +0 -17
  142. package/src/app/(main)/(mobile)/me/page.tsx +0 -31
  143. package/src/app/(main)/@nav/features/UserAvatar.tsx +0 -24
  144. package/src/app/(main)/@nav/features/UserPanel/LangButton.tsx +0 -55
  145. package/src/app/(main)/@nav/features/UserPanel/Popover.tsx +0 -34
  146. package/src/app/(main)/@nav/features/UserPanel/ThemeButton.tsx +0 -70
  147. package/src/app/(main)/@nav/features/UserPanel/UserInfo.tsx +0 -35
  148. package/src/app/(main)/@nav/features/UserPanel/index.tsx +0 -69
  149. package/src/app/(main)/@nav/features/UserPanel/useMenu.tsx +0 -144
  150. package/src/app/(main)/@nav/features/UserPanel/useNewVersion.tsx +0 -12
  151. package/src/app/(main)/chat/_layout/type.ts +0 -5
  152. package/src/app/(main)/chat/settings/_layout/Desktop/index.tsx +0 -32
  153. package/src/app/(main)/chat/settings/_layout/Mobile/index.tsx +0 -15
  154. package/src/app/(main)/chat/settings/error.tsx +0 -5
  155. package/src/app/(main)/chat/settings/loading.tsx +0 -3
  156. package/src/app/(main)/chat/settings/m/page.tsx +0 -15
  157. package/src/app/(main)/chat/settings/not-found.tsx +0 -3
  158. package/src/app/(main)/market/@detail/loading.tsx +0 -1
  159. package/src/app/(main)/settings/@category/default.tsx +0 -16
  160. package/src/app/(main)/settings/@category/features/CategoryContent.tsx +0 -37
  161. package/src/app/(main)/settings/@category/features/UpgradeAlert.tsx +0 -38
  162. package/src/app/(main)/settings/_layout/type.ts +0 -6
  163. package/src/app/(main)/settings/about/features/AboutList.tsx +0 -122
  164. package/src/app/(main)/settings/about/features/Analytics.tsx +0 -42
  165. package/src/app/(main)/settings/about/index.tsx +0 -35
  166. package/src/app/(main)/settings/agent/index.tsx +0 -48
  167. package/src/app/(main)/settings/error.tsx +0 -5
  168. package/src/app/(main)/settings/hooks/useCategory.tsx +0 -54
  169. package/src/app/(main)/settings/llm/components/Footer.tsx +0 -26
  170. package/src/app/(main)/settings/loading.tsx +0 -9
  171. package/src/app/(main)/settings/m/page.tsx +0 -19
  172. package/src/app/(main)/settings/not-found.tsx +0 -3
  173. package/src/app/(main)/settings/sync/features/DeviceInfo/DeviceName.tsx +0 -63
  174. package/src/app/(main)/settings/sync/index.tsx +0 -17
  175. package/src/app/(main)/settings/tts/features/OpenAI.tsx +0 -54
  176. package/src/app/(main)/settings/tts/index.tsx +0 -15
  177. package/src/app/@modal/(.)settings/m/index.tsx +0 -34
  178. package/src/app/@modal/(.)settings/m/layout.tsx +0 -28
  179. package/src/app/@modal/(.)settings/m/loading.tsx +0 -5
  180. package/src/app/@modal/(.)settings/m/page.tsx +0 -10
  181. package/src/app/@modal/_layout/Desktop.tsx +0 -32
  182. package/src/app/@modal/_layout/Mobile.tsx +0 -1
  183. package/src/app/@modal/_layout/SettingModalLayout.tsx +0 -59
  184. package/src/app/@modal/chat/(.)settings/m/features/CategoryContent.tsx +0 -36
  185. package/src/app/@modal/chat/(.)settings/m/features/useCategory.tsx +0 -62
  186. package/src/app/@modal/chat/(.)settings/m/layout.tsx +0 -55
  187. package/src/app/@modal/chat/(.)settings/m/loading.tsx +0 -5
  188. package/src/app/@modal/chat/(.)settings/m/page.tsx +0 -34
  189. package/src/app/@modal/default.tsx +0 -1
  190. package/src/app/@modal/layout.tsx +0 -30
  191. package/src/app/@modal/loading.tsx +0 -5
  192. package/src/components/BrandWatermark/index.tsx +0 -39
  193. package/src/components/Cell/Divider.tsx +0 -19
  194. package/src/components/Cell/index.tsx +0 -38
  195. package/src/components/Menu/index.tsx +0 -97
  196. package/src/components/SkeletonLoading/index.tsx +0 -21
  197. package/src/features/AgentSetting/AgentChat/index.tsx +0 -135
  198. package/src/features/AgentSetting/AgentModal/index.tsx +0 -95
  199. package/src/hooks/useQuery.ts +0 -7
  200. package/src/hooks/useQueryRoute.ts +0 -16
  201. package/src/server/redirectHard.ts +0 -9
  202. /package/src/app/(main)/settings/{about/features → features/SettingList}/Item.tsx +0 -0
  203. /package/src/app/(main)/settings/{common/features/Theme → features}/ThemeSwatches/ThemeSwatchesNeutral.tsx +0 -0
  204. /package/src/app/(main)/settings/{common/features/Theme → features}/ThemeSwatches/ThemeSwatchesPrimary.tsx +0 -0
  205. /package/src/app/(main)/settings/{common/features/Theme → features}/ThemeSwatches/index.ts +0 -0
  206. /package/src/app/(main)/settings/sync/{features/Alert.tsx → Alert.tsx} +0 -0
  207. /package/src/app/(main)/settings/sync/{features/WebRTC → components}/SyncSwitch/index.css +0 -0
  208. /package/src/app/(main)/settings/sync/{features/WebRTC → components}/SyncSwitch/index.tsx +0 -0
  209. /package/src/app/(main)/settings/sync/{features/WebRTC/generateRandomRoomName.ts → util.ts} +0 -0
  210. /package/src/app/(main)/settings/tts/{features/const.ts → TTS/options.ts} +0 -0
  211. /package/src/features/AgentSetting/{AgentModal → AgentConfig}/ModelSelect.tsx +0 -0
@@ -1,24 +1,28 @@
1
1
  import { notFound } from 'next/navigation';
2
2
 
3
3
  import { serverFeatureFlags } from '@/config/server/featureFlags';
4
- import { translation } from '@/server/translation';
5
4
  import { gerServerDeviceInfo, isMobileDevice } from '@/utils/responsive';
6
5
 
7
- import Page from './index';
8
-
9
- export const generateMetadata = async () => {
10
- const { t } = await translation('setting');
11
- return {
12
- title: t('tab.sync'),
13
- };
14
- };
6
+ import Alert from './Alert';
7
+ import DeviceCard from './DeviceInfo';
8
+ import PageTitle from './PageTitle';
9
+ import WebRTC from './WebRTC';
15
10
 
16
11
  export default () => {
17
12
  const enableWebrtc = serverFeatureFlags().enableWebrtc;
13
+
18
14
  if (!enableWebrtc) return notFound();
19
15
 
20
- const isMobile = isMobileDevice();
21
16
  const { os, browser } = gerServerDeviceInfo();
17
+ const isMobile = isMobileDevice();
22
18
 
23
- return <Page browser={browser} mobile={isMobile} os={os} />;
19
+ return (
20
+ <>
21
+ {isMobile && <Alert mobile />}
22
+ <PageTitle />
23
+ <DeviceCard browser={browser} os={os} />
24
+ <WebRTC />
25
+ {!isMobile && <Alert />}
26
+ </>
27
+ );
24
28
  };
@@ -1,8 +1,8 @@
1
- 'use client';
2
-
3
1
  import { Form, type ItemGroup } from '@lobehub/ui';
4
- import { Select, Switch } from 'antd';
2
+ import { Form as AntForm, Select, Switch } from 'antd';
5
3
  import isEqual from 'fast-deep-equal';
4
+ import { debounce } from 'lodash-es';
5
+ import { Mic, Webhook } from 'lucide-react';
6
6
  import { memo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
 
@@ -10,15 +10,15 @@ import { FORM_STYLE } from '@/const/layoutTokens';
10
10
  import { useUserStore } from '@/store/user';
11
11
  import { settingsSelectors } from '@/store/user/selectors';
12
12
 
13
- import { sttOptions } from './const';
13
+ import { opeanaiSTTOptions, opeanaiTTSOptions, sttOptions } from './options';
14
14
 
15
15
  type SettingItemGroup = ItemGroup;
16
16
 
17
17
  const TTS_SETTING_KEY = 'tts';
18
18
 
19
- const STT = memo(() => {
19
+ const TTS = memo(() => {
20
20
  const { t } = useTranslation('setting');
21
- const [form] = Form.useForm();
21
+ const [form] = AntForm.useForm();
22
22
  const settings = useUserStore(settingsSelectors.currentSettings, isEqual);
23
23
  const [setSettings] = useUserStore((s) => [s.setSettings]);
24
24
 
@@ -39,20 +39,36 @@ const STT = memo(() => {
39
39
  valuePropName: 'checked',
40
40
  },
41
41
  ],
42
+ icon: Mic,
42
43
  title: t('settingTTS.stt'),
43
44
  };
44
45
 
46
+ const openai: SettingItemGroup = {
47
+ children: [
48
+ {
49
+ children: <Select options={opeanaiTTSOptions} />,
50
+ label: t('settingTTS.openai.ttsModel'),
51
+ name: [TTS_SETTING_KEY, 'openAI', 'ttsModel'],
52
+ },
53
+ {
54
+ children: <Select options={opeanaiSTTOptions} />,
55
+ label: t('settingTTS.openai.sttModel'),
56
+ name: [TTS_SETTING_KEY, 'openAI', 'sttModel'],
57
+ },
58
+ ],
59
+ icon: Webhook,
60
+ title: t('settingTTS.openai.title'),
61
+ };
62
+
45
63
  return (
46
64
  <Form
47
65
  form={form}
48
66
  initialValues={settings}
49
- items={[stt]}
50
- itemsType={'group'}
51
- onValuesChange={setSettings}
52
- variant={'pure'}
67
+ items={[stt, openai]}
68
+ onValuesChange={debounce(setSettings, 100)}
53
69
  {...FORM_STYLE}
54
70
  />
55
71
  );
56
72
  });
57
73
 
58
- export default STT;
74
+ export default TTS;
@@ -0,0 +1,3 @@
1
+ import { Skeleton } from 'antd';
2
+
3
+ export default () => <Skeleton paragraph={{ rows: 8 }} />;
@@ -1,10 +1,18 @@
1
- import { translation } from '@/server/translation';
1
+ 'use client';
2
2
 
3
- export const generateMetadata = async () => {
4
- const { t } = await translation('setting');
5
- return {
6
- title: t('tab.tts'),
7
- };
8
- };
3
+ import { memo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
9
5
 
10
- export { default } from './index';
6
+ import PageTitle from '@/components/PageTitle';
7
+
8
+ import TTS from './TTS';
9
+
10
+ export default memo(() => {
11
+ const { t } = useTranslation('setting');
12
+ return (
13
+ <>
14
+ <PageTitle title={t('tab.tts')} />
15
+ <TTS />
16
+ </>
17
+ );
18
+ });
@@ -1,7 +1,7 @@
1
1
  import { SpeedInsights } from '@vercel/speed-insights/next';
2
2
  import { ResolvingViewport } from 'next';
3
3
  import { cookies } from 'next/headers';
4
- import { ReactNode } from 'react';
4
+ import { PropsWithChildren } from 'react';
5
5
  import { isRtlLang } from 'rtl-detect';
6
6
 
7
7
  import Analytics from '@/components/Analytics';
@@ -10,12 +10,7 @@ import AuthProvider from '@/layout/AuthProvider';
10
10
  import GlobalProvider from '@/layout/GlobalProvider';
11
11
  import { isMobileDevice } from '@/utils/responsive';
12
12
 
13
- type RootLayoutProps = {
14
- children: ReactNode;
15
- modal: ReactNode;
16
- };
17
-
18
- const RootLayout = async ({ children, modal }: RootLayoutProps) => {
13
+ const RootLayout = async ({ children }: PropsWithChildren) => {
19
14
  const cookieStore = cookies();
20
15
 
21
16
  const lang = cookieStore.get(LOBE_LOCALE_COOKIE);
@@ -25,10 +20,7 @@ const RootLayout = async ({ children, modal }: RootLayoutProps) => {
25
20
  <html dir={direction} lang={lang?.value || DEFAULT_LANG} suppressHydrationWarning>
26
21
  <body>
27
22
  <GlobalProvider>
28
- <AuthProvider>
29
- {children}
30
- {modal}
31
- </AuthProvider>
23
+ <AuthProvider>{children}</AuthProvider>
32
24
  </GlobalProvider>
33
25
  <Analytics />
34
26
  <SpeedInsights />
package/src/const/url.ts CHANGED
@@ -29,7 +29,6 @@ export const ABOUT = OFFICIAL_SITE;
29
29
  export const FEEDBACK = pkg.bugs.url;
30
30
  export const DISCORD = 'https://discord.gg/AYFPHvv2jT';
31
31
  export const PRIVACY_URL = urlJoin(OFFICIAL_SITE, '/privacy');
32
- export const TERMS_URL = urlJoin(OFFICIAL_SITE, '/terms');
33
32
 
34
33
  export const PLUGINS_INDEX_URL = 'https://chat-plugins.lobehub.com';
35
34
 
@@ -0,0 +1,202 @@
1
+ import { Form, ItemGroup, SelectWithImg, SliderWithInput } from '@lobehub/ui';
2
+ import { Form as AFrom, Input, Switch } from 'antd';
3
+ import { useThemeMode } from 'antd-style';
4
+ import { debounce } from 'lodash-es';
5
+ import { BrainCog, LayoutList, MessageSquare, MessagesSquare } from 'lucide-react';
6
+ import { memo, useMemo } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+
9
+ import { FORM_STYLE } from '@/const/layoutTokens';
10
+ import { imageUrl } from '@/const/url';
11
+
12
+ import { useStore } from '../store';
13
+ import ModelSelect from './ModelSelect';
14
+ import { useSyncConfig } from './useSyncConfig';
15
+
16
+ const AgentConfig = memo(() => {
17
+ const { t } = useTranslation('setting');
18
+ const [form] = AFrom.useForm();
19
+ const { isDarkMode } = useThemeMode();
20
+
21
+ const [
22
+ displayMode,
23
+ enableAutoCreateTopic,
24
+ enableHistoryCount,
25
+ enableCompressThreshold,
26
+ enableMaxTokens,
27
+ updateConfig,
28
+ ] = useStore((s) => [
29
+ s.config.displayMode,
30
+ s.config.enableAutoCreateTopic,
31
+ s.config.enableHistoryCount,
32
+ s.config.enableCompressThreshold,
33
+ s.config.enableMaxTokens,
34
+ s.setAgentConfig,
35
+ ]);
36
+
37
+ useSyncConfig(form);
38
+
39
+ const formItems = useMemo(() => {
40
+ const chat: ItemGroup = {
41
+ children: [
42
+ {
43
+ children: (
44
+ <SelectWithImg
45
+ height={86}
46
+ onChange={(mode) => updateConfig({ displayMode: mode })}
47
+ options={[
48
+ {
49
+ icon: MessagesSquare,
50
+ img: imageUrl(`chatmode_chat_${isDarkMode ? 'dark' : 'light'}.webp`),
51
+ label: t('settingChat.chatStyleType.type.chat'),
52
+ value: 'chat',
53
+ },
54
+ {
55
+ icon: LayoutList,
56
+ img: imageUrl(`chatmode_docs_${isDarkMode ? 'dark' : 'light'}.webp`),
57
+ label: t('settingChat.chatStyleType.type.docs'),
58
+ value: 'docs',
59
+ },
60
+ ]}
61
+ unoptimized={false}
62
+ value={displayMode}
63
+ width={144}
64
+ />
65
+ ),
66
+ label: t('settingChat.chatStyleType.title'),
67
+ minWidth: undefined,
68
+ },
69
+ {
70
+ children: <Input.TextArea placeholder={t('settingChat.inputTemplate.placeholder')} />,
71
+ desc: t('settingChat.inputTemplate.desc'),
72
+ label: t('settingChat.inputTemplate.title'),
73
+ name: 'inputTemplate',
74
+ },
75
+ {
76
+ children: <Switch />,
77
+ desc: t('settingChat.enableAutoCreateTopic.desc'),
78
+ label: t('settingChat.enableAutoCreateTopic.title'),
79
+ minWidth: undefined,
80
+ name: 'enableAutoCreateTopic',
81
+ valuePropName: 'checked',
82
+ },
83
+ {
84
+ children: <SliderWithInput max={8} min={0} />,
85
+ desc: t('settingChat.autoCreateTopicThreshold.desc'),
86
+ divider: false,
87
+ hidden: !enableAutoCreateTopic,
88
+ label: t('settingChat.autoCreateTopicThreshold.title'),
89
+ name: 'autoCreateTopicThreshold',
90
+ },
91
+ {
92
+ children: <Switch />,
93
+ label: t('settingChat.enableHistoryCount.title'),
94
+ minWidth: undefined,
95
+ name: 'enableHistoryCount',
96
+ valuePropName: 'checked',
97
+ },
98
+ {
99
+ children: <SliderWithInput max={32} min={1} />,
100
+ desc: t('settingChat.historyCount.desc'),
101
+ divider: false,
102
+ hidden: !enableHistoryCount,
103
+ label: t('settingChat.historyCount.title'),
104
+ name: 'historyCount',
105
+ },
106
+ {
107
+ children: <Switch />,
108
+ label: t('settingChat.enableCompressThreshold.title'),
109
+ minWidth: undefined,
110
+ name: 'enableCompressThreshold',
111
+ valuePropName: 'checked',
112
+ },
113
+ {
114
+ children: <SliderWithInput max={32} min={0} />,
115
+ desc: t('settingChat.compressThreshold.desc'),
116
+ divider: false,
117
+ hidden: !enableCompressThreshold,
118
+ label: t('settingChat.compressThreshold.title'),
119
+ name: 'compressThreshold',
120
+ },
121
+ ],
122
+ icon: MessageSquare,
123
+ title: t('settingChat.title'),
124
+ };
125
+
126
+ const model: ItemGroup = {
127
+ children: [
128
+ {
129
+ children: <ModelSelect />,
130
+ desc: t('settingModel.model.desc'),
131
+ label: t('settingModel.model.title'),
132
+ name: 'model',
133
+ tag: 'model',
134
+ },
135
+ {
136
+ children: <SliderWithInput max={1} min={0} step={0.1} />,
137
+ desc: t('settingModel.temperature.desc'),
138
+ label: t('settingModel.temperature.title'),
139
+ name: ['params', 'temperature'],
140
+ tag: 'temperature',
141
+ },
142
+ {
143
+ children: <SliderWithInput max={1} min={0} step={0.1} />,
144
+ desc: t('settingModel.topP.desc'),
145
+ label: t('settingModel.topP.title'),
146
+ name: ['params', 'top_p'],
147
+ tag: 'top_p',
148
+ },
149
+ {
150
+ children: <SliderWithInput max={2} min={-2} step={0.1} />,
151
+ desc: t('settingModel.presencePenalty.desc'),
152
+ label: t('settingModel.presencePenalty.title'),
153
+ name: ['params', 'presence_penalty'],
154
+ tag: 'presence_penalty',
155
+ },
156
+ {
157
+ children: <SliderWithInput max={2} min={-2} step={0.1} />,
158
+ desc: t('settingModel.frequencyPenalty.desc'),
159
+ label: t('settingModel.frequencyPenalty.title'),
160
+ name: ['params', 'frequency_penalty'],
161
+ tag: 'frequency_penalty',
162
+ },
163
+ {
164
+ children: <Switch />,
165
+ label: t('settingModel.enableMaxTokens.title'),
166
+ minWidth: undefined,
167
+ name: 'enableMaxTokens',
168
+ valuePropName: 'checked',
169
+ },
170
+ {
171
+ children: <SliderWithInput max={32_000} min={0} step={100} />,
172
+ desc: t('settingModel.maxTokens.desc'),
173
+ divider: false,
174
+ hidden: !enableMaxTokens,
175
+ label: t('settingModel.maxTokens.title'),
176
+ name: ['params', 'max_tokens'],
177
+ tag: 'max_tokens',
178
+ },
179
+ ],
180
+ icon: BrainCog,
181
+ title: t('settingModel.title'),
182
+ };
183
+ return [chat, model];
184
+ }, [
185
+ displayMode,
186
+ enableAutoCreateTopic,
187
+ enableHistoryCount,
188
+ enableMaxTokens,
189
+ enableCompressThreshold,
190
+ ]);
191
+
192
+ return (
193
+ <Form
194
+ form={form}
195
+ items={formItems}
196
+ onValuesChange={debounce(updateConfig, 100)}
197
+ {...FORM_STYLE}
198
+ />
199
+ );
200
+ });
201
+
202
+ export default AgentConfig;
@@ -0,0 +1,23 @@
1
+ import { FormInstance } from 'antd/es/form/hooks/useForm';
2
+ import { useEffect } from 'react';
3
+
4
+ import { useStoreApi } from '../store';
5
+
6
+ export const useSyncConfig = (form: FormInstance) => {
7
+ const storeApi = useStoreApi();
8
+
9
+ useEffect(() => {
10
+ // set the first time
11
+ form.setFieldsValue(storeApi.getState().config);
12
+
13
+ // sync with later updated settings
14
+ const unsubscribe = storeApi.subscribe(
15
+ (s) => s.config,
16
+ (config) => form.setFieldsValue(config),
17
+ );
18
+
19
+ return () => {
20
+ unsubscribe();
21
+ };
22
+ }, []);
23
+ };
@@ -1,10 +1,8 @@
1
- 'use client';
2
-
3
1
  import { Form, type FormItemProps, Icon, type ItemGroup, Tooltip } from '@lobehub/ui';
4
2
  import { Button } from 'antd';
5
3
  import isEqual from 'fast-deep-equal';
6
4
  import { isString } from 'lodash-es';
7
- import { Wand2 } from 'lucide-react';
5
+ import { UserCircle, Wand2 } from 'lucide-react';
8
6
  import dynamic from 'next/dynamic';
9
7
  import { memo, useMemo } from 'react';
10
8
  import { useTranslation } from 'react-i18next';
@@ -120,12 +118,13 @@ const AgentMeta = memo(() => {
120
118
  </Button>
121
119
  </Tooltip>
122
120
  ),
121
+ icon: UserCircle,
123
122
  title: t('settingAgent.title'),
124
123
  }),
125
124
  [autocompleteItems, meta],
126
125
  );
127
126
 
128
- return <Form items={[metaData]} itemsType={'group'} variant={'pure'} {...FORM_STYLE} />;
127
+ return <Form items={[metaData]} {...FORM_STYLE} />;
129
128
  });
130
129
 
131
130
  export default AgentMeta;
@@ -1,9 +1,7 @@
1
- 'use client';
2
-
3
- import { Avatar, Form, Icon, ItemGroup, Tooltip } from '@lobehub/ui';
1
+ import { Avatar, Form, Icon, Tooltip } from '@lobehub/ui';
4
2
  import { Button, Empty, Space, Switch, Tag, Typography } from 'antd';
5
3
  import isEqual from 'fast-deep-equal';
6
- import { LucideTrash2, Store } from 'lucide-react';
4
+ import { LucideToyBrick, LucideTrash2, Store } from 'lucide-react';
7
5
  import { memo, useState } from 'react';
8
6
  import { Trans, useTranslation } from 'react-i18next';
9
7
  import { Center, Flexbox } from 'react-layout-kit';
@@ -92,70 +90,73 @@ const AgentPlugin = memo(() => {
92
90
  const hasDeprecated = deprecatedList.length > 0;
93
91
 
94
92
  const loadingSkeleton = LoadingList();
95
-
96
- const extra = (
97
- <Space.Compact style={{ width: 'auto' }}>
98
- <AddPluginButton />
99
- {hasDeprecated ? (
100
- <Tooltip title={t('plugin.clearDeprecated')}>
101
- <Button
102
- icon={<Icon icon={LucideTrash2} />}
103
- onClick={(e) => {
104
- e.stopPropagation();
105
- for (const i of deprecatedList) {
106
- toggleAgentPlugin(i.tag as string);
107
- }
108
- }}
109
- size={'small'}
110
- />
111
- </Tooltip>
112
- ) : null}
113
- <Tooltip title={t('plugin.store')}>
114
- <Button
115
- icon={<Icon icon={Store} />}
116
- onClick={(e) => {
117
- e.stopPropagation();
118
- setShowStore(true);
119
- }}
120
- size={'small'}
121
- />
122
- </Tooltip>
123
- </Space.Compact>
124
- );
125
-
126
- const empty = (
127
- <Center padding={40}>
128
- <Empty
129
- description={
130
- <Trans i18nKey={'plugin.empty'} ns={'setting'}>
131
- 暂无安装插件,
132
- <Typography.Link
133
- href={'/'}
134
- onClick={(e) => {
135
- e.preventDefault();
136
- setShowStore(true);
137
- }}
138
- >
139
- 前往插件市场
140
- </Typography.Link>
141
- 安装
142
- </Trans>
143
- }
144
- image={Empty.PRESENTED_IMAGE_SIMPLE}
145
- />
146
- </Center>
147
- );
148
-
149
- const plugin: ItemGroup = {
150
- children: isLoading ? loadingSkeleton : isEmpty ? empty : [...deprecatedList, ...list],
151
- extra,
152
- title: t('settingPlugin.title'),
153
- };
154
-
155
93
  return (
156
94
  <>
157
95
  <PluginStore open={showStore} setOpen={setShowStore} />
158
- <Form items={[plugin]} itemsType={'group'} variant={'pure'} {...FORM_STYLE} />
96
+ <Form
97
+ items={[
98
+ {
99
+ children: isLoading ? (
100
+ loadingSkeleton
101
+ ) : isEmpty ? (
102
+ <Center padding={40}>
103
+ <Empty
104
+ description={
105
+ <Trans i18nKey={'plugin.empty'} ns={'setting'}>
106
+ 暂无安装插件,
107
+ <Typography.Link
108
+ href={'/'}
109
+ onClick={(e) => {
110
+ e.preventDefault();
111
+ setShowStore(true);
112
+ }}
113
+ >
114
+ 前往插件市场
115
+ </Typography.Link>
116
+ 安装
117
+ </Trans>
118
+ }
119
+ image={Empty.PRESENTED_IMAGE_SIMPLE}
120
+ />
121
+ </Center>
122
+ ) : (
123
+ [...deprecatedList, ...list]
124
+ ),
125
+ extra: (
126
+ <Space.Compact style={{ width: 'auto' }}>
127
+ <AddPluginButton />
128
+ {hasDeprecated ? (
129
+ <Tooltip title={t('plugin.clearDeprecated')}>
130
+ <Button
131
+ icon={<Icon icon={LucideTrash2} />}
132
+ onClick={(e) => {
133
+ e.stopPropagation();
134
+ for (const i of deprecatedList) {
135
+ toggleAgentPlugin(i.tag as string);
136
+ }
137
+ }}
138
+ size={'small'}
139
+ />
140
+ </Tooltip>
141
+ ) : null}
142
+ <Tooltip title={t('plugin.store')}>
143
+ <Button
144
+ icon={<Icon icon={Store} />}
145
+ onClick={(e) => {
146
+ e.stopPropagation();
147
+ setShowStore(true);
148
+ }}
149
+ size={'small'}
150
+ />
151
+ </Tooltip>
152
+ </Space.Compact>
153
+ ),
154
+ icon: LucideToyBrick,
155
+ title: t('settingPlugin.title'),
156
+ },
157
+ ]}
158
+ {...FORM_STYLE}
159
+ />
159
160
  </>
160
161
  );
161
162
  });