Reload Ollama models on URL change, pre-select current model

- /api/ollama-models accepts optional url query param to query a different endpoint
- Frontend fetches models on load and on Ollama URL blur
- Keeps current model selected if available, otherwise selects first in list
- Shows loading indicator while fetching
This commit is contained in:
Oliver Hofmann
2026-04-28 09:07:53 +02:00
parent f22bad6496
commit 94368670b7
2 changed files with 34 additions and 7 deletions
+6 -2
View File
@@ -112,8 +112,12 @@ async def update_settings(
return settings
@app.get("/api/ollama-models")
async def get_ollama_models(db: Session = Depends(get_db), _ = Depends(require_admin_auth)):
ollama_url = crud.get_setting(db, "ollama_url", "http://localhost:11434")
async def get_ollama_models(
url: str = None,
db: Session = Depends(get_db),
_ = Depends(require_admin_auth),
):
ollama_url = url or crud.get_setting(db, "ollama_url", "http://localhost:11434")
try:
async with httpx.AsyncClient(timeout=5.0) as client:
response = await client.get(f"{ollama_url}/api/tags")