diff --git a/backend/provider_settings.py b/backend/provider_settings.py index 7bb994f..0c875c6 100644 --- a/backend/provider_settings.py +++ b/backend/provider_settings.py @@ -104,14 +104,19 @@ def seed_provider_settings(conn) -> None: def seed_llm_profiles(conn) -> None: """Named presets. Existing rows are not overwritten. Keys never stored.""" - ollama = conn.execute("SELECT id FROM llm_profiles WHERE id = ?", (OLLAMA_LAN_ID,)).fetchone() + ollama = conn.execute("SELECT * FROM llm_profiles WHERE id = ?", (OLLAMA_LAN_ID,)).fetchone() if not ollama: conn.execute( """ INSERT INTO llm_profiles (id, title, name, url, model, zdr, no_train) VALUES (?, ?, ?, ?, ?, 1, 1) """, - (OLLAMA_LAN_ID, "Ollama (LAN)", "ollama", OLLAMA_LAN_URL, ""), + (OLLAMA_LAN_ID, "Ollama (LAN)", "ollama", OLLAMA_LAN_URL, "phi3:mini"), + ) + elif not (dict(ollama).get("model") or "").strip(): + conn.execute( + "UPDATE llm_profiles SET model = ?, updated = datetime('now') WHERE id = ?", + ("phi3:mini", OLLAMA_LAN_ID), ) for role in ROLES: row = conn.execute("SELECT * FROM provider_settings WHERE role = ?", (role,)).fetchone() diff --git a/frontend/src/pages/AdminProvidersPage.jsx b/frontend/src/pages/AdminProvidersPage.jsx index b28362d..19d65ff 100644 --- a/frontend/src/pages/AdminProvidersPage.jsx +++ b/frontend/src/pages/AdminProvidersPage.jsx @@ -113,8 +113,29 @@ export default function AdminProvidersPage() { } const applyRole = async (role, profileId) => { + const profile = profiles.find((item) => item.id === profileId) + if (!profile) return setError('') setNotice('') + setForms((prev) => ({ + ...prev, + [role]: { + ...(prev[role] || emptyRole()), + role, + name: profile.name || '', + url: profile.url || '', + model: profile.model || '', + zdr: Boolean(profile.zdr), + no_train: Boolean(profile.no_train), + profile_id: profile.id, + key: '', + saveAsTitle: '' + } + })) + if (!profile.model) { + setError('Das Profil braucht ein Modell, bevor es einer Stufe zugeordnet werden kann.') + return + } setSaving(`activate-${role}`) try { const payload = await api(`/api/admin/providers/${role}/activate`, { @@ -123,7 +144,7 @@ export default function AdminProvidersPage() { body: { profile_id: profileId } }) applyPayload(payload) - setNotice(`${role === 'detect' ? 'Maskierung' : 'Sprachmodell'}: Profil übernommen.`) + setNotice(`${role === 'detect' ? 'Maskierung' : 'Sprachmodell'}: ${profile.title} ist aktiv.`) } catch (err) { setError(err.message) } finally { @@ -226,21 +247,21 @@ export default function AdminProvidersPage() { <> {data.roles.map((role) => { const form = forms[role.role] || emptyRole() + const selected = profiles.find((item) => item.id === form.profile_id) + const view = selected + ? { ...role, ...form, local: selected.local, ready: selected.local ? Boolean(form.url && form.model) : role.ready } + : role return ( -