Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Auto-initialize settings when SettingsManager detects empty database

LearningCircuitf9414485c8df
diff --git a/src/local_deep_research/settings/manager.py b/src/local_deep_research/settings/manager.py
index d3c2759027..5d1a476ea9 100644
--- a/src/local_deep_research/settings/manager.py
+++ b/src/local_deep_research/settings/manager.py
@@ -77,6 +77,26 @@ class SettingsManager(ISettingsManager):
# Simple in-memory cache
self._cache = {}
+ # Auto-initialize settings if database is empty
+ if self.db_session:
+ self._ensure_settings_initialized()
+
+ def _ensure_settings_initialized(self):
+ """Ensure settings are initialized in the database."""
+ try:
+ # Check if we have any settings at all
+ from ..database.models import Setting
+
+ settings_count = self.db_session.query(Setting).count()
+
+ if settings_count == 0:
+ logger.info("No settings found in database, loading defaults")
+ self.load_from_defaults_file(commit=True)
+ logger.info("Default settings loaded successfully")
+ except Exception as e:
+ # Don't fail initialization if we can't check/load settings
+ logger.warning(f"Could not check/initialize settings: {e}")
+
def _check_thread_safety(self):
"""Check if this instance is being used in the same thread it was created in."""
current_thread_id = threading.get_ident()