fix: discover Ollama on Docker host
This commit is contained in:
@@ -62,7 +62,7 @@ In Hermes Dashboard, open **Plugins**, choose **Install from repository**, enter
|
||||
The plugin supports both deployment types:
|
||||
|
||||
- **Physical/Linux Hermes:** Ollama defaults to `http://localhost:11434`. If Ollama is missing, the prerequisite installer can install it on a root-run host.
|
||||
- **Docker Hermes:** Ollama should normally run as a separate service or on the Docker host. The plugin does not install Ollama inside the Hermes container. Set `OLLAMA_HOST` to the reachable Ollama base URL, without `/v1`, for example `http://ollama:11434` for a Compose service or `http://host.docker.internal:11434` for a host service.
|
||||
- **Docker Hermes:** Ollama should normally run as a separate service or on the Docker host. The plugin does not install Ollama inside the Hermes container. It first probes `http://ollama:11434` and then `http://host.docker.internal:11434`. Set `OLLAMA_HOST` to the reachable Ollama base URL, without `/v1`, for example `http://ollama:11434`, `http://host.docker.internal:11434`, or the host address shown by your installation, such as `http://<host-ip>:11434`.
|
||||
|
||||
For host access on Linux Docker, add this to the Hermes service when needed:
|
||||
|
||||
|
||||
@@ -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", [])
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name: ollama-manager
|
||||
version: 1.5.3
|
||||
version: 1.5.4
|
||||
description: Native dashboard manager and chat interface for local Ollama models, attachments, URLs, shared persistent conversations, performance metrics, and live runtime telemetry.
|
||||
auto_install_dependencies: true
|
||||
python_dependencies:
|
||||
|
||||
@@ -14,19 +14,24 @@ is_container() {
|
||||
[[ -f /run/.containerenv ]]
|
||||
}
|
||||
|
||||
ollama_endpoint() {
|
||||
ollama_endpoints() {
|
||||
if [[ -n "${OLLAMA_HOST:-}" ]]; then
|
||||
printf '%s' "${OLLAMA_HOST%/}"
|
||||
printf '%s\n' "${OLLAMA_HOST%/}"
|
||||
elif is_container; then
|
||||
printf '%s' 'http://ollama:11434'
|
||||
printf '%s\n' 'http://ollama:11434' 'http://host.docker.internal:11434'
|
||||
else
|
||||
printf '%s' 'http://localhost:11434'
|
||||
printf '%s\n' 'http://localhost:11434'
|
||||
fi
|
||||
}
|
||||
|
||||
check_endpoint() {
|
||||
command -v curl >/dev/null 2>&1 || return 1
|
||||
curl --fail --silent --show-error --max-time 5 "$(ollama_endpoint)/api/version" >/dev/null
|
||||
while IFS= read -r endpoint; do
|
||||
if curl --fail --silent --show-error --max-time 5 "${endpoint}/api/version" >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
done < <(ollama_endpoints)
|
||||
return 1
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "--check" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user