Use browser download in missing model dialog (#1362)

* Remove custom backend download logic

* Add download hooks

* Download button

* Use browser download

* Update test
This commit is contained in:
Chenlei Hu
2024-10-29 14:07:16 -04:00
committed by GitHub
parent 1f91a88d7b
commit 8dddffe840
10 changed files with 118 additions and 293 deletions

View File

@@ -1,6 +1,5 @@
import type { ComfyWorkflowJSON } from '@/types/comfyWorkflow'
import {
type DownloadModelStatus,
type HistoryTaskItem,
type PendingTaskItem,
type RunningTaskItem,
@@ -240,11 +239,6 @@ class ComfyApi extends EventTarget {
new CustomEvent('execution_cached', { detail: msg.data })
)
break
case 'download_progress':
this.dispatchEvent(
new CustomEvent('download_progress', { detail: msg.data })
)
break
default:
if (this.#registered.has(msg.type)) {
this.dispatchEvent(
@@ -413,36 +407,6 @@ class ComfyApi extends EventTarget {
}
}
/**
* Tells the server to download a model from the specified URL to the specified directory and filename
* @param {string} url The URL to download the model from
* @param {string} model_directory The main directory (eg 'checkpoints') to save the model to
* @param {string} model_filename The filename to save the model as
* @param {number} progress_interval The interval in seconds at which to report download progress (via 'download_progress' event)
*/
async internalDownloadModel(
url: string,
model_directory: string,
model_filename: string,
progress_interval: number,
folder_path: string
): Promise<DownloadModelStatus> {
const res = await this.fetchApi('/internal/models/download', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
url,
model_directory,
model_filename,
progress_interval,
folder_path
})
})
return await res.json()
}
/**
* Loads a list of items (queue or history)
* @param {string} type The type of items to load, queue or history