diff --git a/app/modules/ai.py b/app/modules/ai.py index df0e0aa..e0857f4 100644 --- a/app/modules/ai.py +++ b/app/modules/ai.py @@ -23,20 +23,26 @@ async def ollama_client(url: str) -> AsyncClient: class AIModule(niobot.Module): bot: "TortoiseIntegratedBot" + log = logging.getLogger(__name__) async def find_server(self, gpu_only: bool = True) -> dict[str, str | bool] | None: for name, cfg in self.bot.cfg["ollama"].items(): url = cfg["url"] gpu = cfg["gpu"] if gpu_only and not gpu: + self.log.info("Skipping %r, need GPU.", name) continue async with ollama_client(url) as client: try: + self.log.info("Trying %r", name) await client.ps() except (httpx.HTTPError, ConnectionError): + self.log.warning("%r is offline, trying next.", name) continue else: + self.log.info("%r is online.") return {"name": name, **cfg} + self.log.warning("No suitable ollama server is online.") @staticmethod def read_users():