From 4a2d2f2149a0124bf98c0b7f10a1d022c5c5b887 Mon Sep 17 00:00:00 2001 From: bill Date: Thu, 11 Dec 2025 14:35:51 +0800 Subject: [PATCH] Feat: Add mineru as a model manufacturer to the system. #10621 --- web/src/assets/svg/llm/mineru-bright.svg | 22 ++++++ web/src/assets/svg/llm/mineru-dark.svg | 22 ++++++ web/src/components/svg-icon.tsx | 2 + web/src/constants/llm.ts | 2 +- web/src/locales/en.ts | 15 ++++ web/src/locales/zh.ts | 15 ++++ .../setting-model/components/modal-card.tsx | 2 +- .../setting-model/components/used-model.tsx | 2 +- .../user-setting/setting-model/hooks.tsx | 29 +------ .../user-setting/setting-model/index.tsx | 5 +- .../modal/mineru-modal/index.tsx | 79 ++++++++++--------- 11 files changed, 125 insertions(+), 70 deletions(-) create mode 100644 web/src/assets/svg/llm/mineru-bright.svg create mode 100644 web/src/assets/svg/llm/mineru-dark.svg diff --git a/web/src/assets/svg/llm/mineru-bright.svg b/web/src/assets/svg/llm/mineru-bright.svg new file mode 100644 index 000000000..7b4c3257b --- /dev/null +++ b/web/src/assets/svg/llm/mineru-bright.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/assets/svg/llm/mineru-dark.svg b/web/src/assets/svg/llm/mineru-dark.svg new file mode 100644 index 000000000..755fe0f3c --- /dev/null +++ b/web/src/assets/svg/llm/mineru-dark.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/components/svg-icon.tsx b/web/src/components/svg-icon.tsx index d21e55ace..756336621 100644 --- a/web/src/components/svg-icon.tsx +++ b/web/src/components/svg-icon.tsx @@ -69,6 +69,7 @@ export const LlmIcon = ({ LLMFactory.TogetherAI, LLMFactory.Meituan, LLMFactory.Longcat, + LLMFactory.MinerU, ]; let icon = useMemo(() => { const icontemp = IconMap[name as keyof typeof IconMap]; @@ -88,6 +89,7 @@ export const LlmIcon = ({ // LLMFactory.MiniMax, LLMFactory.Gemini, LLMFactory.StepFun, + LLMFactory.MinerU, // LLMFactory.DeerAPI, ]; if (svgIcons.includes(name as LLMFactory)) { diff --git a/web/src/constants/llm.ts b/web/src/constants/llm.ts index e95481082..1ff5f5387 100644 --- a/web/src/constants/llm.ts +++ b/web/src/constants/llm.ts @@ -126,7 +126,7 @@ export const IconMap = { [LLMFactory.DeerAPI]: 'deerapi', [LLMFactory.JiekouAI]: 'jiekouai', [LLMFactory.Builtin]: 'builtin', - [LLMFactory.MinerU]: 'openai', + [LLMFactory.MinerU]: 'mineru', }; export const APIMapUrl = { diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index c03408beb..89b1f5b79 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -1062,6 +1062,21 @@ Example: Virtual Hosted Style`, modelsToBeAddedTooltip: 'If your model provider is not listed but claims to be "OpenAI-compatible", select the OpenAI-API-compatible card to add the relevant model(s). ', mcp: 'MCP', + mineru: { + modelNameRequired: 'Model name is required', + apiserver: 'MinerU API Server Configuration', + outputDir: 'MinerU Output Directory Path', + backend: 'MinerU Processing Backend Type', + serverUrl: 'MinerU Server URL Address', + deleteOutput: 'Delete Output Files After Processing', + selectBackend: 'Select processing backend', + backendOptions: { + pipeline: 'Standard Pipeline Processing', + vlmTransformers: 'Vision Language Model with Transformers', + vlmVllmEngine: 'Vision Language Model with vLLM Engine', + vlmHttpClient: 'Vision Language Model via HTTP Client', + }, + }, }, message: { registered: 'Registered!', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 8c879ffc5..73ddefbef 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -934,6 +934,21 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于 modelsToBeAddedTooltip: '如果你的模型供应商在这里没有列出,但是宣称 OpenAI-compatible,可以通过选择卡片 OpenAI-API-compatible 设置相关模型。', mcp: 'MCP', + mineru: { + modelNameRequired: '模型名称为必填项', + apiserver: 'MinerU API服务器配置', + outputDir: 'MinerU输出目录路径', + backend: 'MinerU处理后端类型', + serverUrl: 'MinerU服务器URL地址', + deleteOutput: '处理完成后删除输出文件', + selectBackend: '选择处理后端', + backendOptions: { + pipeline: '标准流水线处理', + vlmTransformers: '基于Transformers的视觉语言模型', + vlmVllmEngine: '基于vLLM引擎的视觉语言模型', + vlmHttpClient: '通过HTTP客户端连接的视觉语言模型', + }, + }, }, message: { registered: '注册成功', diff --git a/web/src/pages/user-setting/setting-model/components/modal-card.tsx b/web/src/pages/user-setting/setting-model/components/modal-card.tsx index 3eac19d92..70a232147 100644 --- a/web/src/pages/user-setting/setting-model/components/modal-card.tsx +++ b/web/src/pages/user-setting/setting-model/components/modal-card.tsx @@ -73,7 +73,7 @@ export const ModelProviderCard: FC = ({ {/* Header */}
- +
{item.name} diff --git a/web/src/pages/user-setting/setting-model/components/used-model.tsx b/web/src/pages/user-setting/setting-model/components/used-model.tsx index 3973f6fb6..91c7bc066 100644 --- a/web/src/pages/user-setting/setting-model/components/used-model.tsx +++ b/web/src/pages/user-setting/setting-model/components/used-model.tsx @@ -9,7 +9,7 @@ export const UsedModel = ({ handleAddModel: (factory: string) => void; handleEditModel: (model: any, factory: LlmItem) => void; }) => { - const { factoryList, myLlmList: llmList, loading } = useSelectLlmList(); + const { myLlmList: llmList } = useSelectLlmList(); return (
diff --git a/web/src/pages/user-setting/setting-model/hooks.tsx b/web/src/pages/user-setting/setting-model/hooks.tsx index edc31fa2a..9fc620d3d 100644 --- a/web/src/pages/user-setting/setting-model/hooks.tsx +++ b/web/src/pages/user-setting/setting-model/hooks.tsx @@ -17,6 +17,7 @@ import { getRealModelName } from '@/utils/llm-util'; import { useQueryClient } from '@tanstack/react-query'; import { useCallback, useState } from 'react'; import { ApiKeyPostBody } from '../interface'; +import { MinerUFormValues } from './modal/mineru-modal'; type SavingParamsState = Omit; @@ -461,15 +462,6 @@ export const useHandleDeleteFactory = (llmFactory: string) => { return { handleDeleteFactory, deleteFactory }; }; -type MinerUFormValues = { - llm_name: string; - mineru_apiserver?: string; - mineru_output_dir?: string; - mineru_backend?: string; - mineru_server_url?: string; - mineru_delete_output?: boolean; -}; - export const useSubmitMinerU = () => { const { addLlm, loading } = useAddLlm(); const { @@ -477,18 +469,12 @@ export const useSubmitMinerU = () => { hideModal: hideMineruModal, showModal: showMineruModal, } = useSetModalState(); - const [initialValues, setInitialValues] = useState< - Partial | undefined - >(); const onMineruOk = useCallback( async (payload: MinerUFormValues) => { const cfg = { - MINERU_APISERVER: payload.mineru_apiserver || '', - MINERU_OUTPUT_DIR: payload.mineru_output_dir || '', - MINERU_BACKEND: payload.mineru_backend || 'pipeline', - MINERU_SERVER_URL: payload.mineru_server_url || '', - MINERU_DELETE_OUTPUT: payload.mineru_delete_output ?? true ? '1' : '0', + ...payload, + mineru_delete_output: payload.mineru_delete_output ?? true ? '1' : '0', }; const req: IAddLlmRequestBody = { llm_factory: LLMFactory.MinerU, @@ -501,23 +487,16 @@ export const useSubmitMinerU = () => { const ret = await addLlm(req); if (ret === 0) { hideMineruModal(); - setInitialValues(undefined); } }, [addLlm, hideMineruModal], ); - const handleShowMineruModal = (values?: Partial) => { - setInitialValues(values); - showMineruModal(); - }; - return { mineruVisible, hideMineruModal, - showMineruModal: handleShowMineruModal, + showMineruModal, onMineruOk, mineruLoading: loading, - mineruInitialValues: initialValues, }; }; diff --git a/web/src/pages/user-setting/setting-model/index.tsx b/web/src/pages/user-setting/setting-model/index.tsx index 1ba713bbf..af7907bb0 100644 --- a/web/src/pages/user-setting/setting-model/index.tsx +++ b/web/src/pages/user-setting/setting-model/index.tsx @@ -136,7 +136,6 @@ const ModelProviders = () => { showMineruModal, onMineruOk, mineruLoading, - mineruInitialValues, } = useSubmitMinerU(); const ModalMap = useMemo( @@ -156,12 +155,13 @@ const ModelProviders = () => { showBedrockAddingModal, showVolcAddingModal, showHunyuanAddingModal, - showTencentCloudAddingModal, showSparkAddingModal, showyiyanAddingModal, showFishAudioAddingModal, + showTencentCloudAddingModal, showGoogleAddingModal, showAzureAddingModal, + showMineruModal, ], ); @@ -306,7 +306,6 @@ const ModelProviders = () => { hideModal={hideMineruModal} onOk={onMineruOk} loading={mineruLoading} - initialValues={mineruInitialValues} >
); diff --git a/web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx b/web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx index aad5df724..7833467db 100644 --- a/web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx +++ b/web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx @@ -9,19 +9,21 @@ import { } from '@/components/ui/dialog'; import { Form } from '@/components/ui/form'; import { Input } from '@/components/ui/input'; -import { RAGFlowSelect, RAGFlowSelectOptionType } from '@/components/ui/select'; +import { RAGFlowSelect } from '@/components/ui/select'; import { Switch } from '@/components/ui/switch'; -import { useTranslate } from '@/hooks/common-hooks'; +import { LLMFactory } from '@/constants/llm'; import { IModalProps } from '@/interfaces/common'; +import { buildOptions } from '@/utils/form'; import { zodResolver } from '@hookform/resolvers/zod'; -import { useEffect } from 'react'; +import { t } from 'i18next'; import { useForm } from 'react-hook-form'; +import { useTranslation } from 'react-i18next'; import { z } from 'zod'; import { LLMHeader } from '../../components/llm-header'; const FormSchema = z.object({ llm_name: z.string().min(1, { - message: 'Model name is required', + message: t('setting.mineru.modelNameRequired'), }), mineru_apiserver: z.string().optional(), mineru_output_dir: z.string().optional(), @@ -35,25 +37,22 @@ const FormSchema = z.object({ mineru_delete_output: z.boolean(), }); -type MinerUFormValues = z.infer; - -const backendOptions: RAGFlowSelectOptionType[] = [ - { value: 'pipeline', label: 'pipeline' }, - { value: 'vlm-transformers', label: 'vlm-transformers' }, - { value: 'vlm-vllm-engine', label: 'vlm-vllm-engine' }, - { value: 'vlm-http-client', label: 'vlm-http-client' }, -]; +export type MinerUFormValues = z.infer; const MinerUModal = ({ visible, hideModal, onOk, loading, - initialValues, -}: IModalProps & { - initialValues?: Partial; -}) => { - const { t } = useTranslate('setting'); +}: IModalProps) => { + const { t } = useTranslation(); + + const backendOptions = buildOptions([ + 'pipeline', + 'vlm-transformers', + 'vlm-vllm-engine', + 'vlm-http-client', + ]); const form = useForm({ resolver: zodResolver(FormSchema), @@ -70,25 +69,12 @@ const MinerUModal = ({ } }; - useEffect(() => { - if (visible) { - form.reset(); - if (initialValues) { - form.reset({ - mineru_backend: 'pipeline', - mineru_delete_output: true, - ...initialValues, - }); - } - } - }, [visible, initialValues, form]); - return ( - +
@@ -97,32 +83,47 @@ const MinerUModal = ({ className="space-y-6" id="mineru-form" > - + - + - + - + {(field) => ( )} - + {(field) => (