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))
|
rmtree(str(model_path))
|
||||||
else:
|
else:
|
||||||
model_path.unlink()
|
model_path.unlink()
|
||||||
|
self.commit()
|
||||||
|
|
||||||
# LS: tested
|
# LS: tested
|
||||||
def add_model(
|
def add_model(
|
||||||
|
@ -8,6 +8,7 @@ import IAIAlertDialog from 'common/components/IAIAlertDialog';
|
|||||||
import IAIIconButton from 'common/components/IAIIconButton';
|
import IAIIconButton from 'common/components/IAIIconButton';
|
||||||
import { setOpenModel } from 'features/system/store/systemSlice';
|
import { setOpenModel } from 'features/system/store/systemSlice';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useDeleteMainModelsMutation } from 'services/api/endpoints/models';
|
||||||
|
|
||||||
type ModelListItemProps = {
|
type ModelListItemProps = {
|
||||||
modelKey: string;
|
modelKey: string;
|
||||||
@ -24,6 +25,8 @@ export default function ModelListItem(props: ModelListItemProps) {
|
|||||||
(state: RootState) => state.system.openModel
|
(state: RootState) => state.system.openModel
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [deleteMainModel] = useDeleteMainModelsMutation();
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@ -35,7 +38,11 @@ export default function ModelListItem(props: ModelListItemProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleModelDelete = () => {
|
const handleModelDelete = () => {
|
||||||
dispatch(deleteModel(modelKey));
|
const [base_model, _, model_name] = modelKey.split('/');
|
||||||
|
deleteMainModel({
|
||||||
|
base_model: base_model,
|
||||||
|
model_name: model_name,
|
||||||
|
});
|
||||||
dispatch(setOpenModel(null));
|
dispatch(setOpenModel(null));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,6 +39,11 @@ type UpdateMainModelQuery = {
|
|||||||
body: MainModelConfig;
|
body: MainModelConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type DeleteMainModelQuery = {
|
||||||
|
base_model: BaseModelType;
|
||||||
|
model_name: string;
|
||||||
|
};
|
||||||
|
|
||||||
const mainModelsAdapter = createEntityAdapter<MainModelConfigEntity>({
|
const mainModelsAdapter = createEntityAdapter<MainModelConfigEntity>({
|
||||||
sortComparer: (a, b) => a.name.localeCompare(b.name),
|
sortComparer: (a, b) => a.name.localeCompare(b.name),
|
||||||
});
|
});
|
||||||
@ -121,6 +126,18 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
},
|
},
|
||||||
invalidatesTags: ['MainModel'],
|
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>({
|
getLoRAModels: build.query<EntityState<LoRAModelConfigEntity>, void>({
|
||||||
query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
|
query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
|
||||||
providesTags: (result, error, arg) => {
|
providesTags: (result, error, arg) => {
|
||||||
@ -265,4 +282,5 @@ export const {
|
|||||||
useGetTextualInversionModelsQuery,
|
useGetTextualInversionModelsQuery,
|
||||||
useGetVaeModelsQuery,
|
useGetVaeModelsQuery,
|
||||||
useUpdateMainModelsMutation,
|
useUpdateMainModelsMutation,
|
||||||
|
useDeleteMainModelsMutation,
|
||||||
} = modelsApi;
|
} = modelsApi;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user