mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-09-26 16:51:23 +00:00

### What problem does this PR solve? Feat: Modify the parsing method string to an enumeration type. #5467 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
187 lines
6.1 KiB
TypeScript
187 lines
6.1 KiB
TypeScript
import {
|
|
AutoKeywordsItem,
|
|
AutoQuestionsItem,
|
|
} from '@/components/auto-keywords-item';
|
|
import { useShowAutoKeywords } from '@/components/chunk-method-modal/hooks';
|
|
import Delimiter from '@/components/delimiter';
|
|
import EntityTypesItem from '@/components/entity-types-item';
|
|
import ExcelToHtml from '@/components/excel-to-html';
|
|
import LayoutRecognize from '@/components/layout-recognize';
|
|
import MaxTokenNumber from '@/components/max-token-number';
|
|
import PageRank from '@/components/page-rank';
|
|
import ParseConfiguration, {
|
|
showRaptorParseConfiguration,
|
|
showTagItems,
|
|
} from '@/components/parse-configuration';
|
|
import GraphRagItems, {
|
|
showGraphRagItems,
|
|
} from '@/components/parse-configuration/graph-rag-items';
|
|
import { DocumentParserType } from '@/constants/knowledge';
|
|
import { useTranslate } from '@/hooks/common-hooks';
|
|
import { useHandleChunkMethodSelectChange } from '@/hooks/logic-hooks';
|
|
import { normFile } from '@/utils/file-util';
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
import { Button, Form, Input, Radio, Select, Space, Upload } from 'antd';
|
|
import { FormInstance } from 'antd/lib';
|
|
import {
|
|
useFetchKnowledgeConfigurationOnMount,
|
|
useSubmitKnowledgeConfiguration,
|
|
} from './hooks';
|
|
import styles from './index.less';
|
|
import { TagItems } from './tag-item';
|
|
|
|
const { Option } = Select;
|
|
|
|
const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|
const { submitKnowledgeConfiguration, submitLoading, navigateToDataset } =
|
|
useSubmitKnowledgeConfiguration(form);
|
|
const { parserList, embeddingModelOptions, disabled } =
|
|
useFetchKnowledgeConfigurationOnMount(form);
|
|
const { t } = useTranslate('knowledgeConfiguration');
|
|
const handleChunkMethodSelectChange = useHandleChunkMethodSelectChange(form);
|
|
const showAutoKeywords = useShowAutoKeywords();
|
|
|
|
return (
|
|
<Form form={form} name="validateOnly" layout="vertical" autoComplete="off">
|
|
<Form.Item name="name" label={t('name')} rules={[{ required: true }]}>
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item
|
|
name="avatar"
|
|
label={t('photo')}
|
|
valuePropName="fileList"
|
|
getValueFromEvent={normFile}
|
|
>
|
|
<Upload
|
|
listType="picture-card"
|
|
maxCount={1}
|
|
beforeUpload={() => false}
|
|
showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
|
|
>
|
|
<button style={{ border: 0, background: 'none' }} type="button">
|
|
<PlusOutlined />
|
|
<div style={{ marginTop: 8 }}>{t('upload')}</div>
|
|
</button>
|
|
</Upload>
|
|
</Form.Item>
|
|
<Form.Item name="description" label={t('description')}>
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item
|
|
label={t('language')}
|
|
name="language"
|
|
initialValue={'English'}
|
|
rules={[{ required: true, message: t('languageMessage') }]}
|
|
>
|
|
<Select placeholder={t('languagePlaceholder')}>
|
|
<Option value="English">{t('english')}</Option>
|
|
<Option value="Chinese">{t('chinese')}</Option>
|
|
<Option value="Vietnamese">{t('vietnamese')}</Option>
|
|
<Option value="Portuguese (Brazil)">{t('portugueseBr')}</Option>
|
|
</Select>
|
|
</Form.Item>
|
|
<Form.Item
|
|
name="permission"
|
|
label={t('permissions')}
|
|
tooltip={t('permissionsTip')}
|
|
rules={[{ required: true }]}
|
|
>
|
|
<Radio.Group>
|
|
<Radio value="me">{t('me')}</Radio>
|
|
<Radio value="team">{t('team')}</Radio>
|
|
</Radio.Group>
|
|
</Form.Item>
|
|
<Form.Item
|
|
name="embd_id"
|
|
label={t('embeddingModel')}
|
|
rules={[{ required: true }]}
|
|
tooltip={t('embeddingModelTip')}
|
|
>
|
|
<Select
|
|
placeholder={t('embeddingModelPlaceholder')}
|
|
options={embeddingModelOptions}
|
|
disabled={disabled}
|
|
></Select>
|
|
</Form.Item>
|
|
<Form.Item
|
|
name="parser_id"
|
|
label={t('chunkMethod')}
|
|
tooltip={t('chunkMethodTip')}
|
|
rules={[{ required: true }]}
|
|
>
|
|
<Select
|
|
placeholder={t('chunkMethodPlaceholder')}
|
|
disabled={disabled}
|
|
onChange={handleChunkMethodSelectChange}
|
|
>
|
|
{parserList.map((x) => (
|
|
<Option value={x.value} key={x.value}>
|
|
{x.label}
|
|
</Option>
|
|
))}
|
|
</Select>
|
|
</Form.Item>
|
|
<PageRank></PageRank>
|
|
<Form.Item noStyle dependencies={['parser_id']}>
|
|
{({ getFieldValue }) => {
|
|
const parserId = getFieldValue('parser_id');
|
|
|
|
return (
|
|
<>
|
|
{parserId === DocumentParserType.KnowledgeGraph && (
|
|
<>
|
|
<EntityTypesItem></EntityTypesItem>
|
|
<MaxTokenNumber max={8192 * 2}></MaxTokenNumber>
|
|
<Delimiter></Delimiter>
|
|
</>
|
|
)}
|
|
{showAutoKeywords(parserId) && (
|
|
<>
|
|
<AutoKeywordsItem></AutoKeywordsItem>
|
|
<AutoQuestionsItem></AutoQuestionsItem>
|
|
</>
|
|
)}
|
|
{parserId === DocumentParserType.Naive && (
|
|
<>
|
|
<MaxTokenNumber></MaxTokenNumber>
|
|
<Delimiter></Delimiter>
|
|
<LayoutRecognize></LayoutRecognize>
|
|
<ExcelToHtml></ExcelToHtml>
|
|
</>
|
|
)}
|
|
|
|
{showRaptorParseConfiguration(parserId) && (
|
|
<ParseConfiguration></ParseConfiguration>
|
|
)}
|
|
|
|
{showGraphRagItems(parserId) && <GraphRagItems></GraphRagItems>}
|
|
|
|
{showTagItems(parserId) && <TagItems></TagItems>}
|
|
</>
|
|
);
|
|
}}
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
|
<div className={styles.buttonWrapper}>
|
|
<Space>
|
|
<Button size={'middle'} onClick={navigateToDataset}>
|
|
{t('cancel')}
|
|
</Button>
|
|
<Button
|
|
type="primary"
|
|
size={'middle'}
|
|
loading={submitLoading}
|
|
onClick={submitKnowledgeConfiguration}
|
|
>
|
|
{t('save')}
|
|
</Button>
|
|
</Space>
|
|
</div>
|
|
</Form.Item>
|
|
</Form>
|
|
);
|
|
};
|
|
|
|
export default ConfigurationForm;
|