mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 02:19:10 +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 };
|
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 {
|
export interface IDeleteLlmRequestBody {
|
||||||
llm_factory: string; // Ollama
|
llm_factory: string; // Ollama
|
||||||
llm_name: string;
|
llm_name?: string;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
IApiKeySavingParams,
|
IApiKeySavingParams,
|
||||||
ISystemModelSettingSavingParams,
|
ISystemModelSettingSavingParams,
|
||||||
useAddLlm,
|
useAddLlm,
|
||||||
|
useDeleteFactory,
|
||||||
useDeleteLlm,
|
useDeleteLlm,
|
||||||
useSaveApiKey,
|
useSaveApiKey,
|
||||||
useSaveTenantInfo,
|
useSaveTenantInfo,
|
||||||
@ -366,3 +367,18 @@ export const useHandleDeleteLlm = (llmFactory: string) => {
|
|||||||
|
|
||||||
return { handleDeleteLlm };
|
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 FishAudioModal from './fish-audio-modal';
|
||||||
import GoogleModal from './google-modal';
|
import GoogleModal from './google-modal';
|
||||||
import {
|
import {
|
||||||
|
useHandleDeleteFactory,
|
||||||
useHandleDeleteLlm,
|
useHandleDeleteLlm,
|
||||||
useSubmitApiKey,
|
useSubmitApiKey,
|
||||||
useSubmitBedrock,
|
useSubmitBedrock,
|
||||||
@ -75,6 +76,7 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
|||||||
const { visible, switchVisible } = useSetModalState();
|
const { visible, switchVisible } = useSetModalState();
|
||||||
const { t } = useTranslate('setting');
|
const { t } = useTranslate('setting');
|
||||||
const { handleDeleteLlm } = useHandleDeleteLlm(item.name);
|
const { handleDeleteLlm } = useHandleDeleteLlm(item.name);
|
||||||
|
const { handleDeleteFactory } = useHandleDeleteFactory(item.name);
|
||||||
|
|
||||||
const handleApiKeyClick = () => {
|
const handleApiKeyClick = () => {
|
||||||
clickApiKey(item.name);
|
clickApiKey(item.name);
|
||||||
@ -118,6 +120,9 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
|||||||
<MoreModelIcon />
|
<MoreModelIcon />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button type={'text'} onClick={handleDeleteFactory}>
|
||||||
|
<CloseCircleOutlined style={{ color: '#D92D20' }} />
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -16,6 +16,7 @@ const {
|
|||||||
set_tenant_info,
|
set_tenant_info,
|
||||||
add_llm,
|
add_llm,
|
||||||
delete_llm,
|
delete_llm,
|
||||||
|
deleteFactory,
|
||||||
getSystemStatus,
|
getSystemStatus,
|
||||||
getSystemVersion,
|
getSystemVersion,
|
||||||
} = api;
|
} = api;
|
||||||
@ -81,6 +82,10 @@ const methods = {
|
|||||||
url: getSystemVersion,
|
url: getSystemVersion,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
},
|
},
|
||||||
|
deleteFactory: {
|
||||||
|
url: deleteFactory,
|
||||||
|
method: 'post',
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const userService = registerServer<keyof typeof methods>(methods, request);
|
const userService = registerServer<keyof typeof methods>(methods, request);
|
||||||
|
@ -19,6 +19,7 @@ export default {
|
|||||||
set_api_key: `${api_host}/llm/set_api_key`,
|
set_api_key: `${api_host}/llm/set_api_key`,
|
||||||
add_llm: `${api_host}/llm/add_llm`,
|
add_llm: `${api_host}/llm/add_llm`,
|
||||||
delete_llm: `${api_host}/llm/delete_llm`,
|
delete_llm: `${api_host}/llm/delete_llm`,
|
||||||
|
deleteFactory: `${api_host}/llm/delete_factory`,
|
||||||
|
|
||||||
// knowledge base
|
// knowledge base
|
||||||
kb_list: `${api_host}/kb/list`,
|
kb_list: `${api_host}/kb/list`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user