fix(agent): add missing ping() to OllamaBackend and OdooClient
Health endpoint called .ping() on both but neither implemented it, causing ollama/odoo to always show as error and the bot to stay offline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -62,5 +62,16 @@ class OllamaBackend:
|
|||||||
finally:
|
finally:
|
||||||
self._active -= 1
|
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
|
@property
|
||||||
def active_count(self): return self._active
|
def active_count(self): return self._active
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ class OdooClient:
|
|||||||
self._models = xmlrpc.client.ServerProxy(
|
self._models = xmlrpc.client.ServerProxy(
|
||||||
f'{self._url}/xmlrpc/2/object', transport=transport, allow_none=True)
|
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):
|
async def connect(self):
|
||||||
await self._authenticate()
|
await self._authenticate()
|
||||||
if self._pg_dsn:
|
if self._pg_dsn:
|
||||||
|
|||||||
Reference in New Issue
Block a user