diff --git a/templates/index.html b/templates/index.html index b77c722..4f91e20 100644 --- a/templates/index.html +++ b/templates/index.html @@ -302,21 +302,42 @@ }, 60000); }); - // Provider/Model Functions (global) async function updateModelDropdown(isInitialLoad = false) { const provider = document.getElementById('ai-provider').value; const modelSelect = document.getElementById('ai-model'); + const urlContainer = document.getElementById('ollama-url-container'); + + // FIX: Zeige das URL-Feld nur an, wenn Ollama ausgewählt ist + if (provider === "ollama") { + urlContainer.style.display = "flex"; + } else { + urlContainer.style.display = "none"; + } + + modelSelect.innerHTML = ''; + try { const res = await fetch(`/api/models?provider=${provider}`); const data = await res.json(); modelSelect.innerHTML = ''; - data.models.forEach(m => { - const opt = document.createElement('option'); - opt.value = opt.textContent = m; - modelSelect.appendChild(opt); - }); - if (isInitialLoad && currentSettings[`${provider}_model`]) modelSelect.value = currentSettings[`${provider}_model`]; - } catch (e) {} + + if (data.models && data.models.length > 0) { + data.models.forEach(m => { + const opt = document.createElement('option'); + opt.value = opt.textContent = m; + modelSelect.appendChild(opt); + }); + // Setze gespeichertes Modell beim ersten Laden + if (isInitialLoad && currentSettings[`${provider}_model`]) { + modelSelect.value = currentSettings[`${provider}_model`]; + } + } else { + modelSelect.innerHTML = ''; + } + } catch (e) { + console.error("Fehler beim Laden der Modelle:", e); + modelSelect.innerHTML = ''; + } } async function saveSettings() {