check if ollama is online
This commit is contained in:
@@ -21,16 +21,24 @@ class OllamaManagerPage(AsyncColumn):
|
||||
with self:
|
||||
ui.label('Ollama Manager').classes('text-h4 font-bold')
|
||||
|
||||
ollama_status, ollama_version = await ollama.status()
|
||||
|
||||
# Status cards
|
||||
with ui.row().classes('w-full gap-4'):
|
||||
with ui.card().classes('flex-grow'):
|
||||
with ui.row().classes('items-center gap-2'):
|
||||
ui.icon('check_circle').props('color=positive')
|
||||
if ollama_status:
|
||||
ui.icon('check_circle').props(f'color=positive')
|
||||
ui.label('Ollama Status: Online').classes('font-medium')
|
||||
else:
|
||||
ui.icon('radio_button_unchecked').props(f'color=negative')
|
||||
ui.label('Ollama Status: Offline').classes('font-medium')
|
||||
|
||||
with ui.card().classes('flex-grow'):
|
||||
ui.label('Version: 0.11.11').classes('font-medium')
|
||||
ui.label(f'Version: {ollama_version}').classes('font-medium')
|
||||
|
||||
if ollama_status is False:
|
||||
return
|
||||
# Models management
|
||||
with ui.card().classes('w-full'):
|
||||
with ui.row().classes('w-full items-center mb-4'):
|
||||
|
||||
@@ -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