@lobehub/chat 1.2.1 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.2.2](https://github.com/lobehub/lobe-chat/compare/v1.2.1...v1.2.2)
6
+
7
+ <sup>Released on **2024-07-01**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Display issue when select default model in System Agent.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Display issue when select default model in System Agent, closes [#3095](https://github.com/lobehub/lobe-chat/issues/3095) ([49f7f33](https://github.com/lobehub/lobe-chat/commit/49f7f33))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 1.2.1](https://github.com/lobehub/lobe-chat/compare/v1.2.0...v1.2.1)
6
31
 
7
32
  <sup>Released on **2024-07-01**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -10,19 +10,20 @@ import { FORM_STYLE } from '@/const/layoutTokens';
10
10
  import ModelSelect from '@/features/ModelSelect';
11
11
  import { useUserStore } from '@/store/user';
12
12
  import { settingsSelectors } from '@/store/user/selectors';
13
+ import { type UserSystemAgentConfigKey } from '@/types/user/settings';
13
14
 
14
15
  import { useSyncSystemAgent } from './useSync';
15
16
 
16
17
  type SettingItemGroup = ItemGroup;
17
18
 
18
- const systemAgentKey = 'agentMeta';
19
- const AgentMeta = memo(() => {
19
+ const SystemAgentForm = memo(({ systemAgentKey }: { systemAgentKey: UserSystemAgentConfigKey }) => {
20
20
  const { t } = useTranslation('setting');
21
- const [form] = AntForm.useForm();
22
21
 
23
22
  const settings = useUserStore(settingsSelectors.currentSystemAgent, isEqual);
24
23
  const [updateSystemAgent] = useUserStore((s) => [s.updateSystemAgent]);
25
24
 
25
+ const [form] = AntForm.useForm();
26
+
26
27
  const systemAgentSettings: SettingItemGroup = {
27
28
  children: [
28
29
  {
@@ -42,7 +43,7 @@ const AgentMeta = memo(() => {
42
43
  title: t(`systemAgent.${systemAgentKey}.title`),
43
44
  };
44
45
 
45
- useSyncSystemAgent(form);
46
+ useSyncSystemAgent(form, settings);
46
47
 
47
48
  return (
48
49
  <Form
@@ -55,4 +56,4 @@ const AgentMeta = memo(() => {
55
56
  );
56
57
  });
57
58
 
58
- export default AgentMeta;
59
+ export default SystemAgentForm;
@@ -3,21 +3,21 @@ import { useLayoutEffect } from 'react';
3
3
 
4
4
  import { useUserStore } from '@/store/user';
5
5
 
6
- export const useSyncSystemAgent = (form: FormInstance) => {
6
+ export const useSyncSystemAgent = (form: FormInstance, settings: any) => {
7
7
  useLayoutEffect(() => {
8
- // set the first time
9
- form.setFieldsValue(useUserStore.getState().settings.systemAgent);
8
+ // Set initial form values
9
+ form.setFieldsValue(settings);
10
10
 
11
- // sync with later updated settings
11
+ // Sync form values with updated settings
12
12
  const unsubscribe = useUserStore.subscribe(
13
13
  (s) => s.settings.systemAgent,
14
- (settings) => {
15
- form.setFieldsValue(settings);
14
+ (newSettings) => {
15
+ form.setFieldsValue(newSettings);
16
16
  },
17
17
  );
18
18
 
19
19
  return () => {
20
20
  unsubscribe();
21
21
  };
22
- }, []);
22
+ }, [form, settings]);
23
23
  };
@@ -1,13 +1,11 @@
1
- import AgentMeta from './features/AgentMeta';
2
- import Topic from './features/Topic';
3
- import Translation from './features/Translation';
1
+ import SystemAgentForm from './features/createForm';
4
2
 
5
3
  const Page = () => {
6
4
  return (
7
5
  <>
8
- <Topic />
9
- <Translation />
10
- <AgentMeta />
6
+ <SystemAgentForm systemAgentKey="topic" />
7
+ <SystemAgentForm systemAgentKey="translation" />
8
+ <SystemAgentForm systemAgentKey="agentMeta" />
11
9
  </>
12
10
  );
13
11
  };
@@ -1,57 +0,0 @@
1
- 'use client';
2
-
3
- import { Form, type ItemGroup } from '@lobehub/ui';
4
- import { Form as AntForm } from 'antd';
5
- import isEqual from 'fast-deep-equal';
6
- import { memo } from 'react';
7
- import { useTranslation } from 'react-i18next';
8
-
9
- import { FORM_STYLE } from '@/const/layoutTokens';
10
- import ModelSelect from '@/features/ModelSelect';
11
- import { useUserStore } from '@/store/user';
12
- import { settingsSelectors } from '@/store/user/selectors';
13
-
14
- import { useSyncSystemAgent } from './useSync';
15
-
16
- type SettingItemGroup = ItemGroup;
17
-
18
- const Topic = memo(() => {
19
- const { t } = useTranslation('setting');
20
- const [form] = AntForm.useForm();
21
-
22
- const settings = useUserStore(settingsSelectors.currentSystemAgent, isEqual);
23
- const [updateSystemAgent] = useUserStore((s) => [s.updateSystemAgent]);
24
-
25
- const systemAgentSettings: SettingItemGroup = {
26
- children: [
27
- {
28
- children: (
29
- <ModelSelect
30
- onChange={(props) => {
31
- updateSystemAgent('topic', props);
32
- }}
33
- showAbility={false}
34
- />
35
- ),
36
- desc: t('systemAgent.topic.modelDesc'),
37
- label: t('systemAgent.topic.label'),
38
- name: ['topic', 'model'],
39
- },
40
- ],
41
- title: t('systemAgent.topic.title'),
42
- };
43
-
44
- useSyncSystemAgent(form);
45
-
46
- return (
47
- <Form
48
- form={form}
49
- initialValues={settings}
50
- items={[systemAgentSettings]}
51
- variant={'pure'}
52
- {...FORM_STYLE}
53
- />
54
- );
55
- });
56
-
57
- export default Topic;
@@ -1,57 +0,0 @@
1
- 'use client';
2
-
3
- import { Form, type ItemGroup } from '@lobehub/ui';
4
- import { Form as AntForm } from 'antd';
5
- import isEqual from 'fast-deep-equal';
6
- import { memo } from 'react';
7
- import { useTranslation } from 'react-i18next';
8
-
9
- import { FORM_STYLE } from '@/const/layoutTokens';
10
- import ModelSelect from '@/features/ModelSelect';
11
- import { useUserStore } from '@/store/user';
12
- import { settingsSelectors } from '@/store/user/selectors';
13
-
14
- import { useSyncSystemAgent } from './useSync';
15
-
16
- type SettingItemGroup = ItemGroup;
17
-
18
- const Translation = memo(() => {
19
- const { t } = useTranslation('setting');
20
- const [form] = AntForm.useForm();
21
-
22
- const settings = useUserStore(settingsSelectors.currentSystemAgent, isEqual);
23
- const [updateSystemAgent] = useUserStore((s) => [s.updateSystemAgent]);
24
-
25
- const systemAgentSettings: SettingItemGroup = {
26
- children: [
27
- {
28
- children: (
29
- <ModelSelect
30
- onChange={(props) => {
31
- updateSystemAgent('translation', props);
32
- }}
33
- showAbility={false}
34
- />
35
- ),
36
- desc: t('systemAgent.translation.modelDesc'),
37
- label: t('systemAgent.translation.label'),
38
- name: ['translation', 'model'],
39
- },
40
- ],
41
- title: t('systemAgent.translation.title'),
42
- };
43
-
44
- useSyncSystemAgent(form);
45
-
46
- return (
47
- <Form
48
- form={form}
49
- initialValues={settings}
50
- items={[systemAgentSettings]}
51
- variant={'pure'}
52
- {...FORM_STYLE}
53
- />
54
- );
55
- });
56
-
57
- export default Translation;