@lobehub/chat 0.152.0 → 0.152.2

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 (255) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +8 -8
  3. package/README.zh-CN.md +8 -8
  4. package/locales/ar/common.json +14 -0
  5. package/locales/ar/setting.json +4 -1
  6. package/locales/bg-BG/common.json +14 -0
  7. package/locales/bg-BG/setting.json +4 -1
  8. package/locales/de-DE/common.json +14 -0
  9. package/locales/de-DE/setting.json +4 -1
  10. package/locales/en-US/common.json +14 -0
  11. package/locales/en-US/setting.json +4 -1
  12. package/locales/es-ES/common.json +14 -0
  13. package/locales/es-ES/setting.json +4 -1
  14. package/locales/fr-FR/common.json +14 -0
  15. package/locales/fr-FR/setting.json +4 -1
  16. package/locales/it-IT/common.json +14 -0
  17. package/locales/it-IT/setting.json +4 -1
  18. package/locales/ja-JP/common.json +14 -0
  19. package/locales/ja-JP/setting.json +4 -1
  20. package/locales/ko-KR/common.json +14 -0
  21. package/locales/ko-KR/setting.json +4 -1
  22. package/locales/nl-NL/common.json +14 -0
  23. package/locales/nl-NL/setting.json +4 -1
  24. package/locales/pl-PL/common.json +14 -0
  25. package/locales/pl-PL/setting.json +4 -1
  26. package/locales/pt-BR/common.json +14 -0
  27. package/locales/pt-BR/setting.json +4 -1
  28. package/locales/ru-RU/common.json +14 -0
  29. package/locales/ru-RU/setting.json +4 -1
  30. package/locales/tr-TR/common.json +14 -0
  31. package/locales/tr-TR/setting.json +4 -1
  32. package/locales/vi-VN/common.json +14 -0
  33. package/locales/vi-VN/setting.json +4 -1
  34. package/locales/zh-CN/common.json +14 -0
  35. package/locales/zh-CN/setting.json +4 -1
  36. package/locales/zh-TW/common.json +14 -0
  37. package/locales/zh-TW/setting.json +4 -1
  38. package/package.json +1 -1
  39. package/src/app/(main)/(mobile)/me/features/AvatarBanner.tsx +52 -0
  40. package/src/app/(main)/(mobile)/me/features/Cate.tsx +34 -0
  41. package/src/app/(main)/(mobile)/me/features/ExtraCate.tsx +26 -0
  42. package/src/app/(main)/(mobile)/me/features/useExtraCate.tsx +68 -0
  43. package/src/app/(main)/(mobile)/me/layout.tsx +11 -0
  44. package/src/app/(main)/(mobile)/me/loading.tsx +17 -0
  45. package/src/app/(main)/(mobile)/me/page.tsx +31 -0
  46. package/src/app/(main)/@nav/_layout/Desktop/BottomActions.tsx +7 -120
  47. package/src/app/(main)/@nav/_layout/Desktop/index.tsx +7 -2
  48. package/src/app/(main)/@nav/_layout/Mobile.tsx +3 -3
  49. package/src/app/(main)/@nav/features/UserAvatar.tsx +24 -0
  50. package/src/app/(main)/@nav/features/UserPanel/LangButton.tsx +55 -0
  51. package/src/app/(main)/@nav/features/UserPanel/Popover.tsx +34 -0
  52. package/src/app/(main)/@nav/features/UserPanel/ThemeButton.tsx +70 -0
  53. package/src/app/(main)/@nav/features/UserPanel/UserInfo.tsx +35 -0
  54. package/src/app/(main)/@nav/features/UserPanel/index.tsx +69 -0
  55. package/src/app/(main)/@nav/features/UserPanel/useMenu.tsx +144 -0
  56. package/src/app/(main)/@nav/features/UserPanel/useNewVersion.tsx +12 -0
  57. package/src/app/(main)/chat/(mobile)/features/SessionHeader.tsx +1 -1
  58. package/src/app/(main)/chat/_layout/Desktop/index.tsx +6 -8
  59. package/src/app/(main)/chat/_layout/Mobile/index.tsx +5 -3
  60. package/src/app/(main)/chat/_layout/type.ts +5 -0
  61. package/src/app/(main)/chat/features/SettingButton.tsx +5 -2
  62. package/src/app/(main)/chat/layout.ts +5 -2
  63. package/src/app/(main)/chat/settings/{(desktop) → _layout/Desktop}/Header.tsx +2 -0
  64. package/src/app/(main)/chat/settings/_layout/Desktop/index.tsx +32 -0
  65. package/src/app/(main)/chat/settings/{(mobile) → _layout/Mobile}/Header.tsx +3 -2
  66. package/src/app/(main)/chat/settings/_layout/Mobile/index.tsx +15 -0
  67. package/src/app/(main)/chat/settings/error.tsx +5 -0
  68. package/src/app/(main)/chat/settings/features/HeaderContent.tsx +15 -9
  69. package/src/app/(main)/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +2 -0
  70. package/src/app/(main)/chat/settings/features/SubmitAgentButton/index.tsx +16 -8
  71. package/src/app/(main)/chat/settings/layout.tsx +9 -2
  72. package/src/app/(main)/chat/settings/loading.tsx +3 -0
  73. package/src/app/(main)/chat/settings/not-found.tsx +3 -0
  74. package/src/app/(main)/chat/settings/page.tsx +2 -9
  75. package/src/app/(main)/market/@detail/default.tsx +12 -0
  76. package/src/app/(main)/market/{features/AgentDetailContent/AgentInfo → @detail/features/AgentDetailContent}/Header.tsx +30 -21
  77. package/src/app/(main)/market/{features/AgentDetailContent/AgentInfo → @detail/features/AgentDetailContent}/index.tsx +10 -4
  78. package/src/app/(main)/market/{features/AgentDetailContent/AgentInfo → @detail/features/AgentDetailContent}/style.ts +7 -11
  79. package/src/app/(main)/market/@detail/loading.tsx +1 -0
  80. package/src/app/(main)/market/_layout/Desktop/{AgentDetail.tsx → DetailSidebar.tsx} +17 -12
  81. package/src/app/(main)/market/_layout/Desktop/Header.tsx +3 -6
  82. package/src/app/(main)/market/_layout/Desktop/Hero.tsx +39 -0
  83. package/src/app/(main)/market/_layout/Desktop/index.tsx +24 -44
  84. package/src/app/(main)/market/{(mobile)/features/AgentDetail.tsx → _layout/Mobile/DetailModal.tsx} +9 -7
  85. package/src/app/(main)/market/_layout/Mobile/Header.tsx +2 -2
  86. package/src/app/(main)/market/_layout/Mobile/index.tsx +17 -9
  87. package/src/app/(main)/market/_layout/type.ts +6 -0
  88. package/src/app/(main)/market/features/AgentCard/AgentCardBanner.tsx +10 -9
  89. package/src/app/(main)/market/features/AgentCard/index.tsx +133 -58
  90. package/src/app/(main)/market/features/AgentList.tsx +94 -0
  91. package/src/app/(main)/market/features/AgentSearchBar.tsx +42 -0
  92. package/src/app/(main)/market/features/ShareAgentButton/Inner.tsx +9 -7
  93. package/src/app/(main)/market/features/ShareAgentButton/index.tsx +22 -15
  94. package/src/app/(main)/market/features/TagList.tsx +65 -0
  95. package/src/app/(main)/market/layout.tsx +11 -0
  96. package/src/app/(main)/market/loading.tsx +2 -2
  97. package/src/app/(main)/market/page.tsx +22 -12
  98. package/src/app/(main)/settings/@category/default.tsx +16 -0
  99. package/src/app/(main)/settings/@category/features/CategoryContent.tsx +35 -0
  100. package/src/app/(main)/settings/@category/features/UpgradeAlert.tsx +38 -0
  101. package/src/app/(main)/settings/_layout/Desktop/Header.tsx +78 -23
  102. package/src/app/(main)/settings/_layout/Desktop/SideBar.tsx +39 -27
  103. package/src/app/(main)/settings/_layout/Desktop/index.tsx +41 -17
  104. package/src/app/(main)/settings/_layout/Mobile/{SubSettingHeader.tsx → Header.tsx} +3 -1
  105. package/src/app/(main)/settings/_layout/Mobile/index.tsx +7 -18
  106. package/src/app/(main)/settings/_layout/type.ts +6 -0
  107. package/src/app/(main)/settings/about/features/AboutList.tsx +122 -0
  108. package/src/app/(main)/settings/about/features/Analytics.tsx +42 -0
  109. package/src/app/(main)/settings/about/layout.tsx +26 -0
  110. package/src/app/(main)/settings/about/loading.tsx +5 -0
  111. package/src/app/(main)/settings/about/page.tsx +20 -25
  112. package/src/app/(main)/settings/agent/layout.tsx +35 -0
  113. package/src/app/(main)/settings/agent/loading.tsx +4 -2
  114. package/src/app/(main)/settings/agent/page.tsx +25 -12
  115. package/src/app/(main)/settings/common/{Common.tsx → features/Common.tsx} +7 -5
  116. package/src/app/(main)/settings/common/{Theme.tsx → features/Theme/index.tsx} +8 -6
  117. package/src/app/(main)/settings/common/page.tsx +21 -4
  118. package/src/app/(main)/settings/error.tsx +5 -0
  119. package/src/app/(main)/settings/features/Footer.tsx +2 -0
  120. package/src/app/(main)/settings/features/UpgradeAlert.tsx +21 -13
  121. package/src/app/(main)/settings/hooks/useCategory.tsx +54 -0
  122. package/src/app/(main)/settings/hooks/useSyncSettings.ts +2 -2
  123. package/src/app/(main)/settings/layout.ts +4 -1
  124. package/src/app/(main)/settings/llm/Anthropic/index.tsx +4 -10
  125. package/src/app/(main)/settings/llm/Azure/index.tsx +3 -1
  126. package/src/app/(main)/settings/llm/Bedrock/index.tsx +3 -1
  127. package/src/app/(main)/settings/llm/Google/index.tsx +4 -2
  128. package/src/app/(main)/settings/llm/Groq/index.tsx +3 -1
  129. package/src/app/(main)/settings/llm/Minimax/index.tsx +3 -9
  130. package/src/app/(main)/settings/llm/Mistral/index.tsx +3 -9
  131. package/src/app/(main)/settings/llm/Moonshot/index.tsx +3 -1
  132. package/src/app/(main)/settings/llm/Ollama/index.tsx +3 -1
  133. package/src/app/(main)/settings/llm/OpenAI/index.tsx +2 -0
  134. package/src/app/(main)/settings/llm/OpenRouter/index.tsx +3 -9
  135. package/src/app/(main)/settings/llm/Perplexity/index.tsx +3 -9
  136. package/src/app/(main)/settings/llm/TogetherAI/index.tsx +3 -9
  137. package/src/app/(main)/settings/llm/ZeroOne/index.tsx +3 -9
  138. package/src/app/(main)/settings/llm/Zhipu/index.tsx +3 -10
  139. package/src/app/(main)/settings/llm/components/Checker.tsx +2 -0
  140. package/src/app/(main)/settings/llm/components/Footer.tsx +26 -0
  141. package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +16 -1
  142. package/src/app/(main)/settings/llm/page.tsx +57 -3
  143. package/src/app/(main)/settings/loading.tsx +9 -0
  144. package/src/app/(main)/settings/not-found.tsx +3 -0
  145. package/src/app/(main)/settings/page.tsx +2 -14
  146. package/src/app/(main)/settings/sync/{DeviceInfo → features/DeviceInfo}/Card.tsx +6 -5
  147. package/src/app/(main)/settings/sync/features/DeviceInfo/DeviceName.tsx +63 -0
  148. package/src/app/(main)/settings/sync/{components → features/DeviceInfo}/SystemIcon.tsx +6 -14
  149. package/src/app/(main)/settings/sync/{DeviceInfo → features/DeviceInfo}/index.tsx +22 -36
  150. package/src/app/(main)/settings/sync/{WebRTC → features/WebRTC}/ChannelNameInput.tsx +3 -3
  151. package/src/app/(main)/settings/sync/{WebRTC → features/WebRTC}/index.tsx +10 -9
  152. package/src/app/(main)/settings/sync/page.tsx +19 -11
  153. package/src/app/(main)/settings/tts/features/OpenAI.tsx +54 -0
  154. package/src/app/(main)/settings/tts/{TTS/index.tsx → features/STT.tsx} +11 -27
  155. package/src/app/(main)/settings/tts/page.tsx +17 -11
  156. package/src/app/@modal/(.)settings/about/layout.tsx +1 -0
  157. package/src/app/@modal/(.)settings/about/page.tsx +1 -0
  158. package/src/app/@modal/(.)settings/agent/layout.tsx +1 -0
  159. package/src/app/@modal/(.)settings/agent/page.tsx +1 -0
  160. package/src/app/@modal/(.)settings/common/page.tsx +1 -0
  161. package/src/app/@modal/(.)settings/layout.tsx +28 -0
  162. package/src/app/@modal/(.)settings/llm/page.tsx +1 -0
  163. package/src/app/@modal/(.)settings/loading.tsx +5 -0
  164. package/src/app/@modal/(.)settings/sync/page.tsx +1 -0
  165. package/src/app/@modal/(.)settings/tts/page.tsx +1 -0
  166. package/src/app/@modal/_layout/SettingModalLayout.tsx +59 -0
  167. package/src/app/@modal/chat/(.)settings/features/CategoryContent.tsx +36 -0
  168. package/src/app/@modal/chat/(.)settings/features/useCategory.tsx +62 -0
  169. package/src/app/@modal/chat/(.)settings/layout.tsx +55 -0
  170. package/src/app/@modal/chat/(.)settings/loading.tsx +5 -0
  171. package/src/app/@modal/chat/(.)settings/page.tsx +40 -0
  172. package/src/app/@modal/default.tsx +1 -0
  173. package/src/app/@modal/layout.tsx +30 -0
  174. package/src/app/@modal/loading.tsx +5 -0
  175. package/src/app/layout.tsx +11 -3
  176. package/src/components/BrandWatermark/index.tsx +39 -0
  177. package/src/components/Cell/Divider.tsx +19 -0
  178. package/src/components/Cell/index.tsx +38 -0
  179. package/src/components/Menu/index.tsx +97 -0
  180. package/src/components/SkeletonLoading/index.tsx +21 -0
  181. package/src/const/url.ts +1 -0
  182. package/src/features/AgentSetting/AgentChat/index.tsx +135 -0
  183. package/src/features/AgentSetting/AgentMeta/index.tsx +4 -3
  184. package/src/features/AgentSetting/AgentModal/index.tsx +95 -0
  185. package/src/features/AgentSetting/AgentPlugin/index.tsx +65 -66
  186. package/src/features/AgentSetting/AgentPrompt/index.tsx +101 -47
  187. package/src/features/AgentSetting/AgentTTS/index.tsx +4 -0
  188. package/src/features/AgentSetting/StoreUpdater.tsx +2 -0
  189. package/src/features/AgentSetting/index.tsx +6 -6
  190. package/src/features/AgentSetting/store/index.ts +2 -0
  191. package/src/features/AvatarWithUpload/index.tsx +2 -0
  192. package/src/features/ChatInput/STT/browser.tsx +1 -1
  193. package/src/features/ChatInput/STT/openai.tsx +1 -1
  194. package/src/features/Conversation/components/InboxWelcome/AgentsSuggest.tsx +2 -2
  195. package/src/hooks/useQuery.ts +7 -0
  196. package/src/hooks/useQueryRoute.ts +16 -0
  197. package/src/locales/default/common.ts +14 -0
  198. package/src/locales/default/setting.ts +3 -0
  199. package/src/locales/resources.ts +1 -0
  200. package/src/server/redirectHard.ts +9 -0
  201. package/src/server/translation.ts +20 -0
  202. package/src/services/__tests__/chat.test.ts +1 -1
  203. package/src/store/global/initialState.ts +1 -0
  204. package/src/store/market/action.ts +1 -1
  205. package/src/store/session/slices/session/action.ts +1 -1
  206. package/src/utils/difference.ts +2 -1
  207. package/src/app/(main)/@nav/_layout/Desktop/Avatar.tsx +0 -11
  208. package/src/app/(main)/chat/settings/(desktop)/index.tsx +0 -23
  209. package/src/app/(main)/chat/settings/(mobile)/index.tsx +0 -16
  210. package/src/app/(main)/market/(desktop)/index.tsx +0 -20
  211. package/src/app/(main)/market/(mobile)/features/AgentCard.tsx +0 -31
  212. package/src/app/(main)/market/(mobile)/index.tsx +0 -25
  213. package/src/app/(main)/market/components/Loading.tsx +0 -13
  214. package/src/app/(main)/market/features/AgentCard/AgentCardItem.tsx +0 -54
  215. package/src/app/(main)/market/features/AgentCard/style.ts +0 -33
  216. package/src/app/(main)/market/features/AgentDetailContent/index.tsx +0 -12
  217. package/src/app/(main)/market/features/AgentSearchBar/index.tsx +0 -40
  218. package/src/app/(main)/market/features/PageTitle/index.tsx +0 -13
  219. package/src/app/(main)/market/features/TagList/Inner.tsx +0 -28
  220. package/src/app/(main)/market/features/TagList/index.tsx +0 -23
  221. package/src/app/(main)/market/layout.ts +0 -8
  222. package/src/app/(main)/settings/(desktop)/index.tsx +0 -23
  223. package/src/app/(main)/settings/(mobile)/features/AvatarBanner.tsx +0 -68
  224. package/src/app/(main)/settings/(mobile)/features/ExtraList.tsx +0 -65
  225. package/src/app/(main)/settings/(mobile)/index.tsx +0 -53
  226. package/src/app/(main)/settings/about/AboutList.tsx +0 -53
  227. package/src/app/(main)/settings/about/Analytics.tsx +0 -40
  228. package/src/app/(main)/settings/about/style.ts +0 -22
  229. package/src/app/(main)/settings/agent/Agent.tsx +0 -29
  230. package/src/app/(main)/settings/common/index.tsx +0 -24
  231. package/src/app/(main)/settings/common/loading.tsx +0 -3
  232. package/src/app/(main)/settings/features/SettingList/index.tsx +0 -47
  233. package/src/app/(main)/settings/llm/index.tsx +0 -59
  234. package/src/app/(main)/settings/llm/layout.tsx +0 -11
  235. package/src/app/(main)/settings/llm/loading.tsx +0 -3
  236. package/src/app/(main)/settings/sync/DeviceInfo/DeviceName.tsx +0 -66
  237. package/src/app/(main)/settings/sync/PageTitle.tsx +0 -11
  238. package/src/app/(main)/settings/sync/layout.tsx +0 -12
  239. package/src/app/(main)/settings/sync/loading.tsx +0 -3
  240. package/src/app/(main)/settings/tts/loading.tsx +0 -3
  241. package/src/features/AgentSetting/AgentConfig/index.tsx +0 -202
  242. package/src/features/AgentSetting/AgentConfig/useSyncConfig.ts +0 -23
  243. /package/src/app/(main)/market/{features/AgentDetailContent/AgentInfo → @detail/features/AgentDetailContent}/Comment.tsx +0 -0
  244. /package/src/app/(main)/market/{features/AgentDetailContent/AgentInfo → @detail/features/AgentDetailContent}/Loading.tsx +0 -0
  245. /package/src/app/(main)/market/{features/AgentDetailContent/AgentInfo → @detail/features/AgentDetailContent}/TokenTag.tsx +0 -0
  246. /package/src/app/(main)/settings/{features/SettingList → about/features}/Item.tsx +0 -0
  247. /package/src/app/(main)/settings/{features → common/features/Theme}/ThemeSwatches/ThemeSwatchesNeutral.tsx +0 -0
  248. /package/src/app/(main)/settings/{features → common/features/Theme}/ThemeSwatches/ThemeSwatchesPrimary.tsx +0 -0
  249. /package/src/app/(main)/settings/{features → common/features/Theme}/ThemeSwatches/index.ts +0 -0
  250. /package/src/app/(main)/settings/sync/{Alert.tsx → features/Alert.tsx} +0 -0
  251. /package/src/app/(main)/settings/sync/{components → features/WebRTC}/SyncSwitch/index.css +0 -0
  252. /package/src/app/(main)/settings/sync/{components → features/WebRTC}/SyncSwitch/index.tsx +0 -0
  253. /package/src/app/(main)/settings/sync/{util.ts → features/WebRTC/generateRandomRoomName.ts} +0 -0
  254. /package/src/app/(main)/settings/tts/{TTS/options.ts → features/const.ts} +0 -0
  255. /package/src/features/AgentSetting/{AgentConfig → AgentModal}/ModelSelect.tsx +0 -0
