fix: discover Ollama on Docker host

This commit is contained in:
Hermes Agent
2026-08-24 20:47:46 +10:00
parent 7def2990ce
commit 3bee6ac48c
5 changed files with 28 additions and 8 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.3",
"version": "1.5.4",
"tab": {"path": "/ollama-manager", "position": "after:models"},
"entry": "dist/index.js",
"css": "dist/style.css",
+15
View File
@@ -44,6 +44,20 @@ def _ollama_base_url() -> str:
return "http://ollama:11434" if _running_in_container() else "http://localhost:11434"
def _discover_ollama_endpoint() -> None:
global LOCAL_OLLAMA
if os.environ.get("OLLAMA_HOST", "").strip() or not _running_in_container():
return
candidates = ("http://ollama:11434", "http://host.docker.internal:11434")
for candidate in candidates:
try:
_json_request(candidate + "/api/version", timeout=2)
except (HTTPError, URLError, OSError, ValueError):
continue
LOCAL_OLLAMA = candidate
return
LOCAL_OLLAMA = _ollama_base_url()
REMOTE_OLLAMA = "https://ollama.com"
CATALOG_FILE = "catalog.json"
@@ -274,6 +288,7 @@ def _valid_name(name: str) -> str:
def _local_tags() -> list[dict[str, Any]]:
_discover_ollama_endpoint()
try:
payload = _json_request(LOCAL_OLLAMA + "/api/tags", timeout=15)
models = payload.get("models", [])