diff --git a/README.md b/README.md index af80fdb..bfc7c01 100644 --- a/README.md +++ b/README.md @@ -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://:11434`. For host access on Linux Docker, add this to the Hermes service when needed: diff --git a/dashboard/manifest.json b/dashboard/manifest.json index d6396f5..c5a9759 100644 --- a/dashboard/manifest.json +++ b/dashboard/manifest.json @@ -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", diff --git a/dashboard/plugin_api.py b/dashboard/plugin_api.py index d45318a..1c79524 100644 --- a/dashboard/plugin_api.py +++ b/dashboard/plugin_api.py @@ -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", []) diff --git a/plugin.yaml b/plugin.yaml index 62c449a..dd8a106 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -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: diff --git a/scripts/install_ollama.sh b/scripts/install_ollama.sh index e01f35d..6495f71 100755 --- a/scripts/install_ollama.sh +++ b/scripts/install_ollama.sh @@ -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