mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Solved the problem that BeginForm would get stuck when modifying data #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
32 lines
743 B
TypeScript
32 lines
743 B
TypeScript
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
|
import { isEmpty } from 'lodash';
|
|
import { useMemo } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { AgentDialogueMode } from '../../constant';
|
|
|
|
export function useValues(node?: RAGFlowNodeType) {
|
|
const { t } = useTranslation();
|
|
|
|
const defaultValues = useMemo(
|
|
() => ({
|
|
enablePrologue: true,
|
|
prologue: t('chat.setAnOpenerInitial'),
|
|
mode: AgentDialogueMode.Conversational,
|
|
inputs: [],
|
|
}),
|
|
[t],
|
|
);
|
|
|
|
const values = useMemo(() => {
|
|
const formData = node?.data?.form;
|
|
|
|
if (isEmpty(formData)) {
|
|
return defaultValues;
|
|
}
|
|
|
|
return formData;
|
|
}, [defaultValues, node?.data?.form]);
|
|
|
|
return values;
|
|
}
|