import { DocumentParserType } from '@/constants/knowledge'; import { useTranslate } from '@/hooks/common-hooks'; import { PlusOutlined } from '@ant-design/icons'; import { Button, Flex, Form, Input, InputNumber, Slider, Switch } from 'antd'; import random from 'lodash/random'; export const excludedParseMethods = [ DocumentParserType.Table, DocumentParserType.Resume, DocumentParserType.One, DocumentParserType.Picture, DocumentParserType.KnowledgeGraph, DocumentParserType.Qa, DocumentParserType.Tag, ]; export const showRaptorParseConfiguration = ( parserId: DocumentParserType | undefined, ) => { return !excludedParseMethods.some((x) => x === parserId); }; export const excludedTagParseMethods = [ DocumentParserType.Table, DocumentParserType.KnowledgeGraph, DocumentParserType.Tag, ]; export const showTagItems = (parserId: DocumentParserType) => { return !excludedTagParseMethods.includes(parserId); }; // The three types "table", "resume" and "one" do not display this configuration. const ParseConfiguration = () => { const form = Form.useFormInstance(); const { t } = useTranslate('knowledgeConfiguration'); const handleGenerate = () => { form.setFieldValue( ['parser_config', 'raptor', 'random_seed'], random(10000), ); }; return ( <> prevValues.parser_config.raptor.use_raptor !== curValues.parser_config.raptor.use_raptor } > {({ getFieldValue }) => { const useRaptor = getFieldValue([ 'parser_config', 'raptor', 'use_raptor', ]); return ( useRaptor && ( <> ) ); }} ); }; export default ParseConfiguration;