mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 06:32:12 -03:00
feat(misc): add VAE and Upscaler model management page
This commit is contained in:
@@ -9,7 +9,8 @@ import { state } from '../state/index.js';
|
||||
export const MODEL_TYPES = {
|
||||
LORA: 'loras',
|
||||
CHECKPOINT: 'checkpoints',
|
||||
EMBEDDING: 'embeddings' // Future model type
|
||||
EMBEDDING: 'embeddings',
|
||||
MISC: 'misc'
|
||||
};
|
||||
|
||||
// Base API configuration for each model type
|
||||
@@ -40,6 +41,15 @@ export const MODEL_CONFIG = {
|
||||
supportsBulkOperations: true,
|
||||
supportsMove: true,
|
||||
templateName: 'embeddings.html'
|
||||
},
|
||||
[MODEL_TYPES.MISC]: {
|
||||
displayName: 'Misc',
|
||||
singularName: 'misc',
|
||||
defaultPageSize: 100,
|
||||
supportsLetterFilter: false,
|
||||
supportsBulkOperations: true,
|
||||
supportsMove: true,
|
||||
templateName: 'misc.html'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -133,6 +143,11 @@ export const MODEL_SPECIFIC_ENDPOINTS = {
|
||||
},
|
||||
[MODEL_TYPES.EMBEDDING]: {
|
||||
metadata: `/api/lm/${MODEL_TYPES.EMBEDDING}/metadata`,
|
||||
},
|
||||
[MODEL_TYPES.MISC]: {
|
||||
metadata: `/api/lm/${MODEL_TYPES.MISC}/metadata`,
|
||||
vae_roots: `/api/lm/${MODEL_TYPES.MISC}/vae_roots`,
|
||||
upscaler_roots: `/api/lm/${MODEL_TYPES.MISC}/upscaler_roots`,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
62
static/js/api/miscApi.js
Normal file
62
static/js/api/miscApi.js
Normal file
@@ -0,0 +1,62 @@
|
||||
import { BaseModelApiClient } from './baseModelApi.js';
|
||||
import { getSessionItem } from '../utils/storageHelpers.js';
|
||||
|
||||
export class MiscApiClient extends BaseModelApiClient {
|
||||
_addModelSpecificParams(params, pageState) {
|
||||
const filterMiscHash = getSessionItem('recipe_to_misc_filterHash');
|
||||
const filterMiscHashes = getSessionItem('recipe_to_misc_filterHashes');
|
||||
|
||||
if (filterMiscHash) {
|
||||
params.append('misc_hash', filterMiscHash);
|
||||
} else if (filterMiscHashes) {
|
||||
try {
|
||||
if (Array.isArray(filterMiscHashes) && filterMiscHashes.length > 0) {
|
||||
params.append('misc_hashes', filterMiscHashes.join(','));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error parsing misc hashes from session storage:', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (pageState.subType) {
|
||||
params.append('sub_type', pageState.subType);
|
||||
}
|
||||
}
|
||||
|
||||
async getMiscInfo(filePath) {
|
||||
try {
|
||||
const response = await fetch(this.apiConfig.endpoints.specific.info, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ file_path: filePath })
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to fetch misc info');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching misc info:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getVaeRoots() {
|
||||
try {
|
||||
const response = await fetch(this.apiConfig.endpoints.specific.vae_roots, { method: 'GET' });
|
||||
if (!response.ok) throw new Error('Failed to fetch VAE roots');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching VAE roots:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getUpscalerRoots() {
|
||||
try {
|
||||
const response = await fetch(this.apiConfig.endpoints.specific.upscaler_roots, { method: 'GET' });
|
||||
if (!response.ok) throw new Error('Failed to fetch upscaler roots');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching upscaler roots:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { LoraApiClient } from './loraApi.js';
|
||||
import { CheckpointApiClient } from './checkpointApi.js';
|
||||
import { EmbeddingApiClient } from './embeddingApi.js';
|
||||
import { MiscApiClient } from './miscApi.js';
|
||||
import { MODEL_TYPES, isValidModelType } from './apiConfig.js';
|
||||
import { state } from '../state/index.js';
|
||||
|
||||
@@ -12,6 +13,8 @@ export function createModelApiClient(modelType) {
|
||||
return new CheckpointApiClient(MODEL_TYPES.CHECKPOINT);
|
||||
case MODEL_TYPES.EMBEDDING:
|
||||
return new EmbeddingApiClient(MODEL_TYPES.EMBEDDING);
|
||||
case MODEL_TYPES.MISC:
|
||||
return new MiscApiClient(MODEL_TYPES.MISC);
|
||||
default:
|
||||
throw new Error(`Unsupported model type: ${modelType}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user