2025-01-22 19:43:27 +08:00
|
|
|
import { LlmModelType } from '@/constants/knowledge';
|
2024-07-17 19:07:34 +08:00
|
|
|
import { useTranslate } from '@/hooks/common-hooks';
|
2025-01-22 19:43:27 +08:00
|
|
|
import { useSelectLlmOptionsByModelType } from '@/hooks/llm-hooks';
|
|
|
|
import { Form, Select } from 'antd';
|
2025-02-28 16:54:04 +08:00
|
|
|
import { camelCase } from 'lodash';
|
2025-01-22 19:43:27 +08:00
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
|
|
|
const enum DocumentType {
|
|
|
|
DeepDOC = 'DeepDOC',
|
|
|
|
PlainText = 'Plain Text',
|
|
|
|
}
|
2024-05-17 14:16:55 +08:00
|
|
|
|
|
|
|
const LayoutRecognize = () => {
|
|
|
|
const { t } = useTranslate('knowledgeDetails');
|
2025-01-22 19:43:27 +08:00
|
|
|
const allOptions = useSelectLlmOptionsByModelType();
|
|
|
|
|
|
|
|
const options = useMemo(() => {
|
|
|
|
const list = [DocumentType.DeepDOC, DocumentType.PlainText].map((x) => ({
|
2025-02-28 16:54:04 +08:00
|
|
|
label: x === DocumentType.PlainText ? t(camelCase(x)) : 'DeepDoc',
|
2025-01-22 19:43:27 +08:00
|
|
|
value: x,
|
|
|
|
}));
|
|
|
|
|
2025-02-28 18:44:04 +08:00
|
|
|
const image2TextList = allOptions[LlmModelType.Image2text].map((x) => {
|
|
|
|
return {
|
|
|
|
...x,
|
|
|
|
options: x.options.map((y) => {
|
|
|
|
return {
|
|
|
|
...y,
|
|
|
|
label: (
|
|
|
|
<div className="flex justify-between items-center gap-2">
|
|
|
|
{y.label}
|
|
|
|
<span className="text-red-500 text-sm">Experimental</span>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
return [...list, ...image2TextList];
|
2025-02-28 16:54:04 +08:00
|
|
|
}, [allOptions, t]);
|
2025-01-22 19:43:27 +08:00
|
|
|
|
2024-05-17 14:16:55 +08:00
|
|
|
return (
|
|
|
|
<Form.Item
|
|
|
|
name={['parser_config', 'layout_recognize']}
|
|
|
|
label={t('layoutRecognize')}
|
2025-01-22 19:43:27 +08:00
|
|
|
initialValue={DocumentType.DeepDOC}
|
2024-05-17 14:16:55 +08:00
|
|
|
tooltip={t('layoutRecognizeTip')}
|
|
|
|
>
|
2025-02-28 18:44:04 +08:00
|
|
|
<Select options={options} popupMatchSelectWidth={false} />
|
2024-05-17 14:16:55 +08:00
|
|
|
</Form.Item>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default LayoutRecognize;
|