agent-zero/plugins/_model_config/hooks.py
frdel 15a2b553be Unify global model presets
Make model presets a single global collection and treat presets as reusable setups (main, utility, embedding). Persisted scope configs now store only a preset name (Default is always present and immutable); project-scoped preset definitions were removed and attempts to edit/reset project presets are rejected. Add embedding-model support throughout: include embedding slot in presets, surface embedding in the switcher and override APIs, and notify extensions when the effective embedding model changes. Implement rename/retire propagation to update plugin configs, saved chats, and live AgentContext objects when preset names change or presets are removed. Update CLI/integration commands to use an "inherit" action for returning to the scoped preset and to report the effective scoped-or-chat preset. Add startup migration/bootstrap to initialize presets from remote or bundled fallback and numerous docs/UI text updates to reflect the new preset model. Extra: refactor config resolution helpers and add safety checks (validation, atomic writes) when saving presets.
2026-07-17 12:16:10 +02:00

23 lines
764 B
Python

from plugins._model_config.helpers import model_config
def get_plugin_config(default=None, **kwargs):
"""Expose the legacy complete config shape to runtime callers."""
return model_config.resolve_config_settings(default)
def save_plugin_config(result=None, settings=None, **kwargs):
"""Persist only the scoped preset selection."""
raw = settings if isinstance(settings, dict) else {}
name = str(
raw.get(model_config.MODEL_PRESET_CONFIG_KEY)
or model_config.DEFAULT_PRESET_NAME
).strip()
preset = model_config.resolve_preset(name)
return {
model_config.MODEL_PRESET_CONFIG_KEY: (
str(preset.get("name"))
if preset
else model_config.DEFAULT_PRESET_NAME
)
}