diff --git a/agent_service/llm/ollama_backend.py b/agent_service/llm/ollama_backend.py index ff2f31b..c6d64eb 100644 --- a/agent_service/llm/ollama_backend.py +++ b/agent_service/llm/ollama_backend.py @@ -62,5 +62,16 @@ class OllamaBackend: finally: self._active -= 1 + async def ping(self) -> None: + """Raise if Ollama is unreachable.""" + import ollama + client = ollama.AsyncClient(host=self._url) + try: + await asyncio.wait_for(client.list(), timeout=5) + except asyncio.TimeoutError: + raise OllamaUnavailableError('Ollama ping timed out') + except Exception as exc: + raise OllamaUnavailableError(f'Ollama ping failed: {exc}') from exc + @property def active_count(self): return self._active diff --git a/agent_service/tools/odoo_client.py b/agent_service/tools/odoo_client.py index 9600061..f0d506d 100644 --- a/agent_service/tools/odoo_client.py +++ b/agent_service/tools/odoo_client.py @@ -55,6 +55,10 @@ class OdooClient: self._models = xmlrpc.client.ServerProxy( f'{self._url}/xmlrpc/2/object', transport=transport, allow_none=True) + async def ping(self) -> None: + """Raise if Odoo is unreachable.""" + await self._xmlrpc_call(self._common, 'version') + async def connect(self): await self._authenticate() if self._pg_dsn: