Feat: Fixed the issue where the dataset configuration page kept refreshing #3221 (#7666)

### What problem does this PR solve?

Feat: Fixed the issue where the dataset configuration page kept
refreshing #3221
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-05-16 09:53:47 +08:00
committed by GitHub
parent d373c46976
commit 0e9ff8c1f7
24 changed files with 263 additions and 175 deletions

View File

@ -1,8 +1,7 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { DocumentParserType } from '@/constants/knowledge';
import { useMemo, useState } from 'react';
import { useMemo } from 'react';
import { AudioConfiguration } from './configuration/audio';
import { BookConfiguration } from './configuration/book';
import { EmailConfiguration } from './configuration/email';
@ -18,7 +17,6 @@ import { QAConfiguration } from './configuration/qa';
import { ResumeConfiguration } from './configuration/resume';
import { TableConfiguration } from './configuration/table';
import { TagConfiguration } from './configuration/tag';
import { useFetchKnowledgeConfigurationOnMount } from './hooks';
const ConfigurationComponentMap = {
[DocumentParserType.Naive]: NaiveConfiguration,
@ -44,14 +42,8 @@ function EmptyComponent() {
export function ChunkMethodForm() {
const form = useFormContext();
const { t } = useTranslation();
const [finalParserId, setFinalParserId] = useState<DocumentParserType>(
DocumentParserType.Naive,
);
const knowledgeDetails = useFetchKnowledgeConfigurationOnMount(form);
const parserId: DocumentParserType = useWatch({
const finalParserId: DocumentParserType = useWatch({
control: form.control,
name: 'parser_id',
});
@ -62,16 +54,8 @@ export function ChunkMethodForm() {
: EmptyComponent;
}, [finalParserId]);
// useEffect(() => {
// setFinalParserId(parserId);
// }, [parserId]);
// useEffect(() => {
// setFinalParserId(knowledgeDetails.parser_id as DocumentParserType);
// }, [knowledgeDetails.parser_id]);
return (
<section>
<section className="overflow-auto max-h-[76vh]">
<ConfigurationComponent></ConfigurationComponent>
</section>
);