fix: let saved Ollama URL override environment fallback
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.5",
|
||||
"version": "1.5.6",
|
||||
"tab": {"path": "/ollama-manager", "position": "after:models"},
|
||||
"entry": "dist/index.js",
|
||||
"css": "dist/style.css",
|
||||
|
||||
@@ -305,11 +305,13 @@ def _write_connections(value: dict[str, str]) -> None:
|
||||
|
||||
def _apply_saved_connection() -> None:
|
||||
global LOCAL_OLLAMA
|
||||
if os.environ.get("OLLAMA_HOST", "").strip():
|
||||
return
|
||||
saved = _read_connections().get("active_url")
|
||||
if saved:
|
||||
LOCAL_OLLAMA = saved
|
||||
return
|
||||
configured = os.environ.get("OLLAMA_HOST", "").strip()
|
||||
if configured:
|
||||
LOCAL_OLLAMA = configured.rstrip("/")
|
||||
|
||||
|
||||
def _target_endpoint(target: str = "local") -> str:
|
||||
@@ -336,7 +338,7 @@ def _probe_endpoint(url: str, timeout: int = 5) -> dict[str, Any]:
|
||||
|
||||
def _connection_snapshot() -> list[dict[str, Any]]:
|
||||
saved = _read_connections()
|
||||
configured_local = os.environ.get("OLLAMA_HOST", "").strip() or saved.get("local_url")
|
||||
configured_local = saved.get("local_url") or os.environ.get("OLLAMA_HOST", "").strip()
|
||||
candidates: list[tuple[str, str, str]] = []
|
||||
if configured_local:
|
||||
candidates.append(("local", "Configured local endpoint", configured_local))
|
||||
@@ -1475,7 +1477,7 @@ def chat(body: ChatRequest) -> dict[str, Any]:
|
||||
@router.get("/connections")
|
||||
def connections() -> dict[str, Any]:
|
||||
saved = _read_connections()
|
||||
active = os.environ.get("OLLAMA_HOST", "").strip() or saved.get("active_url") or LOCAL_OLLAMA
|
||||
active = saved.get("active_url") or os.environ.get("OLLAMA_HOST", "").strip() or LOCAL_OLLAMA
|
||||
return {"active_url": active, "connections": _connection_snapshot(), "containerized": _running_in_container()}
|
||||
|
||||
|
||||
@@ -1494,10 +1496,10 @@ def connections_configure(body: ConnectionRequest) -> dict[str, Any]:
|
||||
raise HTTPException(400, "Connection role must be local or remote")
|
||||
saved = _read_connections()
|
||||
saved[f"{role}_url"] = url
|
||||
if role == "local" and not os.environ.get("OLLAMA_HOST", "").strip():
|
||||
if role == "local":
|
||||
saved["active_url"] = url
|
||||
_write_connections(saved)
|
||||
if role == "local" and not os.environ.get("OLLAMA_HOST", "").strip():
|
||||
if role == "local":
|
||||
global LOCAL_OLLAMA
|
||||
LOCAL_OLLAMA = url
|
||||
result = _probe_endpoint(url, timeout=8)
|
||||
|
||||
Reference in New Issue
Block a user