@@ -0,0 +1,135 @@
1
+ 'use client';
2
+
3
+ import { Form, ItemGroup, SelectWithImg, SliderWithInput } from '@lobehub/ui';
4
+ import { Input, Switch } from 'antd';
5
+ import { useThemeMode } from 'antd-style';
6
+ import { debounce } from 'lodash-es';
7
+ import { LayoutList, MessagesSquare } from 'lucide-react';
8
+ import { memo } from 'react';
9
+ import { useTranslation } from 'react-i18next';
10
+
11
+ import { useSyncSettings } from '@/app/(main)/settings/hooks/useSyncSettings';
12
+ import { FORM_STYLE } from '@/const/layoutTokens';
13
+ import { imageUrl } from '@/const/url';
14
+
15
+ import { useStore } from '../store';
16
+
17
+ const AgentChat = memo(() => {
18
+ const { t } = useTranslation('setting');
19
+ const [form] = Form.useForm();
20
+ const { isDarkMode } = useThemeMode();
21
+
22
+ const [
23
+ displayMode,
24
+ enableAutoCreateTopic,
25
+ enableHistoryCount,
26
+ enableCompressThreshold,
27
+ updateConfig,
28
+ ] = useStore((s) => [
29
+ s.config.displayMode,
30
+ s.config.enableAutoCreateTopic,
31
+ s.config.enableHistoryCount,
32
+ s.config.enableCompressThreshold,
33
+ s.setAgentConfig,
34
+ ]);
35
+
36
+ useSyncSettings(form);
37
+
38
+ const chat: ItemGroup = {
39
+ children: [
40
+ {
41
+ children: (
42
+ <SelectWithImg
43
+ height={86}
44
+ onChange={(mode) => updateConfig({ displayMode: mode })}
45
+ options={[
46
+ {
47
+ icon: MessagesSquare,
48
+ img: imageUrl(`chatmode_chat_${isDarkMode ? 'dark' : 'light'}.webp`),
49
+ label: t('settingChat.chatStyleType.type.chat'),
50
+ value: 'chat',
51
+ },
52
+ {
53
+ icon: LayoutList,
54
+ img: imageUrl(`chatmode_docs_${isDarkMode ? 'dark' : 'light'}.webp`),
55
+ label: t('settingChat.chatStyleType.type.docs'),
56
+ value: 'docs',
57
+ },
58
+ ]}
59
+ unoptimized={false}
60
+ value={displayMode}
61
+ width={144}
62
+ />
63
+ ),
64
+ label: t('settingChat.chatStyleType.title'),
65
+ minWidth: undefined,
66
+ },
67
+ {
68
+ children: <Input.TextArea placeholder={t('settingChat.inputTemplate.placeholder')} />,
69
+ desc: t('settingChat.inputTemplate.desc'),
70
+ label: t('settingChat.inputTemplate.title'),
71
+ name: 'inputTemplate',
72
+ },
73
+ {
74
+ children: <Switch />,
75
+ desc: t('settingChat.enableAutoCreateTopic.desc'),
76
+ label: t('settingChat.enableAutoCreateTopic.title'),
77
+ minWidth: undefined,
78
+ name: 'enableAutoCreateTopic',
79
+ valuePropName: 'checked',
80
+ },
81
+ {
82
+ children: <SliderWithInput max={8} min={0} />,
83
+ desc: t('settingChat.autoCreateTopicThreshold.desc'),
84
+ divider: false,
85
+ hidden: !enableAutoCreateTopic,
86
+ label: t('settingChat.autoCreateTopicThreshold.title'),
87
+ name: 'autoCreateTopicThreshold',
88
+ },
89
+ {
90
+ children: <Switch />,
91
+ label: t('settingChat.enableHistoryCount.title'),
92
+ minWidth: undefined,
93
+ name: 'enableHistoryCount',
94
+ valuePropName: 'checked',
95
+ },
96
+ {
97
+ children: <SliderWithInput max={32} min={1} />,
98
+ desc: t('settingChat.historyCount.desc'),
99
+ divider: false,
100
+ hidden: !enableHistoryCount,
101
+ label: t('settingChat.historyCount.title'),
102
+ name: 'historyCount',
103
+ },
104
+ {
105
+ children: <Switch />,
106
+ label: t('settingChat.enableCompressThreshold.title'),
107
+ minWidth: undefined,
108
+ name: 'enableCompressThreshold',
109
+ valuePropName: 'checked',
110
+ },
111
+ {
112
+ children: <SliderWithInput max={32} min={0} />,
113
+ desc: t('settingChat.compressThreshold.desc'),
114
+ divider: false,
115
+ hidden: !enableCompressThreshold,
116
+ label: t('settingChat.compressThreshold.title'),
117
+ name: 'compressThreshold',
118
+ },
119
+ ],
120
+ title: t('settingChat.title'),
121
+ };
122
+
123
+ return (
124
+ <Form
125
+ form={form}
126
+ items={[chat]}
127
+ itemsType={'group'}
128
+ onValuesChange={debounce(updateConfig, 100)}
129
+ variant={'pure'}
130
+ {...FORM_STYLE}
131
+ />
132
+ );
133
+ });
134
+
135
+ export default AgentChat;
@@ -1,8 +1,10 @@
1
+ 'use client';
2
+
1
3
  import { Form, type FormItemProps, Icon, type ItemGroup, Tooltip } from '@lobehub/ui';
