mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-26 08:04:24 +08:00
feat: when Layout recognize is false, hide pages (#144)
* feat: when Layout recognize is false, hide pages * feat: fix the name column to the leftmost part of the KnowledgeFile table
This commit is contained in:
parent
f6aee7f230
commit
da39723f17
@ -1,4 +1,8 @@
|
||||
import MaxTokenNumber from '@/components/max-token-number';
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { IKnowledgeFileParserConfig } from '@/interfaces/database/knowledge';
|
||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
@ -9,14 +13,8 @@ import {
|
||||
Switch,
|
||||
Tag,
|
||||
} from 'antd';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
|
||||
import MaxTokenNumber from '@/components/max-token-number';
|
||||
import { IKnowledgeFileParserConfig } from '@/interfaces/database/knowledge';
|
||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import omit from 'lodash/omit';
|
||||
import {} from 'module';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { useFetchParserListOnMount } from './hooks';
|
||||
|
||||
import styles from './index.less';
|
||||
@ -51,12 +49,10 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
|
||||
const handleOk = async () => {
|
||||
const values = await form.validateFields();
|
||||
console.info(values);
|
||||
const parser_config = {
|
||||
...values.parser_config,
|
||||
pages: values.pages?.map((x: any) => [x.from, x.to]) ?? [],
|
||||
};
|
||||
console.info(parser_config);
|
||||
onOk(selectedTag, parser_config);
|
||||
};
|
||||
|
||||
@ -110,9 +106,29 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
</div>
|
||||
</Space>
|
||||
<Divider></Divider>
|
||||
|
||||
{
|
||||
<Form name="dynamic_form_nest_item" autoComplete="off" form={form}>
|
||||
{showOne && (
|
||||
<Form.Item
|
||||
name={['parser_config', 'layout_recognize']}
|
||||
label="Layout recognize"
|
||||
initialValue={true}
|
||||
valuePropName="checked"
|
||||
tooltip={
|
||||
'Use visual models for layout analysis to better identify document structure, find where the titles, text blocks, images, and tables are. Without this feature, only the plain text of the PDF can be obtained.'
|
||||
}
|
||||
>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
)}
|
||||
{showPages && (
|
||||
<Form.Item
|
||||
noStyle
|
||||
dependencies={[['parser_config', 'layout_recognize']]}
|
||||
>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue(['parser_config', 'layout_recognize']) && (
|
||||
<>
|
||||
<Form.List name="pages">
|
||||
{(fields, { add, remove }) => (
|
||||
@ -139,8 +155,11 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
if (
|
||||
name === 0 ||
|
||||
!value ||
|
||||
getFieldValue(['pages', name - 1, 'to']) <
|
||||
value
|
||||
getFieldValue([
|
||||
'pages',
|
||||
name - 1,
|
||||
'to',
|
||||
]) < value
|
||||
) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -167,13 +186,15 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Missing end page number(excluding)',
|
||||
message:
|
||||
'Missing end page number(excluding)',
|
||||
},
|
||||
({ getFieldValue }) => ({
|
||||
validator(_, value) {
|
||||
if (
|
||||
!value ||
|
||||
getFieldValue(['pages', name, 'from']) < value
|
||||
getFieldValue(['pages', name, 'from']) <
|
||||
value
|
||||
) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -194,7 +215,9 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
/>
|
||||
</Form.Item>
|
||||
{name > 0 && (
|
||||
<MinusCircleOutlined onClick={() => remove(name)} />
|
||||
<MinusCircleOutlined
|
||||
onClick={() => remove(name)}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
))}
|
||||
@ -211,10 +234,12 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
|
||||
<Form.Item
|
||||
name={['parser_config', 'task_page_size']}
|
||||
label="Task page size"
|
||||
tooltip={'coming soon'}
|
||||
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.`}
|
||||
initialValue={2}
|
||||
rules={[
|
||||
{
|
||||
@ -226,18 +251,11 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
||||
<InputNumber min={1} max={128} />
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
{showOne && (
|
||||
<Form.Item
|
||||
name={['parser_config', 'layout_recognize']}
|
||||
label="Layout recognize"
|
||||
initialValue={true}
|
||||
valuePropName="checked"
|
||||
tooltip={'coming soon'}
|
||||
>
|
||||
<Switch />
|
||||
)
|
||||
}
|
||||
</Form.Item>
|
||||
)}
|
||||
|
||||
{selectedTag === 'naive' && <MaxTokenNumber></MaxTokenNumber>}
|
||||
</Form>
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ const KnowledgeFile = () => {
|
||||
title: 'Name',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
fixed: 'left',
|
||||
render: (text: any, { id, thumbnail }) => (
|
||||
<div className={styles.tochunks} onClick={() => toChunk(id)}>
|
||||
<img className={styles.img} src={thumbnail} alt="" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user