Feat: Wrap MaxTokenNumber with DatasetConfigurationContainer. #5467 (#5491)

### What problem does this PR solve?

Feat: Wrap MaxTokenNumber with DatasetConfigurationContainer. #5467

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2025-02-28 17:52:18 +08:00 committed by GitHub
parent 2c7428e2ee
commit aa313e112a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 28 deletions

View File

@ -24,6 +24,7 @@ import { useTranslate } from '@/hooks/common-hooks';
import { IParserConfig } from '@/interfaces/database/document'; import { IParserConfig } from '@/interfaces/database/document';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document'; import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import { AutoKeywordsItem, AutoQuestionsItem } from '../auto-keywords-item'; import { AutoKeywordsItem, AutoQuestionsItem } from '../auto-keywords-item';
import { DatasetConfigurationContainer } from '../dataset-configuration-container';
import Delimiter from '../delimiter'; import Delimiter from '../delimiter';
import EntityTypesItem from '../entity-types-item'; import EntityTypesItem from '../entity-types-item';
import ExcelToHtml from '../excel-to-html'; import ExcelToHtml from '../excel-to-html';
@ -105,10 +106,6 @@ const ChunkMethodModal: React.FC<IProps> = ({
selectedTag === DocumentParserType.Naive || selectedTag === DocumentParserType.Naive ||
selectedTag === DocumentParserType.KnowledgeGraph; selectedTag === DocumentParserType.KnowledgeGraph;
const hideDivider = [showPages, showOne, showMaxTokenNumber].every(
(x) => x === false,
);
const showEntityTypes = selectedTag === DocumentParserType.KnowledgeGraph; const showEntityTypes = selectedTag === DocumentParserType.KnowledgeGraph;
const showExcelToHtml = const showExcelToHtml =
@ -151,8 +148,13 @@ const ChunkMethodModal: React.FC<IProps> = ({
/> />
</Form.Item> </Form.Item>
</Space> </Space>
{hideDivider || <Divider></Divider>} <Divider></Divider>
<Form name="dynamic_form_nest_item" autoComplete="off" form={form}> <Form
name="dynamic_form_nest_item"
autoComplete="off"
form={form}
className="space-y-4"
>
{showPages && ( {showPages && (
<> <>
<Space> <Space>
@ -257,7 +259,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
</Form.List> </Form.List>
</> </>
)} )}
{showOne && <LayoutRecognize></LayoutRecognize>}
{showPages && ( {showPages && (
<Form.Item <Form.Item
noStyle noStyle
@ -283,27 +285,36 @@ const ChunkMethodModal: React.FC<IProps> = ({
} }
</Form.Item> </Form.Item>
)} )}
{showMaxTokenNumber && ( <DatasetConfigurationContainer show={showOne || showMaxTokenNumber}>
<> {showOne && <LayoutRecognize></LayoutRecognize>}
<MaxTokenNumber {showMaxTokenNumber && (
max={ <>
selectedTag === DocumentParserType.KnowledgeGraph <MaxTokenNumber
? 8192 * 2 max={
: 2048 selectedTag === DocumentParserType.KnowledgeGraph
} ? 8192 * 2
></MaxTokenNumber> : 2048
<Delimiter></Delimiter> }
</> ></MaxTokenNumber>
)} <Delimiter></Delimiter>
{showAutoKeywords(selectedTag) && ( </>
<> )}
<AutoKeywordsItem></AutoKeywordsItem> </DatasetConfigurationContainer>
<AutoQuestionsItem></AutoQuestionsItem> <DatasetConfigurationContainer
</> show={showAutoKeywords(selectedTag) || showExcelToHtml}
)} >
{showExcelToHtml && <ExcelToHtml></ExcelToHtml>} {showAutoKeywords(selectedTag) && (
<>
<AutoKeywordsItem></AutoKeywordsItem>
<AutoQuestionsItem></AutoQuestionsItem>
</>
)}
{showExcelToHtml && <ExcelToHtml></ExcelToHtml>}
</DatasetConfigurationContainer>
{showRaptorParseConfiguration(selectedTag) && ( {showRaptorParseConfiguration(selectedTag) && (
<ParseConfiguration></ParseConfiguration> <DatasetConfigurationContainer>
<ParseConfiguration></ParseConfiguration>
</DatasetConfigurationContainer>
)} )}
{showGraphRagItems(selectedTag) && <GraphRagItems></GraphRagItems>} {showGraphRagItems(selectedTag) && <GraphRagItems></GraphRagItems>}
{showEntityTypes && <EntityTypesItem></EntityTypesItem>} {showEntityTypes && <EntityTypesItem></EntityTypesItem>}

View File

@ -3,13 +3,15 @@ import { PropsWithChildren } from 'react';
type DatasetConfigurationContainerProps = { type DatasetConfigurationContainerProps = {
className?: string; className?: string;
show?: boolean;
} & PropsWithChildren; } & PropsWithChildren;
export function DatasetConfigurationContainer({ export function DatasetConfigurationContainer({
children, children,
className, className,
show = true,
}: DatasetConfigurationContainerProps) { }: DatasetConfigurationContainerProps) {
return ( return show ? (
<div <div
className={cn( className={cn(
'border p-2 rounded-lg bg-slate-50 dark:bg-gray-600', 'border p-2 rounded-lg bg-slate-50 dark:bg-gray-600',
@ -18,5 +20,7 @@ export function DatasetConfigurationContainer({
> >
{children} {children}
</div> </div>
) : (
children
); );
} }