balibabu
commited on
Commit
·
834690f
1
Parent(s):
4db2410
Feat: remove useSetLlmSetting from GenerateForm #3591 (#3592)
Browse files### What problem does this PR solve?
Feat: remove useSetLlmSetting from GenerateForm #3591
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- web/src/locales/en.ts +2 -2
- web/src/pages/flow/form/categorize-form/index.tsx +0 -2
- web/src/pages/flow/form/generate-form/index.tsx +0 -3
- web/src/pages/flow/form/invoke-form/index.tsx +0 -3
- web/src/pages/flow/form/keyword-extract-form/index.tsx +0 -3
- web/src/pages/flow/form/relevant-form/index.tsx +0 -2
- web/src/pages/flow/form/rewrite-question-form/index.tsx +0 -2
- web/src/pages/flow/hooks.tsx +20 -13
web/src/locales/en.ts
CHANGED
@@ -594,8 +594,8 @@ The above is the content you need to summarize.`,
|
|
594 |
updateDate: 'Update Date',
|
595 |
role: 'Role',
|
596 |
invite: 'Invite',
|
597 |
-
agree: '
|
598 |
-
refuse: '
|
599 |
teamMembers: 'Team Members',
|
600 |
joinedTeams: 'Joined Teams',
|
601 |
},
|
|
|
594 |
updateDate: 'Update Date',
|
595 |
role: 'Role',
|
596 |
invite: 'Invite',
|
597 |
+
agree: 'Accept',
|
598 |
+
refuse: 'Decline',
|
599 |
teamMembers: 'Team Members',
|
600 |
joinedTeams: 'Joined Teams',
|
601 |
},
|
web/src/pages/flow/form/categorize-form/index.tsx
CHANGED
@@ -2,7 +2,6 @@ import LLMSelect from '@/components/llm-select';
|
|
2 |
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
3 |
import { useTranslate } from '@/hooks/common-hooks';
|
4 |
import { Form } from 'antd';
|
5 |
-
import { useSetLlmSetting } from '../../hooks';
|
6 |
import { IOperatorForm } from '../../interface';
|
7 |
import DynamicInputVariable from '../components/dynamic-input-variable';
|
8 |
import DynamicCategorize from './dynamic-categorize';
|
@@ -15,7 +14,6 @@ const CategorizeForm = ({ form, onValuesChange, node }: IOperatorForm) => {
|
|
15 |
nodeId: node?.id,
|
16 |
onValuesChange,
|
17 |
});
|
18 |
-
useSetLlmSetting(form);
|
19 |
|
20 |
return (
|
21 |
<Form
|
|
|
2 |
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
3 |
import { useTranslate } from '@/hooks/common-hooks';
|
4 |
import { Form } from 'antd';
|
|
|
5 |
import { IOperatorForm } from '../../interface';
|
6 |
import DynamicInputVariable from '../components/dynamic-input-variable';
|
7 |
import DynamicCategorize from './dynamic-categorize';
|
|
|
14 |
nodeId: node?.id,
|
15 |
onValuesChange,
|
16 |
});
|
|
|
17 |
|
18 |
return (
|
19 |
<Form
|
web/src/pages/flow/form/generate-form/index.tsx
CHANGED
@@ -2,15 +2,12 @@ import LLMSelect from '@/components/llm-select';
|
|
2 |
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
3 |
import { useTranslate } from '@/hooks/common-hooks';
|
4 |
import { Form, Input, Switch } from 'antd';
|
5 |
-
import { useSetLlmSetting } from '../../hooks';
|
6 |
import { IOperatorForm } from '../../interface';
|
7 |
import DynamicParameters from './dynamic-parameters';
|
8 |
|
9 |
const GenerateForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
10 |
const { t } = useTranslate('flow');
|
11 |
|
12 |
-
useSetLlmSetting(form);
|
13 |
-
|
14 |
return (
|
15 |
<Form
|
16 |
name="basic"
|
|
|
2 |
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
3 |
import { useTranslate } from '@/hooks/common-hooks';
|
4 |
import { Form, Input, Switch } from 'antd';
|
|
|
5 |
import { IOperatorForm } from '../../interface';
|
6 |
import DynamicParameters from './dynamic-parameters';
|
7 |
|
8 |
const GenerateForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
9 |
const { t } = useTranslate('flow');
|
10 |
|
|
|
|
|
11 |
return (
|
12 |
<Form
|
13 |
name="basic"
|
web/src/pages/flow/form/invoke-form/index.tsx
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import Editor from '@monaco-editor/react';
|
2 |
import { Form, Input, InputNumber, Select, Space, Switch } from 'antd';
|
3 |
import { useTranslation } from 'react-i18next';
|
4 |
-
import { useSetLlmSetting } from '../../hooks';
|
5 |
import { IOperatorForm } from '../../interface';
|
6 |
import DynamicVariablesForm from './dynamic-variables';
|
7 |
|
@@ -33,8 +32,6 @@ const TimeoutInput = ({ value, onChange }: TimeoutInputProps) => {
|
|
33 |
const InvokeForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
34 |
const { t } = useTranslation();
|
35 |
|
36 |
-
useSetLlmSetting(form);
|
37 |
-
|
38 |
return (
|
39 |
<>
|
40 |
<Form
|
|
|
1 |
import Editor from '@monaco-editor/react';
|
2 |
import { Form, Input, InputNumber, Select, Space, Switch } from 'antd';
|
3 |
import { useTranslation } from 'react-i18next';
|
|
|
4 |
import { IOperatorForm } from '../../interface';
|
5 |
import DynamicVariablesForm from './dynamic-variables';
|
6 |
|
|
|
32 |
const InvokeForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
33 |
const { t } = useTranslation();
|
34 |
|
|
|
|
|
35 |
return (
|
36 |
<>
|
37 |
<Form
|
web/src/pages/flow/form/keyword-extract-form/index.tsx
CHANGED
@@ -2,15 +2,12 @@ import LLMSelect from '@/components/llm-select';
|
|
2 |
import TopNItem from '@/components/top-n-item';
|
3 |
import { useTranslate } from '@/hooks/common-hooks';
|
4 |
import { Form } from 'antd';
|
5 |
-
import { useSetLlmSetting } from '../../hooks';
|
6 |
import { IOperatorForm } from '../../interface';
|
7 |
import DynamicInputVariable from '../components/dynamic-input-variable';
|
8 |
|
9 |
const KeywordExtractForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
10 |
const { t } = useTranslate('flow');
|
11 |
|
12 |
-
useSetLlmSetting(form);
|
13 |
-
|
14 |
return (
|
15 |
<Form
|
16 |
name="basic"
|
|
|
2 |
import TopNItem from '@/components/top-n-item';
|
3 |
import { useTranslate } from '@/hooks/common-hooks';
|
4 |
import { Form } from 'antd';
|
|
|
5 |
import { IOperatorForm } from '../../interface';
|
6 |
import DynamicInputVariable from '../components/dynamic-input-variable';
|
7 |
|
8 |
const KeywordExtractForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
9 |
const { t } = useTranslate('flow');
|
10 |
|
|
|
|
|
11 |
return (
|
12 |
<Form
|
13 |
name="basic"
|
web/src/pages/flow/form/relevant-form/index.tsx
CHANGED
@@ -3,13 +3,11 @@ import { useTranslate } from '@/hooks/common-hooks';
|
|
3 |
import { Form, Select } from 'antd';
|
4 |
import { Operator } from '../../constant';
|
5 |
import { useBuildFormSelectOptions } from '../../form-hooks';
|
6 |
-
import { useSetLlmSetting } from '../../hooks';
|
7 |
import { IOperatorForm } from '../../interface';
|
8 |
import { useWatchConnectionChanges } from './hooks';
|
9 |
|
10 |
const RelevantForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
11 |
const { t } = useTranslate('flow');
|
12 |
-
useSetLlmSetting(form);
|
13 |
const buildRelevantOptions = useBuildFormSelectOptions(
|
14 |
Operator.Relevant,
|
15 |
node?.id,
|
|
|
3 |
import { Form, Select } from 'antd';
|
4 |
import { Operator } from '../../constant';
|
5 |
import { useBuildFormSelectOptions } from '../../form-hooks';
|
|
|
6 |
import { IOperatorForm } from '../../interface';
|
7 |
import { useWatchConnectionChanges } from './hooks';
|
8 |
|
9 |
const RelevantForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
10 |
const { t } = useTranslate('flow');
|
|
|
11 |
const buildRelevantOptions = useBuildFormSelectOptions(
|
12 |
Operator.Relevant,
|
13 |
node?.id,
|
web/src/pages/flow/form/rewrite-question-form/index.tsx
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import LLMSelect from '@/components/llm-select';
|
2 |
import { useTranslate } from '@/hooks/common-hooks';
|
3 |
import { Form, InputNumber } from 'antd';
|
4 |
-
import { useSetLlmSetting } from '../../hooks';
|
5 |
import { IOperatorForm } from '../../interface';
|
6 |
|
7 |
const RewriteQuestionForm = ({ onValuesChange, form }: IOperatorForm) => {
|
8 |
const { t } = useTranslate('chat');
|
9 |
-
useSetLlmSetting(form);
|
10 |
|
11 |
return (
|
12 |
<Form
|
|
|
1 |
import LLMSelect from '@/components/llm-select';
|
2 |
import { useTranslate } from '@/hooks/common-hooks';
|
3 |
import { Form, InputNumber } from 'antd';
|
|
|
4 |
import { IOperatorForm } from '../../interface';
|
5 |
|
6 |
const RewriteQuestionForm = ({ onValuesChange, form }: IOperatorForm) => {
|
7 |
const { t } = useTranslate('chat');
|
|
|
8 |
|
9 |
return (
|
10 |
<Form
|
web/src/pages/flow/hooks.tsx
CHANGED
@@ -23,7 +23,7 @@ import { FormInstance, message } from 'antd';
|
|
23 |
import { DefaultOptionType } from 'antd/es/select';
|
24 |
import dayjs from 'dayjs';
|
25 |
import { humanId } from 'human-id';
|
26 |
-
import { get, lowerFirst } from 'lodash';
|
27 |
import trim from 'lodash/trim';
|
28 |
import { useTranslation } from 'react-i18next';
|
29 |
import { useParams } from 'umi';
|
@@ -349,24 +349,31 @@ export const useFlowIsFetching = () => {
|
|
349 |
return useIsFetching({ queryKey: ['flowDetail'] }) > 0;
|
350 |
};
|
351 |
|
352 |
-
export const useSetLlmSetting = (
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
355 |
useEffect(() => {
|
356 |
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
357 |
Record<string, boolean>
|
358 |
>((pre, field) => {
|
359 |
-
pre[field] =
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
variableEnabledFieldMap
|
364 |
-
|
365 |
-
|
366 |
-
];
|
367 |
return pre;
|
368 |
}, {});
|
369 |
-
|
|
|
|
|
|
|
370 |
form?.setFieldsValue({
|
371 |
...switchBoxValues,
|
372 |
...otherValues,
|
|
|
23 |
import { DefaultOptionType } from 'antd/es/select';
|
24 |
import dayjs from 'dayjs';
|
25 |
import { humanId } from 'human-id';
|
26 |
+
import { get, isEmpty, lowerFirst, pick } from 'lodash';
|
27 |
import trim from 'lodash/trim';
|
28 |
import { useTranslation } from 'react-i18next';
|
29 |
import { useParams } from 'umi';
|
|
|
349 |
return useIsFetching({ queryKey: ['flowDetail'] }) > 0;
|
350 |
};
|
351 |
|
352 |
+
export const useSetLlmSetting = (
|
353 |
+
form?: FormInstance,
|
354 |
+
formData?: Record<string, any>,
|
355 |
+
) => {
|
356 |
+
const initialLlmSetting = pick(
|
357 |
+
formData,
|
358 |
+
Object.values(variableEnabledFieldMap),
|
359 |
+
);
|
360 |
useEffect(() => {
|
361 |
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
362 |
Record<string, boolean>
|
363 |
>((pre, field) => {
|
364 |
+
pre[field] = isEmpty(initialLlmSetting)
|
365 |
+
? true
|
366 |
+
: !!initialLlmSetting[
|
367 |
+
variableEnabledFieldMap[
|
368 |
+
field as keyof typeof variableEnabledFieldMap
|
369 |
+
] as keyof Variable
|
370 |
+
];
|
|
|
371 |
return pre;
|
372 |
}, {});
|
373 |
+
let otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
374 |
+
if (!isEmpty(initialLlmSetting)) {
|
375 |
+
otherValues = initialLlmSetting;
|
376 |
+
}
|
377 |
form?.setFieldsValue({
|
378 |
...switchBoxValues,
|
379 |
...otherValues,
|