mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-01 23:10:36 +08:00
### 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)
This commit is contained in:
parent
cc219ff648
commit
06b9256972
@ -594,8 +594,8 @@ The above is the content you need to summarize.`,
|
|||||||
updateDate: 'Update Date',
|
updateDate: 'Update Date',
|
||||||
role: 'Role',
|
role: 'Role',
|
||||||
invite: 'Invite',
|
invite: 'Invite',
|
||||||
agree: 'Agree',
|
agree: 'Accept',
|
||||||
refuse: 'Refuse',
|
refuse: 'Decline',
|
||||||
teamMembers: 'Team Members',
|
teamMembers: 'Team Members',
|
||||||
joinedTeams: 'Joined Teams',
|
joinedTeams: 'Joined Teams',
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,6 @@ import LLMSelect from '@/components/llm-select';
|
|||||||
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
import { useSetLlmSetting } from '../../hooks';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
import DynamicInputVariable from '../components/dynamic-input-variable';
|
||||||
import DynamicCategorize from './dynamic-categorize';
|
import DynamicCategorize from './dynamic-categorize';
|
||||||
@ -15,7 +14,6 @@ const CategorizeForm = ({ form, onValuesChange, node }: IOperatorForm) => {
|
|||||||
nodeId: node?.id,
|
nodeId: node?.id,
|
||||||
onValuesChange,
|
onValuesChange,
|
||||||
});
|
});
|
||||||
useSetLlmSetting(form);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
|
@ -2,15 +2,12 @@ import LLMSelect from '@/components/llm-select';
|
|||||||
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
import MessageHistoryWindowSizeItem from '@/components/message-history-window-size-item';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { Form, Input, Switch } from 'antd';
|
import { Form, Input, Switch } from 'antd';
|
||||||
import { useSetLlmSetting } from '../../hooks';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
import DynamicParameters from './dynamic-parameters';
|
import DynamicParameters from './dynamic-parameters';
|
||||||
|
|
||||||
const GenerateForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const GenerateForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
const { t } = useTranslate('flow');
|
||||||
|
|
||||||
useSetLlmSetting(form);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
name="basic"
|
name="basic"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Editor from '@monaco-editor/react';
|
import Editor from '@monaco-editor/react';
|
||||||
import { Form, Input, InputNumber, Select, Space, Switch } from 'antd';
|
import { Form, Input, InputNumber, Select, Space, Switch } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSetLlmSetting } from '../../hooks';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
import DynamicVariablesForm from './dynamic-variables';
|
import DynamicVariablesForm from './dynamic-variables';
|
||||||
|
|
||||||
@ -33,8 +32,6 @@ const TimeoutInput = ({ value, onChange }: TimeoutInputProps) => {
|
|||||||
const InvokeForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const InvokeForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useSetLlmSetting(form);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form
|
<Form
|
||||||
|
@ -2,15 +2,12 @@ import LLMSelect from '@/components/llm-select';
|
|||||||
import TopNItem from '@/components/top-n-item';
|
import TopNItem from '@/components/top-n-item';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
import { useSetLlmSetting } from '../../hooks';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
import DynamicInputVariable from '../components/dynamic-input-variable';
|
||||||
|
|
||||||
const KeywordExtractForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const KeywordExtractForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
const { t } = useTranslate('flow');
|
||||||
|
|
||||||
useSetLlmSetting(form);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
name="basic"
|
name="basic"
|
||||||
|
@ -3,13 +3,11 @@ import { useTranslate } from '@/hooks/common-hooks';
|
|||||||
import { Form, Select } from 'antd';
|
import { Form, Select } from 'antd';
|
||||||
import { Operator } from '../../constant';
|
import { Operator } from '../../constant';
|
||||||
import { useBuildFormSelectOptions } from '../../form-hooks';
|
import { useBuildFormSelectOptions } from '../../form-hooks';
|
||||||
import { useSetLlmSetting } from '../../hooks';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
import { useWatchConnectionChanges } from './hooks';
|
import { useWatchConnectionChanges } from './hooks';
|
||||||
|
|
||||||
const RelevantForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const RelevantForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
const { t } = useTranslate('flow');
|
||||||
useSetLlmSetting(form);
|
|
||||||
const buildRelevantOptions = useBuildFormSelectOptions(
|
const buildRelevantOptions = useBuildFormSelectOptions(
|
||||||
Operator.Relevant,
|
Operator.Relevant,
|
||||||
node?.id,
|
node?.id,
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import LLMSelect from '@/components/llm-select';
|
import LLMSelect from '@/components/llm-select';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { Form, InputNumber } from 'antd';
|
import { Form, InputNumber } from 'antd';
|
||||||
import { useSetLlmSetting } from '../../hooks';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
|
|
||||||
const RewriteQuestionForm = ({ onValuesChange, form }: IOperatorForm) => {
|
const RewriteQuestionForm = ({ onValuesChange, form }: IOperatorForm) => {
|
||||||
const { t } = useTranslate('chat');
|
const { t } = useTranslate('chat');
|
||||||
useSetLlmSetting(form);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
|
@ -23,7 +23,7 @@ import { FormInstance, message } from 'antd';
|
|||||||
import { DefaultOptionType } from 'antd/es/select';
|
import { DefaultOptionType } from 'antd/es/select';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { humanId } from 'human-id';
|
import { humanId } from 'human-id';
|
||||||
import { get, lowerFirst } from 'lodash';
|
import { get, isEmpty, lowerFirst, pick } from 'lodash';
|
||||||
import trim from 'lodash/trim';
|
import trim from 'lodash/trim';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useParams } from 'umi';
|
import { useParams } from 'umi';
|
||||||
@ -349,15 +349,19 @@ export const useFlowIsFetching = () => {
|
|||||||
return useIsFetching({ queryKey: ['flowDetail'] }) > 0;
|
return useIsFetching({ queryKey: ['flowDetail'] }) > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetLlmSetting = (form?: FormInstance) => {
|
export const useSetLlmSetting = (
|
||||||
const initialLlmSetting = undefined;
|
form?: FormInstance,
|
||||||
|
formData?: Record<string, any>,
|
||||||
|
) => {
|
||||||
|
const initialLlmSetting = pick(
|
||||||
|
formData,
|
||||||
|
Object.values(variableEnabledFieldMap),
|
||||||
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
||||||
Record<string, boolean>
|
Record<string, boolean>
|
||||||
>((pre, field) => {
|
>((pre, field) => {
|
||||||
pre[field] =
|
pre[field] = isEmpty(initialLlmSetting)
|
||||||
initialLlmSetting === undefined
|
|
||||||
? true
|
? true
|
||||||
: !!initialLlmSetting[
|
: !!initialLlmSetting[
|
||||||
variableEnabledFieldMap[
|
variableEnabledFieldMap[
|
||||||
@ -366,7 +370,10 @@ export const useSetLlmSetting = (form?: FormInstance) => {
|
|||||||
];
|
];
|
||||||
return pre;
|
return pre;
|
||||||
}, {});
|
}, {});
|
||||||
const otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
let otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
||||||
|
if (!isEmpty(initialLlmSetting)) {
|
||||||
|
otherValues = initialLlmSetting;
|
||||||
|
}
|
||||||
form?.setFieldsValue({
|
form?.setFieldsValue({
|
||||||
...switchBoxValues,
|
...switchBoxValues,
|
||||||
...otherValues,
|
...otherValues,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user