mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-30 23:26:36 +08:00
### What problem does this PR solve? Feat: Display the pipeline on the agent canvas #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
30 lines
793 B
TypeScript
30 lines
793 B
TypeScript
import { crossLanguageOptions } from '@/components/cross-language-form-field';
|
|
import { isEmpty } from 'lodash';
|
|
import { useEffect } from 'react';
|
|
import { useFormContext } from 'react-hook-form';
|
|
import { buildFieldNameWithPrefix } from './utils';
|
|
|
|
export function useSetInitialLanguage({
|
|
prefix,
|
|
languageShown,
|
|
}: {
|
|
prefix: string;
|
|
languageShown: boolean;
|
|
}) {
|
|
const form = useFormContext();
|
|
const lang = form.getValues(buildFieldNameWithPrefix('lang', prefix));
|
|
|
|
useEffect(() => {
|
|
if (languageShown && isEmpty(lang)) {
|
|
form.setValue(
|
|
buildFieldNameWithPrefix('lang', prefix),
|
|
crossLanguageOptions[0].value,
|
|
{
|
|
shouldValidate: true,
|
|
shouldDirty: true,
|
|
},
|
|
);
|
|
}
|
|
}, [form, lang, languageShown, prefix]);
|
|
}
|