fix(library-desk): reduce ollama health check to single API call
Previously called /api/tags twice (once for server check, once for model check). Now reuses response from single call. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -298,13 +298,22 @@ class OllamaClient:
|
|||||||
True if healthy, False otherwise
|
True if healthy, False otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Check server is up
|
# Check server is up and get models in one call
|
||||||
response = await self.client.get(self.tags_url, timeout=5.0)
|
response = await self.client.get(self.tags_url, timeout=5.0)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
models = data.get("models", [])
|
||||||
|
|
||||||
# Check model is available
|
# Check model is available
|
||||||
models_available = await self.check_model_available()
|
check_model = self.model
|
||||||
if not models_available:
|
model_found = False
|
||||||
|
for m in models:
|
||||||
|
name = m.get("name", "")
|
||||||
|
if name == check_model or name.startswith(f"{check_model}:"):
|
||||||
|
model_found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not model_found:
|
||||||
logger.warning(f"Model '{self.model}' not found in Ollama")
|
logger.warning(f"Model '{self.model}' not found in Ollama")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user