From 15fee6bef27cc0e3f6a8ed24a60be71cb57c082b Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Mon, 23 Mar 2026 22:17:28 -0400 Subject: [PATCH] feat: add button to update ollama models Adds a button to the models page to trigger an update of the local Ollama models. Refs #1014 --- src/dashboard/routes/models.py | 18 ++++++++++++++++++ src/dashboard/templates/models.html | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/dashboard/routes/models.py b/src/dashboard/routes/models.py index 040eed3..439bd47 100644 --- a/src/dashboard/routes/models.py +++ b/src/dashboard/routes/models.py @@ -5,6 +5,7 @@ to swarm agents. Inspired by OpenClaw-RL's multi-model orchestration. """ import logging +import subprocess from pathlib import Path from typing import Any @@ -59,6 +60,23 @@ class SetActiveRequest(BaseModel): # ── API endpoints ───────────────────────────────────────────────────────────── +@api_router.post("/update-ollama") +async def update_ollama_models(): + """Trigger the Ollama model update script.""" + logger.info("Ollama model update triggered") + script_path = Path(__file__).parent.parent.parent.parent / "scripts" / "update_ollama_models.py" + try: + subprocess.Popen( + ["python", str(script_path)], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + return {"message": "Ollama model update started in the background."} + except Exception as e: + logger.error(f"Failed to start Ollama model update: {e}") + raise HTTPException(status_code=500, detail="Failed to start model update script.") from e + + @api_router.get("") async def list_models(role: str | None = None) -> dict[str, Any]: """List all registered custom models.""" diff --git a/src/dashboard/templates/models.html b/src/dashboard/templates/models.html index 47ccea3..ff73a40 100644 --- a/src/dashboard/templates/models.html +++ b/src/dashboard/templates/models.html @@ -53,7 +53,12 @@
-

Registered Models

+
+

Registered Models

+ +
{% if models %}