2
4
  import { Button } from 'antd';
3
5
  import isEqual from 'fast-deep-equal';
4
6
  import { isString } from 'lodash-es';
5
- import { UserCircle, Wand2 } from 'lucide-react';
7
+ import { Wand2 } from 'lucide-react';
6
8
  import dynamic from 'next/dynamic';
7
9
  import { memo, useMemo } from 'react';
8
10
  import { useTranslation } from 'react-i18next';
@@ -118,13 +120,12 @@ const AgentMeta = memo(() => {
118
120
  </Button>
119
121
  </Tooltip>
120
122
  ),
121
- icon: UserCircle,
122
123
  title: t('settingAgent.title'),
123
124
  }),
124
125
  [autocompleteItems, meta],
125
126
  );
126
127
 
127
- return <Form items={[metaData]} {...FORM_STYLE} />;
128
+ return <Form items={[metaData]} itemsType={'group'} variant={'pure'} {...FORM_STYLE} />;
128
129
  });
129
130
 
130
131
  export default AgentMeta;
@@ -0,0 +1,95 @@
1
+ 'use client';
2
+
3
+ import { Form, ItemGroup, SliderWithInput } from '@lobehub/ui';
4
+ import { Switch } from 'antd';
5
+ import { debounce } from 'lodash-es';
6
+ import { memo } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+
9
+ import { useSyncSettings } from '@/app/(main)/settings/hooks/useSyncSettings';
10
+ import { FORM_STYLE } from '@/const/layoutTokens';
11
+
12
+ import { useStore } from '../store';
13
+ import ModelSelect from './ModelSelect';
14
+
15
+ const AgentModal = memo(() => {
16
+ const { t } = useTranslation('setting');
17
+ const [form] = Form.useForm();
18
+
19
+ const [enableMaxTokens, updateConfig] = useStore((s) => [
20
+ s.config.enableMaxTokens,
21
+ s.setAgentConfig,
22
+ ]);
23
+
24
+ useSyncSettings(form);
25
+
26
+ const model: ItemGroup = {
27
+ children: [
28
+ {
29
+ children: <ModelSelect />,
30
+ desc: t('settingModel.model.desc'),
31
+ label: t('settingModel.model.title'),
32
+ name: 'model',
33
+ tag: 'model',
34
+ },
35
+ {
36
+ children: <SliderWithInput max={1} min={0} step={0.1} />,
37
+ desc: t('settingModel.temperature.desc'),
38
+ label: t('settingModel.temperature.title'),
39
+ name: ['params', 'temperature'],
40
+ tag: 'temperature',
41
+ },
42
+ {
43
+ children: <SliderWithInput max={1} min={0} step={0.1} />,
44
+ desc: t('settingModel.topP.desc'),
45
+ label: t('settingModel.topP.title'),
46
+ name: ['params', 'top_p'],
47
+ tag: 'top_p',
48
+ },
49
+ {
50
+ children: <SliderWithInput max={2} min={-2} step={0.1} />,
51
+ desc: t('settingModel.presencePenalty.desc'),
52
+ label: t('settingModel.presencePenalty.title'),
53
+ name: ['params', 'presence_penalty'],
54
+ tag: 'presence_penalty',
55
+ },
56
+ {
57
+ children: <SliderWithInput max={2} min={-2} step={0.1} />,
58
+ desc: t('settingModel.frequencyPenalty.desc'),
59
+ label: t('settingModel.frequencyPenalty.title'),
60
+ name: ['params', 'frequency_penalty'],
61
+ tag: 'frequency_penalty',
62
+ },
63
+ {
64
+ children: <Switch />,
65
+ label: t('settingModel.enableMaxTokens.title'),
66
+ minWidth: undefined,
67
+ name: 'enableMaxTokens',
68
+ valuePropName: 'checked',
69
+ },
70
+ {
71
+ children: <SliderWithInput max={32_000} min={0} step={100} />,
72
+ desc: t('settingModel.maxTokens.desc'),
73
+ divider: false,
74
+ hidden: !enableMaxTokens,
75
+ label: t('settingModel.maxTokens.title'),
76
+ name: ['params', 'max_tokens'],
77
+ tag: 'max_tokens',
78
+ },
79
+ ],
80
+ title: t('settingModel.title'),
81
+ };
82
+
83
+ return (
84
+ <Form
85
+ form={form}
86
+ items={[model]}
87
+ itemsType={'group'}
88
+ onValuesChange={debounce(updateConfig, 100)}
89
+ variant={'pure'}
90
+ {...FORM_STYLE}
91
+ />
92
+ );
93
+ });
94
+
95
+ export default AgentModal;
@@ -1,7 +1,9 @@
1
- import { Avatar, Form, Icon, Tooltip } from '@lobehub/ui';
1
+ 'use client';
2
+
3
+ import { Avatar, Form, Icon, ItemGroup, Tooltip } from '@lobehub/ui';
2
4
  import { Button, Empty, Space, Switch, Tag, Typography } from 'antd';
