mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +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:
@ -23,7 +23,7 @@ import { FormInstance, message } from 'antd';
|
||||
import { DefaultOptionType } from 'antd/es/select';
|
||||
import dayjs from 'dayjs';
|
||||
import { humanId } from 'human-id';
|
||||
import { get, lowerFirst } from 'lodash';
|
||||
import { get, isEmpty, lowerFirst, pick } from 'lodash';
|
||||
import trim from 'lodash/trim';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useParams } from 'umi';
|
||||
@ -349,24 +349,31 @@ export const useFlowIsFetching = () => {
|
||||
return useIsFetching({ queryKey: ['flowDetail'] }) > 0;
|
||||
};
|
||||
|
||||
export const useSetLlmSetting = (form?: FormInstance) => {
|
||||
const initialLlmSetting = undefined;
|
||||
|
||||
export const useSetLlmSetting = (
|
||||
form?: FormInstance,
|
||||
formData?: Record<string, any>,
|
||||
) => {
|
||||
const initialLlmSetting = pick(
|
||||
formData,
|
||||
Object.values(variableEnabledFieldMap),
|
||||
);
|
||||
useEffect(() => {
|
||||
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
||||
Record<string, boolean>
|
||||
>((pre, field) => {
|
||||
pre[field] =
|
||||
initialLlmSetting === undefined
|
||||
? true
|
||||
: !!initialLlmSetting[
|
||||
variableEnabledFieldMap[
|
||||
field as keyof typeof variableEnabledFieldMap
|
||||
] as keyof Variable
|
||||
];
|
||||
pre[field] = isEmpty(initialLlmSetting)
|
||||
? true
|
||||
: !!initialLlmSetting[
|
||||
variableEnabledFieldMap[
|
||||
field as keyof typeof variableEnabledFieldMap
|
||||
] as keyof Variable
|
||||
];
|
||||
return pre;
|
||||
}, {});
|
||||
const otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
||||
let otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
||||
if (!isEmpty(initialLlmSetting)) {
|
||||
otherValues = initialLlmSetting;
|
||||
}
|
||||
form?.setFieldsValue({
|
||||
...switchBoxValues,
|
||||
...otherValues,
|
||||
|
||||
Reference in New Issue
Block a user