"""Small checkpoint-level capability guards layered over architecture YAML.""" from __future__ import annotations _EDIT_ONLY_CHAINS = { "qwen_image_edit", "boogu_image_edit", "reference_image", # Mage-Flow edit checkpoints } def supports_chain_for_model(model_name: str, chain_name: str) -> bool: """Return whether a concrete checkpoint is known to support a chain. Most capabilities apply to every checkpoint of an architecture. Qwen, Boogu, and Mage-Flow register generation and edit checkpoints together, so their reference injectors require the concrete Edit variant. """ if chain_name in _EDIT_ONLY_CHAINS: return "edit" in str(model_name).casefold() return True def enabled_chains_for_model(model_name: str) -> list[str]: """以具体 checkpoint 为准,供界面、计划与 API 共用。""" from core.settings import ARCHITECTURES_CONFIG, FEATURES_CONFIG, MODEL_TYPE_MAP architecture = MODEL_TYPE_MAP.get(model_name, "SDXL") model_type = ARCHITECTURES_CONFIG.get("architectures", {}).get( architecture, {} ).get("model_type", architecture.lower().replace(" ", "").replace(".", "")) return [ chain for chain in FEATURES_CONFIG.get(model_type, {}).get("enabled_chains", []) if supports_chain_for_model(model_name, chain) ]