The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(image_gen): derive the managed-Krea model set from the Krea plugin so the two lists cannot drift
Mariano Nicolinic13276d9df66
diff --git a/plugins/image_gen/krea/__init__.py b/plugins/image_gen/krea/__init__.pyindex 52bbf4d61e2..4fdda1cda8b 100644--- a/plugins/image_gen/krea/__init__.py+++ b/plugins/image_gen/krea/__init__.py@@ -47,6 +47,7 @@ _MODELS: Dict[str, Dict[str, Any]] = {"price": "$0.015 (text) / $0.0175 (style refs)", "path": "medium-turbo", "upscale": False,},}+KREA_MODEL_IDS = frozenset(_MODELS)DEFAULT_MODEL = "krea-2-medium"diff --git a/tools/image_generation_tool.py b/tools/image_generation_tool.pyindex 9a1ec2de019..8317de42d32 100644--- a/tools/image_generation_tool.py+++ b/tools/image_generation_tool.py@@ -662,13 +662,12 @@ def _dispatch_to_plugin_provider(# Native ``krea-2-*`` ids are served by the Krea managed gateway (managed mode only —# direct/BYO users keep their pipeline); ``fal-ai/krea/v2/*`` catalog ids stay on FAL.-_KREA_NATIVE_MODELS = {"krea-2-medium", "krea-2-large", "krea-2-medium-turbo"}--def _normalize_krea_model(model_id: Optional[str]) -> Optional[str]:"""Return the native Krea plugin model id when ``model_id`` is ``krea-2-*``."""+ from plugins.image_gen.krea import KREA_MODEL_IDS+candidate = model_id.strip() if isinstance(model_id, str) else None- return candidate if candidate in _KREA_NATIVE_MODELS else None+ return candidate if candidate in KREA_MODEL_IDS else Nonedef _maybe_route_managed_krea(