Feat: Add mineru as a model manufacturer to the system. #10621
This commit is contained in:
parent
2bb0b0faee
commit
4a2d2f2149
11 changed files with 125 additions and 70 deletions
22
web/src/assets/svg/llm/mineru-bright.svg
Normal file
22
web/src/assets/svg/llm/mineru-bright.svg
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M20.2314 3.36021C20.2314 4.11144 19.6199 4.72043 18.8657 4.72043C18.1115 4.72043 17.5 4.11144 17.5 3.36021C17.5 2.60899 18.1115 2 18.8657 2C19.6199 2 20.2314 2.60899 20.2314 3.36021Z" fill="url(#paint0_linear_1151_8035)"/>
|
||||||
|
<path d="M20.2314 3.36021C20.2314 4.11144 19.6199 4.72043 18.8657 4.72043C18.1115 4.72043 17.5 4.11144 17.5 3.36021C17.5 2.60899 18.1115 2 18.8657 2C19.6199 2 20.2314 2.60899 20.2314 3.36021Z" fill="#010101"/>
|
||||||
|
<path d="M15.5887 4.72056C15.5887 5.4718 14.9773 6.08078 14.2231 6.08078C13.4688 6.08078 12.8574 5.4718 12.8574 4.72056C12.8574 3.96934 13.4688 3.36035 14.2231 3.36035C14.9773 3.36035 15.5887 3.96934 15.5887 4.72056Z" fill="url(#paint1_linear_1151_8035)"/>
|
||||||
|
<path d="M15.5887 4.72056C15.5887 5.4718 14.9773 6.08078 14.2231 6.08078C13.4688 6.08078 12.8574 5.4718 12.8574 4.72056C12.8574 3.96934 13.4688 3.36035 14.2231 3.36035C14.9773 3.36035 15.5887 3.96934 15.5887 4.72056Z" fill="#010101"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.78915 11.1888C7.78915 13.5517 8.95326 15.6437 10.7413 16.927C11.8105 15.9726 12.4832 14.5866 12.4832 13.0441V9.2336C12.4832 8.65972 12.8718 8.15804 13.4293 8.01257L20.4114 6.19033C21.2147 5.98069 22 6.5843 22 7.41139V12.0478C22 17.5442 17.5265 21.9998 12.0082 21.9998H11.9918C6.4735 21.9998 2 17.5442 2 12.0478V8.8481C2 8.27204 2.39155 7.76904 2.95168 7.62557L6.20613 6.79194C7.00807 6.58652 7.78915 7.18972 7.78915 8.01444V11.1888ZM3.4484 12.0478C3.4484 13.963 4.08358 15.7303 5.15556 17.1522C5.65521 17.815 6.41799 18.2567 7.24973 18.2567C8.0415 18.2567 8.79224 18.0815 9.46491 17.768C7.55744 16.2072 6.34075 13.8395 6.34075 11.1888V8.24701L3.4484 8.98791V12.0478Z" fill="url(#paint2_linear_1151_8035)"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.78915 11.1888C7.78915 13.5517 8.95326 15.6437 10.7413 16.927C11.8105 15.9726 12.4832 14.5866 12.4832 13.0441V9.2336C12.4832 8.65972 12.8718 8.15804 13.4293 8.01257L20.4114 6.19033C21.2147 5.98069 22 6.5843 22 7.41139V12.0478C22 17.5442 17.5265 21.9998 12.0082 21.9998H11.9918C6.4735 21.9998 2 17.5442 2 12.0478V8.8481C2 8.27204 2.39155 7.76904 2.95168 7.62557L6.20613 6.79194C7.00807 6.58652 7.78915 7.18972 7.78915 8.01444V11.1888ZM3.4484 12.0478C3.4484 13.963 4.08358 15.7303 5.15556 17.1522C5.65521 17.815 6.41799 18.2567 7.24973 18.2567C8.0415 18.2567 8.79224 18.0815 9.46491 17.768C7.55744 16.2072 6.34075 13.8395 6.34075 11.1888V8.24701L3.4484 8.98791V12.0478Z" fill="#010101"/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="paint0_linear_1151_8035" x1="14.5453" y1="8.14096" x2="13.2718" y2="19.9129" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#2E2E2E"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="paint1_linear_1151_8035" x1="14.5459" y1="8.1411" x2="13.2725" y2="19.9131" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#2E2E2E"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="paint2_linear_1151_8035" x1="14.5456" y1="8.14075" x2="13.2722" y2="19.9127" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#2E2E2E"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.1 KiB |
22
web/src/assets/svg/llm/mineru-dark.svg
Normal file
22
web/src/assets/svg/llm/mineru-dark.svg
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M20.2314 3.36021C20.2314 4.11144 19.6199 4.72043 18.8657 4.72043C18.1115 4.72043 17.5 4.11144 17.5 3.36021C17.5 2.60899 18.1115 2 18.8657 2C19.6199 2 20.2314 2.60899 20.2314 3.36021Z" fill="url(#paint0_linear_1151_8043)"/>
|
||||||
|
<path d="M20.2314 3.36021C20.2314 4.11144 19.6199 4.72043 18.8657 4.72043C18.1115 4.72043 17.5 4.11144 17.5 3.36021C17.5 2.60899 18.1115 2 18.8657 2C19.6199 2 20.2314 2.60899 20.2314 3.36021Z" fill="white"/>
|
||||||
|
<path d="M15.5887 4.72056C15.5887 5.4718 14.9773 6.08078 14.2231 6.08078C13.4688 6.08078 12.8574 5.4718 12.8574 4.72056C12.8574 3.96934 13.4688 3.36035 14.2231 3.36035C14.9773 3.36035 15.5887 3.96934 15.5887 4.72056Z" fill="url(#paint1_linear_1151_8043)"/>
|
||||||
|
<path d="M15.5887 4.72056C15.5887 5.4718 14.9773 6.08078 14.2231 6.08078C13.4688 6.08078 12.8574 5.4718 12.8574 4.72056C12.8574 3.96934 13.4688 3.36035 14.2231 3.36035C14.9773 3.36035 15.5887 3.96934 15.5887 4.72056Z" fill="white"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.78915 11.1888C7.78915 13.5517 8.95326 15.6437 10.7413 16.927C11.8105 15.9726 12.4832 14.5866 12.4832 13.0441V9.2336C12.4832 8.65972 12.8718 8.15804 13.4293 8.01257L20.4114 6.19033C21.2147 5.98069 22 6.5843 22 7.41139V12.0478C22 17.5442 17.5265 21.9998 12.0082 21.9998H11.9918C6.4735 21.9998 2 17.5442 2 12.0478V8.8481C2 8.27204 2.39155 7.76904 2.95168 7.62557L6.20613 6.79194C7.00807 6.58652 7.78915 7.18972 7.78915 8.01444V11.1888ZM3.4484 12.0478C3.4484 13.963 4.08358 15.7303 5.15556 17.1522C5.65521 17.815 6.41799 18.2567 7.24973 18.2567C8.0415 18.2567 8.79224 18.0815 9.46491 17.768C7.55744 16.2072 6.34075 13.8395 6.34075 11.1888V8.24701L3.4484 8.98791V12.0478Z" fill="url(#paint2_linear_1151_8043)"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.78915 11.1888C7.78915 13.5517 8.95326 15.6437 10.7413 16.927C11.8105 15.9726 12.4832 14.5866 12.4832 13.0441V9.2336C12.4832 8.65972 12.8718 8.15804 13.4293 8.01257L20.4114 6.19033C21.2147 5.98069 22 6.5843 22 7.41139V12.0478C22 17.5442 17.5265 21.9998 12.0082 21.9998H11.9918C6.4735 21.9998 2 17.5442 2 12.0478V8.8481C2 8.27204 2.39155 7.76904 2.95168 7.62557L6.20613 6.79194C7.00807 6.58652 7.78915 7.18972 7.78915 8.01444V11.1888ZM3.4484 12.0478C3.4484 13.963 4.08358 15.7303 5.15556 17.1522C5.65521 17.815 6.41799 18.2567 7.24973 18.2567C8.0415 18.2567 8.79224 18.0815 9.46491 17.768C7.55744 16.2072 6.34075 13.8395 6.34075 11.1888V8.24701L3.4484 8.98791V12.0478Z" fill="white"/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="paint0_linear_1151_8043" x1="14.5453" y1="8.14096" x2="13.2718" y2="19.9129" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#2E2E2E"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="paint1_linear_1151_8043" x1="14.5459" y1="8.1411" x2="13.2725" y2="19.9131" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#2E2E2E"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="paint2_linear_1151_8043" x1="14.5456" y1="8.14075" x2="13.2722" y2="19.9127" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#2E2E2E"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.1 KiB |
|
|
@ -69,6 +69,7 @@ export const LlmIcon = ({
|
||||||
LLMFactory.TogetherAI,
|
LLMFactory.TogetherAI,
|
||||||
LLMFactory.Meituan,
|
LLMFactory.Meituan,
|
||||||
LLMFactory.Longcat,
|
LLMFactory.Longcat,
|
||||||
|
LLMFactory.MinerU,
|
||||||
];
|
];
|
||||||
let icon = useMemo(() => {
|
let icon = useMemo(() => {
|
||||||
const icontemp = IconMap[name as keyof typeof IconMap];
|
const icontemp = IconMap[name as keyof typeof IconMap];
|
||||||
|
|
@ -88,6 +89,7 @@ export const LlmIcon = ({
|
||||||
// LLMFactory.MiniMax,
|
// LLMFactory.MiniMax,
|
||||||
LLMFactory.Gemini,
|
LLMFactory.Gemini,
|
||||||
LLMFactory.StepFun,
|
LLMFactory.StepFun,
|
||||||
|
LLMFactory.MinerU,
|
||||||
// LLMFactory.DeerAPI,
|
// LLMFactory.DeerAPI,
|
||||||
];
|
];
|
||||||
if (svgIcons.includes(name as LLMFactory)) {
|
if (svgIcons.includes(name as LLMFactory)) {
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ export const IconMap = {
|
||||||
[LLMFactory.DeerAPI]: 'deerapi',
|
[LLMFactory.DeerAPI]: 'deerapi',
|
||||||
[LLMFactory.JiekouAI]: 'jiekouai',
|
[LLMFactory.JiekouAI]: 'jiekouai',
|
||||||
[LLMFactory.Builtin]: 'builtin',
|
[LLMFactory.Builtin]: 'builtin',
|
||||||
[LLMFactory.MinerU]: 'openai',
|
[LLMFactory.MinerU]: 'mineru',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const APIMapUrl = {
|
export const APIMapUrl = {
|
||||||
|
|
|
||||||
|
|
@ -1062,6 +1062,21 @@ Example: Virtual Hosted Style`,
|
||||||
modelsToBeAddedTooltip:
|
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). ',
|
'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',
|
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: {
|
message: {
|
||||||
registered: 'Registered!',
|
registered: 'Registered!',
|
||||||
|
|
|
||||||
|
|
@ -934,6 +934,21 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于
|
||||||
modelsToBeAddedTooltip:
|
modelsToBeAddedTooltip:
|
||||||
'如果你的模型供应商在这里没有列出,但是宣称 OpenAI-compatible,可以通过选择卡片 OpenAI-API-compatible 设置相关模型。',
|
'如果你的模型供应商在这里没有列出,但是宣称 OpenAI-compatible,可以通过选择卡片 OpenAI-API-compatible 设置相关模型。',
|
||||||
mcp: 'MCP',
|
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: {
|
message: {
|
||||||
registered: '注册成功',
|
registered: '注册成功',
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ export const ModelProviderCard: FC<IModelCardProps> = ({
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex h-16 items-center justify-between p-4 cursor-pointer transition-colors text-text-secondary">
|
<div className="flex h-16 items-center justify-between p-4 cursor-pointer transition-colors text-text-secondary">
|
||||||
<div className="flex items-center space-x-3">
|
<div className="flex items-center space-x-3">
|
||||||
<LlmIcon name={item.name} />
|
<LlmIcon name={item.name} width={32} />
|
||||||
<div>
|
<div>
|
||||||
<div className="font-medium text-xl text-text-primary">
|
<div className="font-medium text-xl text-text-primary">
|
||||||
{item.name}
|
{item.name}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export const UsedModel = ({
|
||||||
handleAddModel: (factory: string) => void;
|
handleAddModel: (factory: string) => void;
|
||||||
handleEditModel: (model: any, factory: LlmItem) => void;
|
handleEditModel: (model: any, factory: LlmItem) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const { factoryList, myLlmList: llmList, loading } = useSelectLlmList();
|
const { myLlmList: llmList } = useSelectLlmList();
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col w-full gap-5 mb-4">
|
<div className="flex flex-col w-full gap-5 mb-4">
|
||||||
<div className="text-text-primary text-2xl font-medium mb-2 mt-4">
|
<div className="text-text-primary text-2xl font-medium mb-2 mt-4">
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { getRealModelName } from '@/utils/llm-util';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { ApiKeyPostBody } from '../interface';
|
import { ApiKeyPostBody } from '../interface';
|
||||||
|
import { MinerUFormValues } from './modal/mineru-modal';
|
||||||
|
|
||||||
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
||||||
|
|
||||||
|
|
@ -461,15 +462,6 @@ export const useHandleDeleteFactory = (llmFactory: string) => {
|
||||||
return { handleDeleteFactory, deleteFactory };
|
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 = () => {
|
export const useSubmitMinerU = () => {
|
||||||
const { addLlm, loading } = useAddLlm();
|
const { addLlm, loading } = useAddLlm();
|
||||||
const {
|
const {
|
||||||
|
|
@ -477,18 +469,12 @@ export const useSubmitMinerU = () => {
|
||||||
hideModal: hideMineruModal,
|
hideModal: hideMineruModal,
|
||||||
showModal: showMineruModal,
|
showModal: showMineruModal,
|
||||||
} = useSetModalState();
|
} = useSetModalState();
|
||||||
const [initialValues, setInitialValues] = useState<
|
|
||||||
Partial<MinerUFormValues> | undefined
|
|
||||||
>();
|
|
||||||
|
|
||||||
const onMineruOk = useCallback(
|
const onMineruOk = useCallback(
|
||||||
async (payload: MinerUFormValues) => {
|
async (payload: MinerUFormValues) => {
|
||||||
const cfg = {
|
const cfg = {
|
||||||
MINERU_APISERVER: payload.mineru_apiserver || '',
|
...payload,
|
||||||
MINERU_OUTPUT_DIR: payload.mineru_output_dir || '',
|
mineru_delete_output: payload.mineru_delete_output ?? true ? '1' : '0',
|
||||||
MINERU_BACKEND: payload.mineru_backend || 'pipeline',
|
|
||||||
MINERU_SERVER_URL: payload.mineru_server_url || '',
|
|
||||||
MINERU_DELETE_OUTPUT: payload.mineru_delete_output ?? true ? '1' : '0',
|
|
||||||
};
|
};
|
||||||
const req: IAddLlmRequestBody = {
|
const req: IAddLlmRequestBody = {
|
||||||
llm_factory: LLMFactory.MinerU,
|
llm_factory: LLMFactory.MinerU,
|
||||||
|
|
@ -501,23 +487,16 @@ export const useSubmitMinerU = () => {
|
||||||
const ret = await addLlm(req);
|
const ret = await addLlm(req);
|
||||||
if (ret === 0) {
|
if (ret === 0) {
|
||||||
hideMineruModal();
|
hideMineruModal();
|
||||||
setInitialValues(undefined);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[addLlm, hideMineruModal],
|
[addLlm, hideMineruModal],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleShowMineruModal = (values?: Partial<MinerUFormValues>) => {
|
|
||||||
setInitialValues(values);
|
|
||||||
showMineruModal();
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mineruVisible,
|
mineruVisible,
|
||||||
hideMineruModal,
|
hideMineruModal,
|
||||||
showMineruModal: handleShowMineruModal,
|
showMineruModal,
|
||||||
onMineruOk,
|
onMineruOk,
|
||||||
mineruLoading: loading,
|
mineruLoading: loading,
|
||||||
mineruInitialValues: initialValues,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,6 @@ const ModelProviders = () => {
|
||||||
showMineruModal,
|
showMineruModal,
|
||||||
onMineruOk,
|
onMineruOk,
|
||||||
mineruLoading,
|
mineruLoading,
|
||||||
mineruInitialValues,
|
|
||||||
} = useSubmitMinerU();
|
} = useSubmitMinerU();
|
||||||
|
|
||||||
const ModalMap = useMemo(
|
const ModalMap = useMemo(
|
||||||
|
|
@ -156,12 +155,13 @@ const ModelProviders = () => {
|
||||||
showBedrockAddingModal,
|
showBedrockAddingModal,
|
||||||
showVolcAddingModal,
|
showVolcAddingModal,
|
||||||
showHunyuanAddingModal,
|
showHunyuanAddingModal,
|
||||||
showTencentCloudAddingModal,
|
|
||||||
showSparkAddingModal,
|
showSparkAddingModal,
|
||||||
showyiyanAddingModal,
|
showyiyanAddingModal,
|
||||||
showFishAudioAddingModal,
|
showFishAudioAddingModal,
|
||||||
|
showTencentCloudAddingModal,
|
||||||
showGoogleAddingModal,
|
showGoogleAddingModal,
|
||||||
showAzureAddingModal,
|
showAzureAddingModal,
|
||||||
|
showMineruModal,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -306,7 +306,6 @@ const ModelProviders = () => {
|
||||||
hideModal={hideMineruModal}
|
hideModal={hideMineruModal}
|
||||||
onOk={onMineruOk}
|
onOk={onMineruOk}
|
||||||
loading={mineruLoading}
|
loading={mineruLoading}
|
||||||
initialValues={mineruInitialValues}
|
|
||||||
></MinerUModal>
|
></MinerUModal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,21 @@ import {
|
||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import { Form } from '@/components/ui/form';
|
import { Form } from '@/components/ui/form';
|
||||||
import { Input } from '@/components/ui/input';
|
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 { Switch } from '@/components/ui/switch';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { LLMFactory } from '@/constants/llm';
|
||||||
import { IModalProps } from '@/interfaces/common';
|
import { IModalProps } from '@/interfaces/common';
|
||||||
|
import { buildOptions } from '@/utils/form';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useEffect } from 'react';
|
import { t } from 'i18next';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
|
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';
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
llm_name: z.string().min(1, {
|
llm_name: z.string().min(1, {
|
||||||
message: 'Model name is required',
|
message: t('setting.mineru.modelNameRequired'),
|
||||||
}),
|
}),
|
||||||
mineru_apiserver: z.string().optional(),
|
mineru_apiserver: z.string().optional(),
|
||||||
mineru_output_dir: z.string().optional(),
|
mineru_output_dir: z.string().optional(),
|
||||||
|
|
@ -35,25 +37,22 @@ const FormSchema = z.object({
|
||||||
mineru_delete_output: z.boolean(),
|
mineru_delete_output: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type MinerUFormValues = z.infer<typeof FormSchema>;
|
export type MinerUFormValues = z.infer<typeof FormSchema>;
|
||||||
|
|
||||||
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' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const MinerUModal = ({
|
const MinerUModal = ({
|
||||||
visible,
|
visible,
|
||||||
hideModal,
|
hideModal,
|
||||||
onOk,
|
onOk,
|
||||||
loading,
|
loading,
|
||||||
initialValues,
|
}: IModalProps<MinerUFormValues>) => {
|
||||||
}: IModalProps<MinerUFormValues> & {
|
const { t } = useTranslation();
|
||||||
initialValues?: Partial<MinerUFormValues>;
|
|
||||||
}) => {
|
const backendOptions = buildOptions([
|
||||||
const { t } = useTranslate('setting');
|
'pipeline',
|
||||||
|
'vlm-transformers',
|
||||||
|
'vlm-vllm-engine',
|
||||||
|
'vlm-http-client',
|
||||||
|
]);
|
||||||
|
|
||||||
const form = useForm<MinerUFormValues>({
|
const form = useForm<MinerUFormValues>({
|
||||||
resolver: zodResolver(FormSchema),
|
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 (
|
return (
|
||||||
<Dialog open={visible} onOpenChange={hideModal}>
|
<Dialog open={visible} onOpenChange={hideModal}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
<LLMHeader name="MinerU" />
|
<LLMHeader name={LLMFactory.MinerU} />
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
|
|
@ -97,32 +83,47 @@ const MinerUModal = ({
|
||||||
className="space-y-6"
|
className="space-y-6"
|
||||||
id="mineru-form"
|
id="mineru-form"
|
||||||
>
|
>
|
||||||
<RAGFlowFormItem name="llm_name" label={t('modelName')} required>
|
<RAGFlowFormItem
|
||||||
|
name="llm_name"
|
||||||
|
label={t('setting.modelName')}
|
||||||
|
required
|
||||||
|
>
|
||||||
<Input placeholder="mineru-from-env-1" />
|
<Input placeholder="mineru-from-env-1" />
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
<RAGFlowFormItem name="mineru_apiserver" label="MINERU_APISERVER">
|
<RAGFlowFormItem
|
||||||
|
name="mineru_apiserver"
|
||||||
|
label={t('setting.mineru.apiserver')}
|
||||||
|
>
|
||||||
<Input placeholder="http://host.docker.internal:9987" />
|
<Input placeholder="http://host.docker.internal:9987" />
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
<RAGFlowFormItem name="mineru_output_dir" label="MINERU_OUTPUT_DIR">
|
<RAGFlowFormItem
|
||||||
|
name="mineru_output_dir"
|
||||||
|
label={t('setting.mineru.outputDir')}
|
||||||
|
>
|
||||||
<Input placeholder="/tmp/mineru" />
|
<Input placeholder="/tmp/mineru" />
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
<RAGFlowFormItem name="mineru_backend" label="MINERU_BACKEND">
|
<RAGFlowFormItem
|
||||||
|
name="mineru_backend"
|
||||||
|
label={t('setting.mineru.backend')}
|
||||||
|
>
|
||||||
{(field) => (
|
{(field) => (
|
||||||
<RAGFlowSelect
|
<RAGFlowSelect
|
||||||
value={field.value}
|
value={field.value}
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
options={backendOptions}
|
options={backendOptions}
|
||||||
placeholder="Select backend"
|
placeholder={t('setting.mineru.selectBackend')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
<RAGFlowFormItem name="mineru_server_url" label="MINERU_SERVER_URL">
|
<RAGFlowFormItem
|
||||||
|
name="mineru_server_url"
|
||||||
|
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="MINERU_DELETE_OUTPUT"
|
label={t('setting.mineru.deleteOutput')}
|
||||||
className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm"
|
|
||||||
labelClassName="!mb-0"
|
labelClassName="!mb-0"
|
||||||
>
|
>
|
||||||
{(field) => (
|
{(field) => (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue