Unify metadata workflow cache and category handling

This commit is contained in:
Dariusz L
2026-09-13 23:09:22 +02:00
parent 21245569c7
commit 552ef683da
11 changed files with 318 additions and 111 deletions
@@ -16,6 +16,7 @@ export const CATEGORY_ALIASES = Object.freeze(
"background_removal_model": "background_removal",
"checkpoint": "checkpoints",
"checkpoints": "checkpoints",
"ckpt": "checkpoints",
"clip": "text_encoders",
"clip_gguf": "text_encoders",
"clip_vision": "clip_vision",
@@ -67,8 +68,10 @@ export const CATEGORY_ALIASES = Object.freeze(
"ultralytics_segm": "ultralytics",
"unet": "diffusion_models",
"unet_gguf": "diffusion_models",
"upscale": "upscale_models",
"upscale_model": "upscale_models",
"upscale_models": "upscale_models",
"upscalemodel": "upscale_models",
"upscaler": "upscale_models",
"vae": "vae",
"vae_approx": "vae_approx",
+17
View File
@@ -1,5 +1,22 @@
import { CATEGORY_ALIASES, normalizeCategoryToken } from './category_aliases.generated.js';
export function normalizeCategoryValue(
category = '',
{
aliases = CATEGORY_ALIASES,
defaultValue = '',
emptyValues = ['unknown', 'none', 'null'],
} = {},
) {
const token = normalizeCategoryToken(category);
const categoryAliases = aliases && typeof aliases === 'object'
? aliases
: CATEGORY_ALIASES;
const emptyTokens = new Set(emptyValues);
if (!token || emptyTokens.has(token)) return defaultValue;
return categoryAliases[token] || token;
}
export function normalizeDownloadCategoryValue(
category = '',
aliases = CATEGORY_ALIASES,