mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-22 14:16:42 +08:00
### What problem does this PR solve? Feat: Add mineru as a model manufacturer to the system. #10621 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: balibabu <assassin_cike@163.com>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { LLMFactory } from '@/constants/llm';
|
||||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/common-hooks';
|
||||
import {
|
||||
IApiKeySavingParams,
|
||||
@ -16,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<IApiKeySavingParams, 'api_key'>;
|
||||
|
||||
@ -459,3 +461,42 @@ export const useHandleDeleteFactory = (llmFactory: string) => {
|
||||
|
||||
return { handleDeleteFactory, deleteFactory };
|
||||
};
|
||||
|
||||
export const useSubmitMinerU = () => {
|
||||
const { addLlm, loading } = useAddLlm();
|
||||
const {
|
||||
visible: mineruVisible,
|
||||
hideModal: hideMineruModal,
|
||||
showModal: showMineruModal,
|
||||
} = useSetModalState();
|
||||
|
||||
const onMineruOk = useCallback(
|
||||
async (payload: MinerUFormValues) => {
|
||||
const cfg = {
|
||||
...payload,
|
||||
mineru_delete_output: payload.mineru_delete_output ?? true ? '1' : '0',
|
||||
};
|
||||
const req: IAddLlmRequestBody = {
|
||||
llm_factory: LLMFactory.MinerU,
|
||||
llm_name: payload.llm_name,
|
||||
model_type: 'ocr',
|
||||
api_key: cfg,
|
||||
api_base: '',
|
||||
max_tokens: 0,
|
||||
};
|
||||
const ret = await addLlm(req);
|
||||
if (ret === 0) {
|
||||
hideMineruModal();
|
||||
}
|
||||
},
|
||||
[addLlm, hideMineruModal],
|
||||
);
|
||||
|
||||
return {
|
||||
mineruVisible,
|
||||
hideMineruModal,
|
||||
showMineruModal,
|
||||
onMineruOk,
|
||||
mineruLoading: loading,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user