mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-10 10:00:08 +00:00
Model downloader dialog (#569)
* API core for model downloader * initial basic dialog for missing models * app.ts handling for missing models * don't explode if getModels is a 404 * actually track downloads in progress * overall pile of improvements to the missing models view * minor fixes * add setting to disable missing models warning * temporarily remove 'models' entry from default graph to avoid missing model dialog causing issues. Also because ckpt autodownloading shouldn't be allowed * swap the url to a title * add model directory to display * match settingStore commit * check setting before scanning models list ie avoid redundant calcs when setting is disabled anyway
This commit is contained in:
committed by
GitHub
parent
57c5a78af3
commit
af378262f4
@@ -1,5 +1,6 @@
|
||||
import { ComfyWorkflowJSON } from '@/types/comfyWorkflow'
|
||||
import {
|
||||
DownloadModelStatus,
|
||||
HistoryTaskItem,
|
||||
PendingTaskItem,
|
||||
RunningTaskItem,
|
||||
@@ -216,6 +217,11 @@ 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(
|
||||
@@ -319,6 +325,47 @@ class ComfyApi extends EventTarget {
|
||||
return await res.json()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of models in the specified folder
|
||||
* @param {string} folder The folder to list models from, such as 'checkpoints'
|
||||
* @returns The list of model filenames within the specified folder
|
||||
*/
|
||||
async getModels(folder: string) {
|
||||
const res = await this.fetchApi(`/models/${folder}`)
|
||||
if (res.status === 404) {
|
||||
return null
|
||||
}
|
||||
return await res.json()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
): 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
|
||||
})
|
||||
})
|
||||
return await res.json()
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a list of items (queue or history)
|
||||
* @param {string} type The type of items to load, queue or history
|
||||
|
||||
Reference in New Issue
Block a user