mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 14:18:57 +08:00
### What problem does this PR solve? feat: Delete Model Provider #2376 ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
91dbce30bd
commit
9251fb39af
@ -278,3 +278,26 @@ export const useDeleteLlm = () => {
|
||||
|
||||
return { data, loading, deleteLlm: mutateAsync };
|
||||
};
|
||||
|
||||
export const useDeleteFactory = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: ['deleteFactory'],
|
||||
mutationFn: async (params: IDeleteLlmRequestBody) => {
|
||||
const { data } = await userService.deleteFactory(params);
|
||||
if (data.retcode === 0) {
|
||||
queryClient.invalidateQueries({ queryKey: ['myLlmList'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['factoryList'] });
|
||||
message.success(t('message.deleted'));
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, deleteFactory: mutateAsync };
|
||||
};
|
||||
|
@ -8,5 +8,5 @@ export interface IAddLlmRequestBody {
|
||||
|
||||
export interface IDeleteLlmRequestBody {
|
||||
llm_factory: string; // Ollama
|
||||
llm_name: string;
|
||||
llm_name?: string;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import {
|
||||
IApiKeySavingParams,
|
||||
ISystemModelSettingSavingParams,
|
||||
useAddLlm,
|
||||
useDeleteFactory,
|
||||
useDeleteLlm,
|
||||
useSaveApiKey,
|
||||
useSaveTenantInfo,
|
||||
@ -366,3 +367,18 @@ export const useHandleDeleteLlm = (llmFactory: string) => {
|
||||
|
||||
return { handleDeleteLlm };
|
||||
};
|
||||
|
||||
export const useHandleDeleteFactory = (llmFactory: string) => {
|
||||
const { deleteFactory } = useDeleteFactory();
|
||||
const showDeleteConfirm = useShowDeleteConfirm();
|
||||
|
||||
const handleDeleteFactory = () => {
|
||||
showDeleteConfirm({
|
||||
onOk: async () => {
|
||||
deleteFactory({ llm_factory: llmFactory });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return { handleDeleteFactory };
|
||||
};
|
||||
|
@ -34,6 +34,7 @@ import { IconMap } from './constant';
|
||||
import FishAudioModal from './fish-audio-modal';
|
||||
import GoogleModal from './google-modal';
|
||||
import {
|
||||
useHandleDeleteFactory,
|
||||
useHandleDeleteLlm,
|
||||
useSubmitApiKey,
|
||||
useSubmitBedrock,
|
||||
@ -75,6 +76,7 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
||||
const { visible, switchVisible } = useSetModalState();
|
||||
const { t } = useTranslate('setting');
|
||||
const { handleDeleteLlm } = useHandleDeleteLlm(item.name);
|
||||
const { handleDeleteFactory } = useHandleDeleteFactory(item.name);
|
||||
|
||||
const handleApiKeyClick = () => {
|
||||
clickApiKey(item.name);
|
||||
@ -118,6 +120,9 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
||||
<MoreModelIcon />
|
||||
</Flex>
|
||||
</Button>
|
||||
<Button type={'text'} onClick={handleDeleteFactory}>
|
||||
<CloseCircleOutlined style={{ color: '#D92D20' }} />
|
||||
</Button>
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
|
@ -16,6 +16,7 @@ const {
|
||||
set_tenant_info,
|
||||
add_llm,
|
||||
delete_llm,
|
||||
deleteFactory,
|
||||
getSystemStatus,
|
||||
getSystemVersion,
|
||||
} = api;
|
||||
@ -81,6 +82,10 @@ const methods = {
|
||||
url: getSystemVersion,
|
||||
method: 'get',
|
||||
},
|
||||
deleteFactory: {
|
||||
url: deleteFactory,
|
||||
method: 'post',
|
||||
},
|
||||
} as const;
|
||||
|
||||
const userService = registerServer<keyof typeof methods>(methods, request);
|
||||
|
@ -19,6 +19,7 @@ export default {
|
||||
set_api_key: `${api_host}/llm/set_api_key`,
|
||||
add_llm: `${api_host}/llm/add_llm`,
|
||||
delete_llm: `${api_host}/llm/delete_llm`,
|
||||
deleteFactory: `${api_host}/llm/delete_factory`,
|
||||
|
||||
// knowledge base
|
||||
kb_list: `${api_host}/kb/list`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user