From 8bca17ee1df8987a50669c9dc742b6f936e475d5 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 24 May 2024 18:32:48 -0700 Subject: [PATCH] refac --- src/lib/components/workspace/Models.svelte | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/lib/components/workspace/Models.svelte b/src/lib/components/workspace/Models.svelte index d5e9cf8a5..c6b689643 100644 --- a/src/lib/components/workspace/Models.svelte +++ b/src/lib/components/workspace/Models.svelte @@ -20,27 +20,23 @@ let modelfilesImportInputElement: HTMLInputElement; const deleteModelHandler = async (model) => { - if (model?.info?.base_model_id) { - const res = await deleteModelById(localStorage.token, model.id); - - if (res) { - toast.success($i18n.t(`Deleted {{name}}`, { name: model.id })); - } - await models.set(await getModels(localStorage.token)); - } else if (model?.owned_by === 'ollama') { - const res = await deleteModel(localStorage.token, model.id); - - if (res) { - toast.success($i18n.t(`Deleted {{name}}`, { name: model.id })); - } - await models.set(await getModels(localStorage.token)); - } else { + console.log(model.info); + if (!model?.info) { toast.error( - $i18n.t('{{ owner }}: You cannot delete this model', { + $i18n.t('{{ owner }}: You cannot delete a base model', { owner: model.owned_by.toUpperCase() }) ); + return null; } + + const res = await deleteModelById(localStorage.token, model.id); + + if (res) { + toast.success($i18n.t(`Deleted {{name}}`, { name: model.id })); + } + + await models.set(await getModels(localStorage.token)); }; const cloneModelHandler = async (model) => {