Optimize model library (#1739)

* Adapt experiment models api

* Add model preview
This commit is contained in:
Hayden
2024-12-17 07:27:30 +08:00
committed by GitHub
parent 601b739f75
commit 5b72fc7fdc
4 changed files with 44 additions and 21 deletions

View File

@@ -481,8 +481,8 @@ export class ComfyApi extends EventTarget {
* Gets a list of model folder keys (eg ['checkpoints', 'loras', ...])
* @returns The list of model folder keys
*/
async getModelFolders(): Promise<string[]> {
const res = await this.fetchApi(`/models`)
async getModelFolders(): Promise<{ name: string; folders: string[] }[]> {
const res = await this.fetchApi(`/experiment/models`)
if (res.status === 404) {
return []
}
@@ -497,8 +497,10 @@ export class ComfyApi extends EventTarget {
* @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): Promise<string[]> {
const res = await this.fetchApi(`/models/${folder}`)
async getModels(
folder: string
): Promise<{ name: string; pathIndex: number }[]> {
const res = await this.fetchApi(`/experiment/models/${folder}`)
if (res.status === 404) {
return []
}