3
5
  import isEqual from 'fast-deep-equal';
4
- import { LucideToyBrick, LucideTrash2, Store } from 'lucide-react';
6
+ import { LucideTrash2, Store } from 'lucide-react';
5
7
  import { memo, useState } from 'react';
6
8
  import { Trans, useTranslation } from 'react-i18next';
7
9
  import { Center, Flexbox } from 'react-layout-kit';
@@ -90,73 +92,70 @@ const AgentPlugin = memo(() => {
90
92
  const hasDeprecated = deprecatedList.length > 0;
91
93
 
92
94
  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
+
93
155
  return (
94
156
  <>
95
157
  <PluginStore open={showStore} setOpen={setShowStore} />
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
- />
158
+ <Form items={[plugin]} itemsType={'group'} variant={'pure'} {...FORM_STYLE} />
160
159
  </>
161
160
  );
162
161
  });
@@ -1,7 +1,8 @@
1
- import { EditableMessage, FormGroup } from '@lobehub/ui';
1
+ 'use client';
2
+
3
+ import { EditableMessage, Form } from '@lobehub/ui';
2
4
  import { Button } from 'antd';
3
5
  import { createStyles } from 'antd-style';
4
- import { Bot } from 'lucide-react';
5
6
  import { memo, useState } from 'react';
