feat: support physical and Docker Ollama runtimes

This commit is contained in:
Hermes Agent
2026-08-24 20:22:22 +10:00
parent 9f2be5b368
commit 7def2990ce
5 changed files with 95 additions and 5 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
"label": "Ollama Models",
"description": "Inspect, manage, and chat with local Ollama models, including shared persistent conversations, performance metrics, images, PDFs, URLs, and live memory telemetry.",
"icon": "Cpu",
"version": "1.5.2",
"version": "1.5.3",
"tab": {"path": "/ollama-manager", "position": "after:models"},
"entry": "dist/index.js",
"css": "dist/style.css",
+28 -2
View File
@@ -31,7 +31,20 @@ from pydantic import BaseModel, Field
from hermes_constants import get_hermes_home
router = APIRouter()
LOCAL_OLLAMA = os.environ.get("OLLAMA_HOST", "http://localhost:11434").rstrip("/")
def _running_in_container() -> bool:
return Path("/.dockerenv").exists() or Path("/run/.containerenv").exists()
def _ollama_base_url() -> str:
configured = os.environ.get("OLLAMA_HOST", "").strip()
if configured:
return configured.rstrip("/")
return "http://ollama:11434" if _running_in_container() else "http://localhost:11434"
LOCAL_OLLAMA = _ollama_base_url()
REMOTE_OLLAMA = "https://ollama.com"
CATALOG_FILE = "catalog.json"
MODEL_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:/-]{0,190}$")
@@ -1396,8 +1409,21 @@ def status() -> dict[str, Any]:
variants.append(variant)
row["variants"] = sorted(variants, key=lambda item: (item.get("size_bytes") or 0, item["name"]))
ollama_version = _ollama_version()
return {
"ollama": {"available": bool(tags or ps_rows), "version": _ollama_version(), "endpoint": LOCAL_OLLAMA},
"ollama": {
"available": bool(tags or ps_rows or ollama_version),
"version": ollama_version,
"endpoint": LOCAL_OLLAMA,
"containerized": _running_in_container(),
"configured_endpoint": bool(os.environ.get("OLLAMA_HOST", "").strip()),
"connection_hint": (
"Set OLLAMA_HOST to a reachable Ollama service, such as "
"http://ollama:11434 or http://host.docker.internal:11434."
if _running_in_container() and not (tags or ps_rows or ollama_version)
else ""
),
},
"models": local,
"popular": popular,
"popular_filter": {