mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-19 22:21:04 +08:00
Fix: When creating a dataset, if no chunk_method is selected, there is no indication that this is a required field. (#14039)
### What problem does this PR solve? Fix: When creating a dataset, if no `chunk_method` is selected, there is no indication that this is a required field. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from '@/components/ui/form';
|
||||
import { DocumentParserType } from '@/constants/knowledge';
|
||||
import { DocumentParserType, ParseType } from '@/constants/knowledge';
|
||||
import { useFetchKnowledgeBaseConfiguration } from '@/hooks/use-knowledge-request';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { IParserConfig } from '@/interfaces/database/document';
|
||||
@@ -102,7 +102,7 @@ export function ChunkMethodDialog({
|
||||
|
||||
const FormSchema = z
|
||||
.object({
|
||||
parseType: z.number(),
|
||||
parseType: z.nativeEnum(ParseType),
|
||||
parser_id: z
|
||||
.string()
|
||||
.min(1, {
|
||||
@@ -156,7 +156,7 @@ export function ChunkMethodDialog({
|
||||
}),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
if (data.parseType === 2 && !data.pipeline_id) {
|
||||
if (data.parseType === ParseType.Pipeline && !data.pipeline_id) {
|
||||
ctx.addIssue({
|
||||
path: ['pipeline_id'],
|
||||
message: t('common.pleaseSelect'),
|
||||
@@ -170,7 +170,7 @@ export function ChunkMethodDialog({
|
||||
defaultValues: {
|
||||
parser_id: parserId || '',
|
||||
pipeline_id: pipelineId || '',
|
||||
parseType: pipelineId ? 2 : 1,
|
||||
parseType: pipelineId ? ParseType.Pipeline : ParseType.BuiltIn,
|
||||
parser_config: defaultParserValues,
|
||||
},
|
||||
});
|
||||
@@ -248,7 +248,7 @@ export function ChunkMethodDialog({
|
||||
form.reset({
|
||||
parser_id: parserId || '',
|
||||
pipeline_id: pipelineId || '',
|
||||
parseType: pipelineId ? 2 : 1,
|
||||
parseType: pipelineId ? ParseType.Pipeline : ParseType.BuiltIn,
|
||||
parser_config: fillDefaultParserValue({
|
||||
pages: pages.length > 0 ? pages : [{ from: 1, to: 1024 }],
|
||||
...omit(parserConfig, 'pages'),
|
||||
@@ -279,10 +279,10 @@ export function ChunkMethodDialog({
|
||||
const parseType = useWatch({
|
||||
control: form.control,
|
||||
name: 'parseType',
|
||||
defaultValue: pipelineId ? 2 : 1,
|
||||
defaultValue: pipelineId ? ParseType.Pipeline : ParseType.BuiltIn,
|
||||
});
|
||||
useEffect(() => {
|
||||
if (parseType === 1) {
|
||||
if (parseType === ParseType.BuiltIn) {
|
||||
form.setValue('pipeline_id', '');
|
||||
}
|
||||
}, [parseType, form]);
|
||||
@@ -301,49 +301,36 @@ export function ChunkMethodDialog({
|
||||
>
|
||||
<div className="space-y-6">
|
||||
<ParseTypeItem />
|
||||
{parseType === 1 && <ChunkMethodItem />}
|
||||
{parseType === ParseType.BuiltIn && <ChunkMethodItem />}
|
||||
|
||||
{/* <FormField
|
||||
control={form.control}
|
||||
name="parser_id"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>{t('knowledgeDetails.chunkMethod')}</FormLabel>
|
||||
<FormControl>
|
||||
<RAGFlowSelect
|
||||
{...field}
|
||||
options={parserList}
|
||||
></RAGFlowSelect>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/> */}
|
||||
|
||||
{showPages && parseType === 1 && <DynamicPageRange />}
|
||||
|
||||
{showPages && parseType === 1 && layoutRecognize && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="parser_config.task_page_size"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel
|
||||
tooltip={t('knowledgeDetails.taskPageSizeTip')}
|
||||
>
|
||||
{t('knowledgeDetails.taskPageSize')}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} type={'number'} min={1} max={128} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{showPages && parseType === ParseType.BuiltIn && (
|
||||
<DynamicPageRange />
|
||||
)}
|
||||
|
||||
{showPages &&
|
||||
parseType === ParseType.BuiltIn &&
|
||||
layoutRecognize && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="parser_config.task_page_size"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel
|
||||
tooltip={t('knowledgeDetails.taskPageSizeTip')}
|
||||
>
|
||||
{t('knowledgeDetails.taskPageSize')}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} type={'number'} min={1} max={128} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{parseType === 1 && (
|
||||
{parseType === ParseType.BuiltIn && (
|
||||
<>
|
||||
<div className="space-y-6 border-t-0.5 border-border-button pt-6 empty:hidden">
|
||||
{showOne && (
|
||||
@@ -411,7 +398,7 @@ export function ChunkMethodDialog({
|
||||
)}
|
||||
|
||||
<div className="space-y-6 empty:hidden">
|
||||
{parseType === 2 && (
|
||||
{parseType === ParseType.Pipeline && (
|
||||
<DataFlowSelect
|
||||
isMult={false}
|
||||
// toDataPipeline={navigateToAgents}
|
||||
|
||||
@@ -86,6 +86,7 @@ export function DataFlowSelect(props: IProps) {
|
||||
<FormLabel
|
||||
// tooltip={t('dataFlowTip')}
|
||||
className="text-sm text-text-primary whitespace-wrap "
|
||||
required
|
||||
>
|
||||
{t('manualSetup')}
|
||||
</FormLabel>
|
||||
|
||||
Reference in New Issue
Block a user