← back to Exo
formatting deleteModel
bc905cd6182031ae8f371295d14915c32168d9ce · 2024-11-21 17:19:35 -0800 · cadenmackenzie
Files touched
Diff
commit bc905cd6182031ae8f371295d14915c32168d9ce
Author: cadenmackenzie <cadenmackenzie@gmail.com>
Date: Thu Nov 21 17:19:35 2024 -0800
formatting deleteModel
---
exo/tinychat/index.js | 78 +++++++++++++++++++++++++--------------------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/exo/tinychat/index.js b/exo/tinychat/index.js
index 64f3d1a0..6792923f 100644
--- a/exo/tinychat/index.js
+++ b/exo/tinychat/index.js
@@ -437,51 +437,51 @@ document.addEventListener("alpine:init", () => {
},
async deleteModel(modelName, model) {
- const downloadedSize = model.total_downloaded || 0;
- const sizeMessage = downloadedSize > 0 ?
- `This will free up ${this.formatBytes(downloadedSize)} of space.` :
- 'This will remove any partially downloaded files.';
-
- if (!confirm(`Are you sure you want to delete ${model.name}? ${sizeMessage}`)) {
- return;
- }
+ const downloadedSize = model.total_downloaded || 0;
+ const sizeMessage = downloadedSize > 0 ?
+ `This will free up ${this.formatBytes(downloadedSize)} of space.` :
+ 'This will remove any partially downloaded files.';
+
+ if (!confirm(`Are you sure you want to delete ${model.name}? ${sizeMessage}`)) {
+ return;
+ }
- try {
- const response = await fetch(`${window.location.origin}/models/${modelName}`, {
- method: 'DELETE',
- headers: {
- 'Content-Type': 'application/json'
- }
- });
+ try {
+ const response = await fetch(`${window.location.origin}/models/${modelName}`, {
+ method: 'DELETE',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
- const data = await response.json();
-
- if (!response.ok) {
- throw new Error(data.detail || 'Failed to delete model');
- }
+ const data = await response.json();
+
+ if (!response.ok) {
+ throw new Error(data.detail || 'Failed to delete model');
+ }
- // Update the model status in the UI
- if (this.models[modelName]) {
- this.models[modelName].downloaded = false;
- this.models[modelName].download_percentage = 0;
- this.models[modelName].total_downloaded = 0;
- }
+ // Update the model status in the UI
+ if (this.models[modelName]) {
+ this.models[modelName].downloaded = false;
+ this.models[modelName].download_percentage = 0;
+ this.models[modelName].total_downloaded = 0;
+ }
- // If this was the selected model, switch to a different one
- if (this.cstate.selectedModel === modelName) {
- const availableModel = Object.keys(this.models).find(key => this.models[key].downloaded);
- this.cstate.selectedModel = availableModel || 'llama-3.2-1b';
- }
+ // If this was the selected model, switch to a different one
+ if (this.cstate.selectedModel === modelName) {
+ const availableModel = Object.keys(this.models).find(key => this.models[key].downloaded);
+ this.cstate.selectedModel = availableModel || 'llama-3.2-1b';
+ }
- // Show success message
- console.log(`Model deleted successfully from: ${data.path}`);
+ // Show success message
+ console.log(`Model deleted successfully from: ${data.path}`);
- // Refresh the model list
- await this.populateSelector();
- } catch (error) {
- console.error('Error deleting model:', error);
- this.setError(error.message || 'Failed to delete model');
- }
+ // Refresh the model list
+ await this.populateSelector();
+ } catch (error) {
+ console.error('Error deleting model:', error);
+ this.setError(error.message || 'Failed to delete model');
+ }
}
}));
});
← a9838a8f formatting handle_delete_model
·
back to Exo
·
Fixed GRPC issues e3ec9eaa →