mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-01 08:06:15 +08:00
### What problem does this PR solve? feat: Add EntityTypesForm #162 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
4ba1ba973a
commit
3a739e3dd7
@ -22,6 +22,7 @@ import React, { useEffect, useMemo } from 'react';
|
|||||||
import { useFetchParserListOnMount } from './hooks';
|
import { useFetchParserListOnMount } from './hooks';
|
||||||
|
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
|
import EntityTypesForm from '../entity-types-form';
|
||||||
import LayoutRecognize from '../layout-recognize';
|
import LayoutRecognize from '../layout-recognize';
|
||||||
import ParseConfiguration, {
|
import ParseConfiguration, {
|
||||||
showRaptorParseConfiguration,
|
showRaptorParseConfiguration,
|
||||||
@ -41,7 +42,14 @@ interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
|||||||
documentId: string;
|
documentId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hidePagesChunkMethods = ['qa', 'table', 'picture', 'resume', 'one'];
|
const hidePagesChunkMethods = [
|
||||||
|
'qa',
|
||||||
|
'table',
|
||||||
|
'picture',
|
||||||
|
'resume',
|
||||||
|
'one',
|
||||||
|
'knowledge_graph',
|
||||||
|
];
|
||||||
|
|
||||||
const ChunkMethodModal: React.FC<IProps> = ({
|
const ChunkMethodModal: React.FC<IProps> = ({
|
||||||
documentId,
|
documentId,
|
||||||
@ -80,7 +88,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
return (
|
return (
|
||||||
isPdf &&
|
isPdf &&
|
||||||
hidePagesChunkMethods
|
hidePagesChunkMethods
|
||||||
.filter((x) => x !== 'one')
|
.filter((x) => x !== 'one' && x !== 'knowledge_graph')
|
||||||
.every((x) => x !== selectedTag)
|
.every((x) => x !== selectedTag)
|
||||||
);
|
);
|
||||||
}, [selectedTag, isPdf]);
|
}, [selectedTag, isPdf]);
|
||||||
@ -91,6 +99,8 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
(x) => x === false,
|
(x) => x === false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const showEntityTypes = selectedTag === 'knowledge_graph';
|
||||||
|
|
||||||
const afterClose = () => {
|
const afterClose = () => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
};
|
};
|
||||||
@ -262,6 +272,7 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|||||||
{showRaptorParseConfiguration(selectedTag) && (
|
{showRaptorParseConfiguration(selectedTag) && (
|
||||||
<ParseConfiguration></ParseConfiguration>
|
<ParseConfiguration></ParseConfiguration>
|
||||||
)}
|
)}
|
||||||
|
{showEntityTypes && <EntityTypesForm></EntityTypesForm>}
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -7,8 +7,8 @@ import React, { useEffect, useRef, useState } from 'react';
|
|||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
interface EditTagsProps {
|
interface EditTagsProps {
|
||||||
tags: string[];
|
tags?: string[];
|
||||||
setTags: (tags: string[]) => void;
|
setTags?: (tags: string[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
||||||
@ -24,9 +24,8 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
|||||||
}, [inputVisible]);
|
}, [inputVisible]);
|
||||||
|
|
||||||
const handleClose = (removedTag: string) => {
|
const handleClose = (removedTag: string) => {
|
||||||
const newTags = tags.filter((tag) => tag !== removedTag);
|
const newTags = tags?.filter((tag) => tag !== removedTag);
|
||||||
console.log(newTags);
|
setTags?.(newTags ?? []);
|
||||||
setTags(newTags);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showInput = () => {
|
const showInput = () => {
|
||||||
@ -38,8 +37,8 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleInputConfirm = () => {
|
const handleInputConfirm = () => {
|
||||||
if (inputValue && tags.indexOf(inputValue) === -1) {
|
if (inputValue && tags?.indexOf(inputValue) === -1) {
|
||||||
setTags([...tags, inputValue]);
|
setTags?.([...tags, inputValue]);
|
||||||
}
|
}
|
||||||
setInputVisible(false);
|
setInputVisible(false);
|
||||||
setInputValue('');
|
setInputValue('');
|
||||||
@ -64,7 +63,7 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const tagChild = tags.map(forMap);
|
const tagChild = tags?.map(forMap);
|
||||||
|
|
||||||
const tagPlusStyle: React.CSSProperties = {
|
const tagPlusStyle: React.CSSProperties = {
|
||||||
background: token.colorBgContainer,
|
background: token.colorBgContainer,
|
29
web/src/components/entity-types-form.tsx
Normal file
29
web/src/components/entity-types-form.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
|
import { Form } from 'antd';
|
||||||
|
import EditTag from './edit-tag';
|
||||||
|
|
||||||
|
const initialEntityTypes = [
|
||||||
|
'organization',
|
||||||
|
'person',
|
||||||
|
'location',
|
||||||
|
'event',
|
||||||
|
'time',
|
||||||
|
];
|
||||||
|
|
||||||
|
const EntityTypesForm = () => {
|
||||||
|
const { t } = useTranslate('knowledgeConfiguration');
|
||||||
|
return (
|
||||||
|
<Form.Item
|
||||||
|
name={['parser_config', 'entity_types']}
|
||||||
|
label={t('entityTypes')}
|
||||||
|
rules={[{ required: true }]}
|
||||||
|
initialValue={initialEntityTypes}
|
||||||
|
valuePropName="tags"
|
||||||
|
trigger="setTags"
|
||||||
|
>
|
||||||
|
<EditTag></EditTag>
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EntityTypesForm;
|
@ -12,7 +12,13 @@ import {
|
|||||||
} from 'antd';
|
} from 'antd';
|
||||||
import random from 'lodash/random';
|
import random from 'lodash/random';
|
||||||
|
|
||||||
export const excludedParseMethods = ['table', 'resume', 'one', 'picture'];
|
export const excludedParseMethods = [
|
||||||
|
'table',
|
||||||
|
'resume',
|
||||||
|
'one',
|
||||||
|
'picture',
|
||||||
|
'knowledge_graph',
|
||||||
|
];
|
||||||
|
|
||||||
export const showRaptorParseConfiguration = (parserId: string) => {
|
export const showRaptorParseConfiguration = (parserId: string) => {
|
||||||
return !excludedParseMethods.includes(parserId);
|
return !excludedParseMethods.includes(parserId);
|
||||||
|
@ -289,6 +289,7 @@ The above is the content you need to summarize.`,
|
|||||||
maxClusterMessage: 'Max cluster is required',
|
maxClusterMessage: 'Max cluster is required',
|
||||||
randomSeed: 'Random seed',
|
randomSeed: 'Random seed',
|
||||||
randomSeedMessage: 'Random seed is required',
|
randomSeedMessage: 'Random seed is required',
|
||||||
|
entityTypes: 'Entity types',
|
||||||
},
|
},
|
||||||
chunk: {
|
chunk: {
|
||||||
chunk: 'Chunk',
|
chunk: 'Chunk',
|
||||||
|
@ -261,6 +261,7 @@ export default {
|
|||||||
maxTokenTip: '用於匯總的最大token數。',
|
maxTokenTip: '用於匯總的最大token數。',
|
||||||
thresholdTip: '閾值越大,聚類越少。',
|
thresholdTip: '閾值越大,聚類越少。',
|
||||||
maxClusterTip: '最大聚類數。',
|
maxClusterTip: '最大聚類數。',
|
||||||
|
entityTypes: '實體類型',
|
||||||
},
|
},
|
||||||
chunk: {
|
chunk: {
|
||||||
chunk: '解析塊',
|
chunk: '解析塊',
|
||||||
|
@ -278,6 +278,7 @@ export default {
|
|||||||
maxTokenTip: '用于汇总的最大token数。',
|
maxTokenTip: '用于汇总的最大token数。',
|
||||||
thresholdTip: '阈值越大,聚类越少。',
|
thresholdTip: '阈值越大,聚类越少。',
|
||||||
maxClusterTip: '最大聚类数。',
|
maxClusterTip: '最大聚类数。',
|
||||||
|
entityTypes: '实体类型',
|
||||||
},
|
},
|
||||||
chunk: {
|
chunk: {
|
||||||
chunk: '解析块',
|
chunk: '解析块',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import EditTag from '@/components/edit-tag';
|
||||||
import { useFetchChunk } from '@/hooks/chunk-hooks';
|
import { useFetchChunk } from '@/hooks/chunk-hooks';
|
||||||
import { IModalProps } from '@/interfaces/common';
|
import { IModalProps } from '@/interfaces/common';
|
||||||
import { DeleteOutlined } from '@ant-design/icons';
|
import { DeleteOutlined } from '@ant-design/icons';
|
||||||
@ -5,7 +6,6 @@ import { Checkbox, Divider, Form, Input, Modal, Space } from 'antd';
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useDeleteChunkByIds } from '../../hooks';
|
import { useDeleteChunkByIds } from '../../hooks';
|
||||||
import EditTag from '../edit-tag';
|
|
||||||
|
|
||||||
type FieldType = {
|
type FieldType = {
|
||||||
content?: string;
|
content?: string;
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
useSubmitKnowledgeConfiguration,
|
useSubmitKnowledgeConfiguration,
|
||||||
} from './hooks';
|
} from './hooks';
|
||||||
|
|
||||||
|
import EntityTypesForm from '@/components/entity-types-form';
|
||||||
import LayoutRecognize from '@/components/layout-recognize';
|
import LayoutRecognize from '@/components/layout-recognize';
|
||||||
import MaxTokenNumber from '@/components/max-token-number';
|
import MaxTokenNumber from '@/components/max-token-number';
|
||||||
import ParseConfiguration, {
|
import ParseConfiguration, {
|
||||||
@ -98,6 +99,7 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<EntityTypesForm></EntityTypesForm>
|
||||||
<Form.Item noStyle dependencies={['parser_id']}>
|
<Form.Item noStyle dependencies={['parser_id']}>
|
||||||
{({ getFieldValue }) => {
|
{({ getFieldValue }) => {
|
||||||
const parserId = getFieldValue('parser_id');
|
const parserId = getFieldValue('parser_id');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user