6
7
  import { useTranslation } from 'react-i18next';
7
8
  import { Flexbox } from 'react-layout-kit';
@@ -9,65 +10,118 @@ import { Flexbox } from 'react-layout-kit';
9
10
  import { FORM_STYLE } from '@/const/layoutTokens';
10
11
 
11
12
  import { useStore } from '../store';
12
- import TokenTag from './TokenTag';
13
13
 
14
- export const useStyles = createStyles(({ css, token }) => ({
14
+ export const useStyles = createStyles(({ css, token, responsive }) => ({
15
+ container: css`
16
+ position: relative;
17
+ width: 100%;
18
+ background: ${token.colorFillSecondary};
19
+ border-radius: ${token.borderRadiusLG}px;
20
+ `,
21
+ content: css`
22
+ z-index: 2;
23
+ padding: 8px;
24
+ background: ${token.colorBgContainer};
25
+ border-radius: ${token.borderRadiusLG - 1}px;
26
+ `,
15
27
  markdown: css`
16
28
  border: unset;
17
29
  `,
18
- textarea: css`
19
- background: ${token.colorFillTertiary};
30
+ wrapper: css`
31
+ width: 100%;
32
+ ${responsive.mobile} {
33
+ padding-block: 8px;
34
+ padding-inline: 4px;
35
+ }
20
36
  `,
21
37
  }));
22
38
 
23
- const AgentPrompt = memo(() => {
39
+ const AgentPrompt = memo<{ modal?: boolean }>(({ modal }) => {
24
40
  const { t } = useTranslation('setting');
25
41
  const { styles } = useStyles();
26
42
  const [editing, setEditing] = useState(false);
27
43
  const [systemRole, updateConfig] = useStore((s) => [s.config.systemRole, s.setAgentConfig]);
28
44
 
29
- return (
30
- <FormGroup
31
- extra={<TokenTag />}
32
- icon={Bot}
33
- style={FORM_STYLE.style}
34
- title={t('settingAgent.prompt.title')}
45
+ const content = (
46
+ <EditableMessage
47
+ classNames={{
48
+ markdown: styles.markdown,
49
+ }}
50
+ editButtonSize={'small'}
51
+ editing={editing}
52
+ height={'auto'}
53
+ inputType={'pure'}
54
+ onChange={(e) => {
55
+ updateConfig({ systemRole: e });
56
+ }}
57
+ onEditingChange={setEditing}
58
+ placeholder={t('settingAgent.prompt.placeholder')}
59
+ showEditWhenEmpty
60
+ text={{
61
+ cancel: t('cancel', { ns: 'common' }),
62
+ confirm: t('ok', { ns: 'common' }),
63
+ }}
64
+ value={systemRole}
65
+ />
66
+ );
67
+
68
+ const editButton = !editing && !!systemRole && (
69
+ <Button
70
+ onClick={(e) => {
71
+ e.stopPropagation();
72
+ setEditing(true);
73
+ }}
74
+ size={'small'}
75
+ type={'primary'}
35
76
  >
36
- <Flexbox gap={16} paddingBlock={16}>
37
- <EditableMessage
38
- classNames={styles}
39
- editButtonSize={'small'}
40
- editing={editing}
41
- height={'auto'}
42
- inputType={'ghost'}
43
- onChange={(e) => {
44
- updateConfig({ systemRole: e });
45
- }}
46
- onEditingChange={setEditing}
47
- placeholder={t('settingAgent.prompt.placeholder')}
48
- showEditWhenEmpty
49
- text={{
50
- cancel: t('cancel', { ns: 'common' }),
51
- confirm: t('ok', { ns: 'common' }),
52
- }}
53
- value={systemRole}
54
- />
55
- {!editing && !!systemRole && (
56
- <Flexbox direction={'horizontal-reverse'}>
57
- <Button
58
- onClick={(e) => {
59
- e.stopPropagation();
60
- setEditing(true);
61
- }}
62
- size={'small'}
63
- type={'primary'}
64
- >
65
- {t('edit', { ns: 'common' })}
66
- </Button>
67
- </Flexbox>
68
- )}
77
+ {t('edit', { ns: 'common' })}
78
+ </Button>
79
+ );
80
+
81
+ if (modal)
82
+ return (
83
+ <Form
84
+ items={[
85
+ {
86
+ children: (
87
+ <>
88
+ <div style={{ height: 24 }} />
89
+ {content}
90
+ </>
91
+ ),
92
+ extra: editButton,
93
+ title: t('settingAgent.prompt.title'),
94
+ },
95
+ ]}
96
+ itemsType={'group'}
97
+ variant={'pure'}
98
+ {...FORM_STYLE}
99
+ />
100
+ );
101
+
102
+ return (
103
+ <div className={styles.wrapper}>
104
+ <Flexbox className={styles.container} padding={4}>
105
+ <Flexbox horizontal justify={'space-between'} paddingBlock={8} paddingInline={12}>
106
+ <h1 style={{ fontSize: 18, fontWeight: 'bold', marginBottom: 4 }}>
107
+ {t('settingAgent.prompt.title')}
108
+ </h1>
109
+ {editButton}
110
+ </Flexbox>
111
+ <Flexbox
112
+ align={'center'}
113
+ className={styles.content}
114
+ flex={1}
115
+ gap={16}
116
+ horizontal
117
+ justify={'space-between'}
118
+ padding={12}
119
+ wrap={'wrap'}
120
+ >
121
+ {content}
122
+ </Flexbox>
69
123
  </Flexbox>
70
- </FormGroup>
124
+ </div>
71
125
  );
72
126
  });
73
127
 
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { VoiceList } from '@lobehub/tts';
2
4
  import { Form, ItemGroup } from '@lobehub/ui';
3
5
  import { Form as AFrom, Select, Switch } from 'antd';
@@ -107,7 +109,9 @@ const AgentTTS = memo(() => {
107
109
  },
108
110
  }}
109
111
  items={[tts]}
112
+ itemsType={'group'}
110
113
  onValuesChange={debounce(updateConfig, 100)}
114
+ variant={'pure'}
111
115
  {...FORM_STYLE}
112
116
  />
113
117
  );
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { memo } from 'react';
2
4
  import { createStoreUpdater } from 'zustand-utils';
3
5
 
@@ -1,7 +1,6 @@
1
- import { memo } from 'react';
2
-
3
- import AgentConfig from './AgentConfig';
1
+ import AgentChat from './AgentChat';
4
2
  import AgentMeta from './AgentMeta';
3
+ import AgentModal from './AgentModal';
5
4
  import AgentPlugin from './AgentPlugin';
6
5
  import AgentPrompt from './AgentPrompt';
7
6
  import AgentTTS from './AgentTTS';
@@ -10,17 +9,18 @@ import { Provider, createStore } from './store';
10
9
 
11
10
  type AgentSettingsProps = StoreUpdaterProps;
12
11
 
13
- const AgentSettings = memo<AgentSettingsProps>((props) => {
12
+ const AgentSettings = (props: AgentSettingsProps) => {
14
13
  return (
15
14
  <Provider createStore={createStore}>
16
15
  <StoreUpdater {...props} />
17
16
  <AgentPrompt />
18
17
  <AgentMeta />
19
- <AgentConfig />
18
+ <AgentChat />
19
+ <AgentModal />
20
20
  <AgentTTS />
21
21
  <AgentPlugin />
22
22
  </Provider>
23
23
  );
24
- });
24
+ };
25
25
 
26
26
  export default AgentSettings;
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { createContext } from 'zustand-utils';
2
4
  import { subscribeWithSelector } from 'zustand/middleware';
3
5
  import { shallow } from 'zustand/shallow';
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { Upload } from 'antd';
2
4
  import { createStyles } from 'antd-style';
3
5
  import NextImage from 'next/image';
@@ -1,5 +1,5 @@
1
1
  import { SpeechRecognitionOptions, useSpeechRecognition } from '@lobehub/tts/react';
2
- import { isEqual } from 'lodash';
2
+ import isEqual from 'fast-deep-equal';
3
3
  import { memo, useCallback, useState } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { SWRConfiguration } from 'swr';
@@ -1,6 +1,6 @@
1
1
  import { getRecordMineType } from '@lobehub/tts';
2
2
  import { OpenAISTTOptions, useOpenAISTT } from '@lobehub/tts/react';
3
- import { isEqual } from 'lodash';
3
+ import isEqual from 'fast-deep-equal';
4
4
  import { memo, useCallback, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { SWRConfiguration } from 'swr';
@@ -10,7 +10,7 @@ import { memo, useMemo, useState } from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import { Flexbox } from 'react-layout-kit';
12
12
 
13
- import { agentMarketSelectors, useMarketStore } from '@/store/market';
13
+ import { useMarketStore } from '@/store/market';
14
14
 
15
15
  const { Paragraph } = Typography;
16
16
 
@@ -53,7 +53,7 @@ const AgentsSuggest = memo(() => {
53
53
  const [sliceStart, setSliceStart] = useState(0);
54
54
  const useFetchAgentList = useMarketStore((s) => s.useFetchAgentList);
55
55
  const { isLoading } = useFetchAgentList();
56
- const agentList = useMarketStore((s) => agentMarketSelectors.getAgentList(s), isEqual);
56
+ const agentList = useMarketStore((s) => s.agentList, isEqual);
57
57
  const { styles } = useStyles();
58
58
 
59
59
  const loadingCards = Array.from({ length: 4 }).map((_, index) => (