Initial commit: a0_software_orchestrator v1.0
- Auto-Registration-Bug behoben (register_project/get_project_id/resolve_project Trennung) - 25 Tests gruen (Pytest) - block_compactor-Tool refactored (Option B: Soft-Check statt Hard-Block) - 4 Restbaustellen gefixt - DB-Schema: plugin_settings-Tabelle hinzugefuegt - 3 Schattenprojekte aus DB geloescht - Plan v3 + Refactor-Plan + Worklog dokumentiert
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""API: Save model routing configuration."""
|
||||
from helpers.api import ApiHandler, Request, Response
|
||||
import yaml
|
||||
import os
|
||||
|
||||
class ModelRoutingSave(ApiHandler):
|
||||
async def process(self, input: dict, request: Request) -> dict | Response:
|
||||
role = input.get("role", "")
|
||||
preset = input.get("preset", "")
|
||||
project_name = input.get("project_name", "")
|
||||
agent_profile = input.get("agent_profile", "")
|
||||
|
||||
if not role or not preset:
|
||||
return {"ok": False, "error": "role and preset are required"}
|
||||
|
||||
# Update default_config.yaml or per-project config
|
||||
plugin_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
config_path = os.path.join(plugin_dir, "default_config.yaml")
|
||||
|
||||
try:
|
||||
with open(config_path, "r") as f:
|
||||
config = yaml.safe_load(f) or {}
|
||||
except Exception:
|
||||
config = {}
|
||||
|
||||
routing = config.get("model_routing", {})
|
||||
roles = routing.get("roles", {})
|
||||
if role not in roles:
|
||||
roles[role] = {}
|
||||
roles[role]["preset"] = preset
|
||||
routing["roles"] = roles
|
||||
config["model_routing"] = routing
|
||||
|
||||
try:
|
||||
with open(config_path, "w") as f:
|
||||
yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
|
||||
return {"ok": True, "role": role, "preset": preset}
|
||||
except Exception as e:
|
||||
return {"ok": False, "error": str(e)}
|
||||
Reference in New Issue
Block a user