mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 15:06:50 +08:00
Refa: better UX for adding OCR model (#12034)
### What problem does this PR solve? Better UX for adding OCR model. ### Type of change - [x] Refactoring
This commit is contained in:
@ -1110,6 +1110,9 @@ Example: Virtual Hosted Style`,
|
|||||||
mcp: 'MCP',
|
mcp: 'MCP',
|
||||||
mineru: {
|
mineru: {
|
||||||
modelNameRequired: 'Model name is required',
|
modelNameRequired: 'Model name is required',
|
||||||
|
apiServerRequired: 'MinerU API Server Configuration is required',
|
||||||
|
serverUrlBackendLimit:
|
||||||
|
'MinerU Server URL Address is only available for the HTTP client backend',
|
||||||
apiserver: 'MinerU API Server Configuration',
|
apiserver: 'MinerU API Server Configuration',
|
||||||
outputDir: 'MinerU Output Directory Path',
|
outputDir: 'MinerU Output Directory Path',
|
||||||
backend: 'MinerU Processing Backend Type',
|
backend: 'MinerU Processing Backend Type',
|
||||||
@ -1121,6 +1124,11 @@ Example: Virtual Hosted Style`,
|
|||||||
vlmTransformers: 'Vision Language Model with Transformers',
|
vlmTransformers: 'Vision Language Model with Transformers',
|
||||||
vlmVllmEngine: 'Vision Language Model with vLLM Engine',
|
vlmVllmEngine: 'Vision Language Model with vLLM Engine',
|
||||||
vlmHttpClient: 'Vision Language Model via HTTP Client',
|
vlmHttpClient: 'Vision Language Model via HTTP Client',
|
||||||
|
vlmMlxEngine: 'Vision Language Model with MLX Engine',
|
||||||
|
vlmVllmAsyncEngine:
|
||||||
|
'Vision Language Model with vLLM Async Engine (Experimental)',
|
||||||
|
vlmLmdeployEngine:
|
||||||
|
'Vision Language Model with LMDeploy Engine (Experimental)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -959,6 +959,8 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于
|
|||||||
mcp: 'MCP',
|
mcp: 'MCP',
|
||||||
mineru: {
|
mineru: {
|
||||||
modelNameRequired: '模型名称为必填项',
|
modelNameRequired: '模型名称为必填项',
|
||||||
|
apiServerRequired: 'MinerU API服务器配置为必填项',
|
||||||
|
serverUrlBackendLimit: '仅在backend 为vlm-http-client 时可填写',
|
||||||
apiserver: 'MinerU API服务器配置',
|
apiserver: 'MinerU API服务器配置',
|
||||||
outputDir: 'MinerU输出目录路径',
|
outputDir: 'MinerU输出目录路径',
|
||||||
backend: 'MinerU处理后端类型',
|
backend: 'MinerU处理后端类型',
|
||||||
@ -970,6 +972,9 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于
|
|||||||
vlmTransformers: '基于Transformers的视觉语言模型',
|
vlmTransformers: '基于Transformers的视觉语言模型',
|
||||||
vlmVllmEngine: '基于vLLM引擎的视觉语言模型',
|
vlmVllmEngine: '基于vLLM引擎的视觉语言模型',
|
||||||
vlmHttpClient: '通过HTTP客户端连接的视觉语言模型',
|
vlmHttpClient: '通过HTTP客户端连接的视觉语言模型',
|
||||||
|
vlmMlxEngine: '基于MLX引擎的视觉语言模型',
|
||||||
|
vlmVllmAsyncEngine: '基于vLLM异步引擎的视觉语言模型(实验性)',
|
||||||
|
vlmLmdeployEngine: '基于LMDeploy引擎的视觉语言模型(实验性)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -472,10 +472,13 @@ export const useSubmitMinerU = () => {
|
|||||||
|
|
||||||
const onMineruOk = useCallback(
|
const onMineruOk = useCallback(
|
||||||
async (payload: MinerUFormValues) => {
|
async (payload: MinerUFormValues) => {
|
||||||
const cfg = {
|
const cfg: any = {
|
||||||
...payload,
|
...payload,
|
||||||
mineru_delete_output: payload.mineru_delete_output ?? true ? '1' : '0',
|
mineru_delete_output: payload.mineru_delete_output ?? true ? '1' : '0',
|
||||||
};
|
};
|
||||||
|
if (payload.mineru_backend !== 'vlm-http-client') {
|
||||||
|
delete cfg.mineru_server_url;
|
||||||
|
}
|
||||||
const req: IAddLlmRequestBody = {
|
const req: IAddLlmRequestBody = {
|
||||||
llm_factory: LLMFactory.MinerU,
|
llm_factory: LLMFactory.MinerU,
|
||||||
llm_name: payload.llm_name,
|
llm_name: payload.llm_name,
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { IModalProps } from '@/interfaces/common';
|
|||||||
import { buildOptions } from '@/utils/form';
|
import { buildOptions } from '@/utils/form';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm, useWatch } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { LLMHeader } from '../../components/llm-header';
|
import { LLMHeader } from '../../components/llm-header';
|
||||||
@ -25,15 +25,18 @@ const FormSchema = z.object({
|
|||||||
llm_name: z.string().min(1, {
|
llm_name: z.string().min(1, {
|
||||||
message: t('setting.mineru.modelNameRequired'),
|
message: t('setting.mineru.modelNameRequired'),
|
||||||
}),
|
}),
|
||||||
mineru_apiserver: z.string().optional(),
|
mineru_apiserver: z.string().url(),
|
||||||
mineru_output_dir: z.string().optional(),
|
mineru_output_dir: z.string().optional(),
|
||||||
mineru_backend: z.enum([
|
mineru_backend: z.enum([
|
||||||
'pipeline',
|
'pipeline',
|
||||||
'vlm-transformers',
|
'vlm-transformers',
|
||||||
'vlm-vllm-engine',
|
'vlm-vllm-engine',
|
||||||
'vlm-http-client',
|
'vlm-http-client',
|
||||||
|
'vlm-mlx-engine',
|
||||||
|
'vlm-vllm-async-engine',
|
||||||
|
'vlm-lmdeploy-engine',
|
||||||
]),
|
]),
|
||||||
mineru_server_url: z.string().optional(),
|
mineru_server_url: z.string().url().optional(),
|
||||||
mineru_delete_output: z.boolean(),
|
mineru_delete_output: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,6 +55,9 @@ const MinerUModal = ({
|
|||||||
'vlm-transformers',
|
'vlm-transformers',
|
||||||
'vlm-vllm-engine',
|
'vlm-vllm-engine',
|
||||||
'vlm-http-client',
|
'vlm-http-client',
|
||||||
|
'vlm-mlx-engine',
|
||||||
|
'vlm-vllm-async-engine',
|
||||||
|
'vlm-lmdeploy-engine',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const form = useForm<MinerUFormValues>({
|
const form = useForm<MinerUFormValues>({
|
||||||
@ -62,6 +68,11 @@ const MinerUModal = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const backend = useWatch({
|
||||||
|
control: form.control,
|
||||||
|
name: 'mineru_backend',
|
||||||
|
});
|
||||||
|
|
||||||
const handleOk = async (values: MinerUFormValues) => {
|
const handleOk = async (values: MinerUFormValues) => {
|
||||||
const ret = await onOk?.(values as any);
|
const ret = await onOk?.(values as any);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -93,6 +104,7 @@ const MinerUModal = ({
|
|||||||
<RAGFlowFormItem
|
<RAGFlowFormItem
|
||||||
name="mineru_apiserver"
|
name="mineru_apiserver"
|
||||||
label={t('setting.mineru.apiserver')}
|
label={t('setting.mineru.apiserver')}
|
||||||
|
required
|
||||||
>
|
>
|
||||||
<Input placeholder="http://host.docker.internal:9987" />
|
<Input placeholder="http://host.docker.internal:9987" />
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
@ -109,18 +121,25 @@ const MinerUModal = ({
|
|||||||
{(field) => (
|
{(field) => (
|
||||||
<RAGFlowSelect
|
<RAGFlowSelect
|
||||||
value={field.value}
|
value={field.value}
|
||||||
onChange={field.onChange}
|
onChange={(value) => {
|
||||||
|
field.onChange(value);
|
||||||
|
if (value !== 'vlm-http-client') {
|
||||||
|
form.setValue('mineru_server_url', undefined);
|
||||||
|
}
|
||||||
|
}}
|
||||||
options={backendOptions}
|
options={backendOptions}
|
||||||
placeholder={t('setting.mineru.selectBackend')}
|
placeholder={t('setting.mineru.selectBackend')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
|
{backend === 'vlm-http-client' && (
|
||||||
<RAGFlowFormItem
|
<RAGFlowFormItem
|
||||||
name="mineru_server_url"
|
name="mineru_server_url"
|
||||||
label={t('setting.mineru.serverUrl')}
|
label={t('setting.mineru.serverUrl')}
|
||||||
>
|
>
|
||||||
<Input placeholder="http://your-vllm-server:30000" />
|
<Input placeholder="http://your-vllm-server:30000" />
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
|
)}
|
||||||
<RAGFlowFormItem
|
<RAGFlowFormItem
|
||||||
name="mineru_delete_output"
|
name="mineru_delete_output"
|
||||||
label={t('setting.mineru.deleteOutput')}
|
label={t('setting.mineru.deleteOutput')}
|
||||||
|
|||||||
Reference in New Issue
Block a user