download-models, show actionable error message when Ollama is not running
This commit is contained in:
parent
356e9f040d
commit
08a4252c33
2 changed files with 33 additions and 26 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Added `cachetools` as an explicit dependency (was only available transitively, causing `ModuleNotFoundError` for some installations)
|
- Added `cachetools` as an explicit dependency (was only available transitively, causing `ModuleNotFoundError` for some installations)
|
||||||
|
- **download-models**: Show actionable error message when Ollama is not running instead of cryptic "All connection attempts failed" (#277)
|
||||||
|
|
||||||
## [0.30.1] - 2026-02-17
|
## [0.30.1] - 2026-02-17
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1846,35 +1846,41 @@ class HaikuRAG:
|
||||||
|
|
||||||
base_url = self._config.providers.ollama.base_url
|
base_url = self._config.providers.ollama.base_url
|
||||||
|
|
||||||
async with httpx.AsyncClient(timeout=None) as client:
|
try:
|
||||||
for model in sorted(required_models):
|
async with httpx.AsyncClient(timeout=None) as client:
|
||||||
yield DownloadProgress(model=model, status="pulling")
|
for model in sorted(required_models):
|
||||||
|
yield DownloadProgress(model=model, status="pulling")
|
||||||
|
|
||||||
async with client.stream(
|
async with client.stream(
|
||||||
"POST", f"{base_url}/api/pull", json={"model": model}
|
"POST", f"{base_url}/api/pull", json={"model": model}
|
||||||
) as r:
|
) as r:
|
||||||
async for line in r.aiter_lines():
|
async for line in r.aiter_lines():
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
data = json.loads(line)
|
data = json.loads(line)
|
||||||
status = data.get("status", "")
|
status = data.get("status", "")
|
||||||
digest = data.get("digest", "")
|
digest = data.get("digest", "")
|
||||||
|
|
||||||
if digest and "total" in data:
|
if digest and "total" in data:
|
||||||
yield DownloadProgress(
|
yield DownloadProgress(
|
||||||
model=model,
|
model=model,
|
||||||
status="downloading",
|
status="downloading",
|
||||||
total=data.get("total", 0),
|
total=data.get("total", 0),
|
||||||
completed=data.get("completed", 0),
|
completed=data.get("completed", 0),
|
||||||
digest=digest,
|
digest=digest,
|
||||||
)
|
)
|
||||||
elif status:
|
elif status:
|
||||||
yield DownloadProgress(model=model, status=status)
|
yield DownloadProgress(model=model, status=status)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
yield DownloadProgress(model=model, status="done")
|
yield DownloadProgress(model=model, status="done")
|
||||||
|
except httpx.ConnectError:
|
||||||
|
raise ConnectionError(
|
||||||
|
f"Cannot connect to Ollama at {base_url}. "
|
||||||
|
"Is Ollama running? Start it with 'ollama serve'."
|
||||||
|
)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the underlying store connection."""
|
"""Close the underlying store connection."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue