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:
+6
-2
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user