check if ollama is online

This commit is contained in:
2025-09-18 03:57:19 +02:00
parent 8c6f070ea1
commit 590af9407c
2 changed files with 26 additions and 3 deletions

View File

@@ -1,5 +1,20 @@
import httpx
from nicegui import ui
from typing import Tuple
async def status(url='http://127.0.0.1:11434') -> Tuple[bool, str]:
async with httpx.AsyncClient() as client:
try:
response = await client.get(f"{url}/api/version")
response.raise_for_status()
return True, response.json()["version"]
except httpx.RequestError as exc:
print(exc)
return False, 'Unknown'
except httpx.HTTPStatusError as exc:
print(exc)
return False, 'Unknown'
async def available_models(url='http://127.0.0.1:11434'):