check if ollama is online
This commit is contained in:
@@ -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'):
|
||||
|
||||
Reference in New Issue
Block a user