mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00
feat: move layout_recognize to the bottom (#146)
* feat: add Page Ranges label * feat: move layout_recognize to the bottom
This commit is contained in:
parent
da39723f17
commit
1d9a50b090
@ -2,7 +2,11 @@ import MaxTokenNumber from '@/components/max-token-number';
|
|||||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||||
import { IKnowledgeFileParserConfig } from '@/interfaces/database/knowledge';
|
import { IKnowledgeFileParserConfig } from '@/interfaces/database/knowledge';
|
||||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
import {
|
||||||
|
MinusCircleOutlined,
|
||||||
|
PlusOutlined,
|
||||||
|
QuestionCircleOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Divider,
|
Divider,
|
||||||
@ -12,6 +16,7 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch,
|
||||||
Tag,
|
Tag,
|
||||||
|
Tooltip,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import omit from 'lodash/omit';
|
import omit from 'lodash/omit';
|
||||||
import React, { useEffect, useMemo } from 'react';
|
import React, { useEffect, useMemo } from 'react';
|
||||||
@ -31,6 +36,7 @@ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
|||||||
parserId: string;
|
parserId: string;
|
||||||
parserConfig: IKnowledgeFileParserConfig;
|
parserConfig: IKnowledgeFileParserConfig;
|
||||||
documentType: string;
|
documentType: string;
|
||||||
|
disabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
|
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
|
||||||
@ -40,6 +46,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
onOk,
|
onOk,
|
||||||
hideModal,
|
hideModal,
|
||||||
visible,
|
visible,
|
||||||
|
disabled,
|
||||||
documentType,
|
documentType,
|
||||||
parserConfig,
|
parserConfig,
|
||||||
}) => {
|
}) => {
|
||||||
@ -89,6 +96,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
onOk={handleOk}
|
onOk={handleOk}
|
||||||
onCancel={hideModal}
|
onCancel={hideModal}
|
||||||
afterClose={afterClose}
|
afterClose={afterClose}
|
||||||
|
okButtonProps={{ disabled }}
|
||||||
>
|
>
|
||||||
<Space size={[0, 8]} wrap>
|
<Space size={[0, 8]} wrap>
|
||||||
<div className={styles.tags}>
|
<div className={styles.tags}>
|
||||||
@ -97,7 +105,11 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
<CheckableTag
|
<CheckableTag
|
||||||
key={x.value}
|
key={x.value}
|
||||||
checked={selectedTag === x.value}
|
checked={selectedTag === x.value}
|
||||||
onChange={(checked) => handleChange(x.value, checked)}
|
onChange={(checked) => {
|
||||||
|
if (!disabled) {
|
||||||
|
handleChange(x.value, checked);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{x.label}
|
{x.label}
|
||||||
</CheckableTag>
|
</CheckableTag>
|
||||||
@ -108,7 +120,125 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
<Divider></Divider>
|
<Divider></Divider>
|
||||||
|
|
||||||
{
|
{
|
||||||
<Form name="dynamic_form_nest_item" autoComplete="off" form={form}>
|
<Form
|
||||||
|
name="dynamic_form_nest_item"
|
||||||
|
autoComplete="off"
|
||||||
|
form={form}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
{showPages && (
|
||||||
|
<>
|
||||||
|
<Space>
|
||||||
|
<p>Page Ranges:</p>
|
||||||
|
<Tooltip
|
||||||
|
title={
|
||||||
|
'page ranges: Define the page ranges that need to be parsed. The pages that not included in these ranges will be ignored.'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<QuestionCircleOutlined
|
||||||
|
className={styles.questionIcon}
|
||||||
|
></QuestionCircleOutlined>
|
||||||
|
</Tooltip>
|
||||||
|
</Space>
|
||||||
|
<Form.List name="pages">
|
||||||
|
{(fields, { add, remove }) => (
|
||||||
|
<>
|
||||||
|
{fields.map(({ key, name, ...restField }) => (
|
||||||
|
<Space
|
||||||
|
key={key}
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
}}
|
||||||
|
align="baseline"
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
{...restField}
|
||||||
|
name={[name, 'from']}
|
||||||
|
dependencies={name > 0 ? [name - 1, 'to'] : []}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Missing start page number',
|
||||||
|
},
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(_, value) {
|
||||||
|
if (
|
||||||
|
name === 0 ||
|
||||||
|
!value ||
|
||||||
|
getFieldValue(['pages', name - 1, 'to']) <
|
||||||
|
value
|
||||||
|
) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(
|
||||||
|
new Error(
|
||||||
|
'The current value must be greater than the previous to!',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber
|
||||||
|
placeholder="from"
|
||||||
|
min={0}
|
||||||
|
precision={0}
|
||||||
|
className={styles.pageInputNumber}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
{...restField}
|
||||||
|
name={[name, 'to']}
|
||||||
|
dependencies={[name, 'from']}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Missing end page number(excluding)',
|
||||||
|
},
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(_, value) {
|
||||||
|
if (
|
||||||
|
!value ||
|
||||||
|
getFieldValue(['pages', name, 'from']) < value
|
||||||
|
) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(
|
||||||
|
new Error(
|
||||||
|
'The current value must be greater than to!',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber
|
||||||
|
placeholder="to"
|
||||||
|
min={0}
|
||||||
|
precision={0}
|
||||||
|
className={styles.pageInputNumber}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
{name > 0 && (
|
||||||
|
<MinusCircleOutlined onClick={() => remove(name)} />
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
))}
|
||||||
|
<Form.Item>
|
||||||
|
<Button
|
||||||
|
type="dashed"
|
||||||
|
onClick={() => add()}
|
||||||
|
block
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
>
|
||||||
|
Add page
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Form.List>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{showOne && (
|
{showOne && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={['parser_config', 'layout_recognize']}
|
name={['parser_config', 'layout_recognize']}
|
||||||
@ -129,128 +259,21 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
>
|
>
|
||||||
{({ getFieldValue }) =>
|
{({ getFieldValue }) =>
|
||||||
getFieldValue(['parser_config', 'layout_recognize']) && (
|
getFieldValue(['parser_config', 'layout_recognize']) && (
|
||||||
<>
|
<Form.Item
|
||||||
<Form.List name="pages">
|
name={['parser_config', 'task_page_size']}
|
||||||
{(fields, { add, remove }) => (
|
label="Task page size"
|
||||||
<>
|
tooltip={`If using layout recognize, the PDF file will be split into groups of successive. Layout analysis will be performed parallelly between groups to increase the processing speed.
|
||||||
{fields.map(({ key, name, ...restField }) => (
|
|
||||||
<Space
|
|
||||||
key={key}
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
}}
|
|
||||||
align="baseline"
|
|
||||||
>
|
|
||||||
<Form.Item
|
|
||||||
{...restField}
|
|
||||||
name={[name, 'from']}
|
|
||||||
dependencies={name > 0 ? [name - 1, 'to'] : []}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: 'Missing start page number',
|
|
||||||
},
|
|
||||||
({ getFieldValue }) => ({
|
|
||||||
validator(_, value) {
|
|
||||||
if (
|
|
||||||
name === 0 ||
|
|
||||||
!value ||
|
|
||||||
getFieldValue([
|
|
||||||
'pages',
|
|
||||||
name - 1,
|
|
||||||
'to',
|
|
||||||
]) < value
|
|
||||||
) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
return Promise.reject(
|
|
||||||
new Error(
|
|
||||||
'The current value must be greater than the previous to!',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber
|
|
||||||
placeholder="from"
|
|
||||||
min={0}
|
|
||||||
precision={0}
|
|
||||||
className={styles.pageInputNumber}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
{...restField}
|
|
||||||
name={[name, 'to']}
|
|
||||||
dependencies={[name, 'from']}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message:
|
|
||||||
'Missing end page number(excluding)',
|
|
||||||
},
|
|
||||||
({ getFieldValue }) => ({
|
|
||||||
validator(_, value) {
|
|
||||||
if (
|
|
||||||
!value ||
|
|
||||||
getFieldValue(['pages', name, 'from']) <
|
|
||||||
value
|
|
||||||
) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
return Promise.reject(
|
|
||||||
new Error(
|
|
||||||
'The current value must be greater than to!',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber
|
|
||||||
placeholder="to"
|
|
||||||
min={0}
|
|
||||||
precision={0}
|
|
||||||
className={styles.pageInputNumber}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
{name > 0 && (
|
|
||||||
<MinusCircleOutlined
|
|
||||||
onClick={() => remove(name)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Space>
|
|
||||||
))}
|
|
||||||
<Form.Item>
|
|
||||||
<Button
|
|
||||||
type="dashed"
|
|
||||||
onClick={() => add()}
|
|
||||||
block
|
|
||||||
icon={<PlusOutlined />}
|
|
||||||
>
|
|
||||||
Add page
|
|
||||||
</Button>
|
|
||||||
</Form.Item>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Form.List>
|
|
||||||
|
|
||||||
<Form.Item
|
|
||||||
name={['parser_config', 'task_page_size']}
|
|
||||||
label="Task page size"
|
|
||||||
tooltip={`If using layout recognize, the PDF file will be split into groups of successive. Layout analysis will be performed parallelly between groups to increase the processing speed.
|
|
||||||
The 'Task page size' determines the size of groups. The larger the page size is, the lower the chance of splitting continuous text between pages into different chunks.`}
|
The 'Task page size' determines the size of groups. The larger the page size is, the lower the chance of splitting continuous text between pages into different chunks.`}
|
||||||
initialValue={2}
|
initialValue={12}
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: 'Please input your task page size!',
|
message: 'Please input your task page size!',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<InputNumber min={1} max={128} />
|
<InputNumber min={1} max={128} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -38,3 +38,10 @@
|
|||||||
.pageInputNumber {
|
.pageInputNumber {
|
||||||
width: 220px;
|
width: 220px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.questionIcon {
|
||||||
|
margin-inline-start: 4px;
|
||||||
|
color: rgba(0, 0, 0, 0.45);
|
||||||
|
cursor: help;
|
||||||
|
writing-mode: horizontal-tb;
|
||||||
|
}
|
||||||
|
@ -231,6 +231,7 @@ const KnowledgeFile = () => {
|
|||||||
onOk={onChangeParserOk}
|
onOk={onChangeParserOk}
|
||||||
visible={changeParserVisible}
|
visible={changeParserVisible}
|
||||||
hideModal={hideChangeParserModal}
|
hideModal={hideChangeParserModal}
|
||||||
|
disabled={currentRecord.chunk_num > 0}
|
||||||
loading={changeParserLoading}
|
loading={changeParserLoading}
|
||||||
/>
|
/>
|
||||||
<RenameModal
|
<RenameModal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user