feat: Added auto_keywords and auto_questions fields to the parsing configuration page #2687 (#2987)

### What problem does this PR solve?

feat: Added auto_keywords and auto_questions fields to the parsing
configuration page #2687

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-10-23 15:45:03 +08:00
committed by GitHub
parent 8714754afc
commit ec6d942d83
7 changed files with 82 additions and 2 deletions

View File

@ -0,0 +1,36 @@
import { useTranslate } from '@/hooks/common-hooks';
import { Form, InputNumber } from 'antd';
const style = {
width: '100%',
};
export const AutoKeywordsItem = () => {
const { t } = useTranslate('knowledgeDetails');
return (
<Form.Item
label={t('autoKeywords')}
name={['parser_config', 'auto_keywords']}
tooltip={t('autoKeywordsTip')}
initialValue={0}
>
<InputNumber style={style}></InputNumber>
</Form.Item>
);
};
export const AutoQuestionsItem = () => {
const { t } = useTranslate('knowledgeDetails');
return (
<Form.Item
label={t('autoQuestions')}
name={['parser_config', 'auto_questions']}
tooltip={t('autoQuestionsTip')}
initialValue={0}
>
<InputNumber style={style}></InputNumber>
</Form.Item>
);
};

View File

@ -1,7 +1,7 @@
import { useHandleChunkMethodSelectChange } from '@/hooks/logic-hooks';
import { useSelectParserList } from '@/hooks/user-setting-hooks';
import { FormInstance } from 'antd';
import { useEffect, useMemo, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
const ParserListMap = new Map([
[
@ -118,3 +118,13 @@ export const useFetchParserListOnMount = (
return { parserList: nextParserList, handleChange, selectedTag };
};
const hideAutoKeywords = ['qa', 'table', 'resume', 'knowledge_graph'];
export const useShowAutoKeywords = () => {
const showAutoKeywords = useCallback((selectedTag: string) => {
return hideAutoKeywords.every((x) => selectedTag !== x);
}, []);
return showAutoKeywords;
};

View File

@ -17,11 +17,12 @@ import {
} from 'antd';
import omit from 'lodash/omit';
import React, { useEffect, useMemo } from 'react';
import { useFetchParserListOnMount } from './hooks';
import { useFetchParserListOnMount, useShowAutoKeywords } from './hooks';
import { useTranslate } from '@/hooks/common-hooks';
import { IParserConfig } from '@/interfaces/database/document';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import { AutoKeywordsItem, AutoQuestionsItem } from '../auto-keywords-item';
import Delimiter from '../delimiter';
import EntityTypesItem from '../entity-types-item';
import ExcelToHtml from '../excel-to-html';
@ -108,6 +109,8 @@ const ChunkMethodModal: React.FC<IProps> = ({
const showExcelToHtml =
selectedTag === 'naive' && documentExtension === 'xlsx';
const showAutoKeywords = useShowAutoKeywords();
const afterClose = () => {
form.resetFields();
};
@ -283,6 +286,12 @@ const ChunkMethodModal: React.FC<IProps> = ({
<Delimiter></Delimiter>
</>
)}
{showAutoKeywords(selectedTag) && (
<>
<AutoKeywordsItem></AutoKeywordsItem>
<AutoQuestionsItem></AutoQuestionsItem>
</>
)}
{showExcelToHtml && <ExcelToHtml></ExcelToHtml>}
{showRaptorParseConfiguration(selectedTag) && (
<ParseConfiguration></ParseConfiguration>