| 1 | from plugins._model_config.helpers import model_config |
| 2 | |
| 3 | |
| 4 | def get_plugin_config(default=None, **kwargs): |
| 5 | """Expose the legacy complete config shape to runtime callers.""" |
| 6 | return model_config.resolve_config_settings(default) |
| 7 | |
| 8 | |
| 9 | def save_plugin_config(result=None, settings=None, **kwargs): |
| 10 | """Persist only the scoped preset selection.""" |
| 11 | raw = settings if isinstance(settings, dict) else {} |
| 12 | name = str( |
| 13 | raw.get(model_config.MODEL_PRESET_CONFIG_KEY) |
| 14 | or model_config.DEFAULT_PRESET_NAME |
| 15 | ).strip() |
| 16 | preset = model_config.resolve_preset(name) |
| 17 | return { |
| 18 | model_config.MODEL_PRESET_CONFIG_KEY: ( |
| 19 | str(preset.get("name")) |
| 20 | if preset |
| 21 | else model_config.DEFAULT_PRESET_NAME |
| 22 | ) |
| 23 | } |