Fix 'default' model selection breaking readiness indicator
When a user selected the 'Default' option in Settings, the dropdown sent an empty string "" to the backend. The route saved it as a DB row, which caused get_setting() to return "" instead of falling back to Config defaults. The chat status endpoint then tried to match "" against installed model names — always failing — resulting in model: "not_found" and a permanently failing readiness indicator. services/settings.py: - Add delete_setting() helper: removes a setting row so get_setting() correctly falls back to its hardcoded default argument routes/settings.py: - Import delete_setting - When default_model or intent_model are saved as empty string, delete the DB row instead of storing "" — cleanly restores Config fallback routes/chat.py: - chat_status_route: add explicit `or Config.OLLAMA_MODEL` guard for any existing "" rows written before this fix (migration safety net) - send_message and summarize routes: same guard on model resolution so empty settings never cause silent generation failures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from fabledassistant.auth import login_required, get_current_user_id
|
||||
from fabledassistant.config import Config
|
||||
from fabledassistant.services.caldav import CALDAV_SETTING_KEYS, get_caldav_config, test_connection
|
||||
from fabledassistant.services.llm import get_installed_models
|
||||
from fabledassistant.services.settings import get_all_settings, set_settings_batch
|
||||
from fabledassistant.services.settings import delete_setting, get_all_settings, set_settings_batch
|
||||
|
||||
settings_bp = Blueprint("settings", __name__, url_prefix="/api/settings")
|
||||
|
||||
@@ -33,7 +33,20 @@ async def update_settings_route():
|
||||
if installed and model not in installed:
|
||||
return jsonify({"error": f"Model '{model}' is not installed"}), 400
|
||||
|
||||
await set_settings_batch(uid, {k: str(v) for k, v in data.items()})
|
||||
# Empty string for model keys means "reset to system default".
|
||||
# Delete the DB row so get_setting() falls back to Config defaults
|
||||
# rather than returning "" and breaking model resolution everywhere.
|
||||
_MODEL_KEYS = frozenset({"default_model", "intent_model"})
|
||||
to_save = {}
|
||||
for k, v in data.items():
|
||||
str_v = str(v)
|
||||
if k in _MODEL_KEYS and not str_v:
|
||||
await delete_setting(uid, k)
|
||||
else:
|
||||
to_save[k] = str_v
|
||||
|
||||
if to_save:
|
||||
await set_settings_batch(uid, to_save)
|
||||
settings = await get_all_settings(uid)
|
||||
return jsonify(settings)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user