fix: discover Ollama on Docker host
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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", [])
|
||||
|
||||
Reference in New Issue
Block a user