mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: Restore Delete Model Functionality
This commit is contained in:
parent
afb46564e8
commit
5a6ad99d4e
@ -593,6 +593,7 @@ class ModelManager(object):
|
||||
rmtree(str(model_path))
|
||||
else:
|
||||
model_path.unlink()
|
||||
self.commit()
|
||||
|
||||
# LS: tested
|
||||
def add_model(
|
||||
|
@ -8,6 +8,7 @@ import IAIAlertDialog from 'common/components/IAIAlertDialog';
|
||||
import IAIIconButton from 'common/components/IAIIconButton';
|
||||
import { setOpenModel } from 'features/system/store/systemSlice';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useDeleteMainModelsMutation } from 'services/api/endpoints/models';
|
||||
|
||||
type ModelListItemProps = {
|
||||
modelKey: string;
|
||||
@ -24,6 +25,8 @@ export default function ModelListItem(props: ModelListItemProps) {
|
||||
(state: RootState) => state.system.openModel
|
||||
);
|
||||
|
||||
const [deleteMainModel] = useDeleteMainModelsMutation();
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
@ -35,7 +38,11 @@ export default function ModelListItem(props: ModelListItemProps) {
|
||||
};
|
||||
|
||||
const handleModelDelete = () => {
|
||||
dispatch(deleteModel(modelKey));
|
||||
const [base_model, _, model_name] = modelKey.split('/');
|
||||
deleteMainModel({
|
||||
base_model: base_model,
|
||||
model_name: model_name,
|
||||
});
|
||||
dispatch(setOpenModel(null));
|
||||
};
|
||||
|
||||
|
@ -39,6 +39,11 @@ type UpdateMainModelQuery = {
|
||||
body: MainModelConfig;
|
||||
};
|
||||
|
||||
type DeleteMainModelQuery = {
|
||||
base_model: BaseModelType;
|
||||
model_name: string;
|
||||
};
|
||||
|
||||
const mainModelsAdapter = createEntityAdapter<MainModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.name.localeCompare(b.name),
|
||||
});
|
||||
@ -121,6 +126,18 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: ['MainModel'],
|
||||
}),
|
||||
deleteMainModels: build.mutation<
|
||||
EntityState<MainModelConfigEntity>,
|
||||
DeleteMainModelQuery
|
||||
>({
|
||||
query: ({ base_model, model_name }) => {
|
||||
return {
|
||||
url: `models/${base_model}/main/${model_name}`,
|
||||
method: 'DELETE',
|
||||
};
|
||||
},
|
||||
invalidatesTags: ['MainModel'],
|
||||
}),
|
||||
getLoRAModels: build.query<EntityState<LoRAModelConfigEntity>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
|
||||
providesTags: (result, error, arg) => {
|
||||
@ -265,4 +282,5 @@ export const {
|
||||
useGetTextualInversionModelsQuery,
|
||||
useGetVaeModelsQuery,
|
||||
useUpdateMainModelsMutation,
|
||||
useDeleteMainModelsMutation,
|
||||
} = modelsApi;
|
||||
|
Loading…
Reference in New Issue
Block a user