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.

WIP on removing old config file dependencies.

Daniel Petti2b78e1877476
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.py
index 28c6c9f1d2..32b77e0800 100644
--- a/src/local_deep_research/web/app_factory.py
+++ b/src/local_deep_research/web/app_factory.py
@@ -165,29 +165,6 @@ def register_blueprints(app):
api_bp, url_prefix="/research/api"
) # Register API blueprint with prefix
- # Configure settings paths
- # Import config inside the function to avoid circular dependencies
- def configure_settings_routes():
- try:
- from ..config.config_files import SEARCH_ENGINES_FILE, get_config_dir
- from .routes.settings_routes import set_config_paths
-
- CONFIG_DIR = get_config_dir() / "config"
- MAIN_CONFIG_FILE = CONFIG_DIR / "settings.toml"
- LOCAL_COLLECTIONS_FILE = CONFIG_DIR / "local_collections.toml"
-
- set_config_paths(
- CONFIG_DIR,
- SEARCH_ENGINES_FILE,
- MAIN_CONFIG_FILE,
- LOCAL_COLLECTIONS_FILE,
- )
- except Exception as e:
- logger.error(f"Error configuring settings routes: {e}")
-
- # Call this after all blueprints are registered
- configure_settings_routes()
-
# Add root route redirect
@app.route("/")
def root_index():
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.py
index b0fb89e5bb..d60b298983 100644
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@ -37,23 +37,6 @@ logger = logging.getLogger(__name__)
# Create a Blueprint for settings
settings_bp = Blueprint("settings", __name__, url_prefix="/research/settings")
-# Legacy config for backwards compatibility
-SEARCH_ENGINES_FILE = None
-CONFIG_DIR = None
-MAIN_CONFIG_FILE = None
-LOCAL_COLLECTIONS_FILE = None
-
-
-def set_config_paths(
- config_dir, search_engines_file, main_config_file, local_collections_file
-):
- """Set the config paths for the settings routes (legacy support)"""
- global CONFIG_DIR, SEARCH_ENGINES_FILE, MAIN_CONFIG_FILE, LOCAL_COLLECTIONS_FILE
- CONFIG_DIR = config_dir
- SEARCH_ENGINES_FILE = search_engines_file
- MAIN_CONFIG_FILE = main_config_file
- LOCAL_COLLECTIONS_FILE = local_collections_file
-
def get_db_session() -> Session:
"""Get the database session from the app context"""
@@ -925,6 +908,35 @@ def api_get_available_models():
def api_get_available_search_engines():
"""Get available search engines"""
try:
+ # Find search engines that are set in the DB.
+ db_session = get_db_session()
+ search_settings = (
+ db_session.query(Setting)
+ .filter(Setting.type == "SEARCH")
+ .filter(Setting.key.endswith(".class_name"))
+ .filter(~Setting.key.startswith("search."))
+ ).all()
+
+ # These should all correspond to different search engines.
+ engines_dict = {}
+ for setting in search_settings:
+ engine_name = setting.key.split(".")[0]
+ display_name = setting.key.replace("_", " ").title()
+ strengths = (
+ db_session.query(Setting)
+ .filter(Setting.key == f"{engine_name}.strengths")
+ .first()
+ )
+ if strengths is None:
+ # No strengths in DB.
+ strengths = []
+ else:
+ strengths = strengths.value
+
+ engines_dict[engine_name] = dict(
+ display_name=display_name, strengths=strengths
+ )
+
# First try to get engines from search_engines.toml file
engines_dict = get_engines_from_file()
diff --git a/src/local_deep_research/web/services/settings_service.py b/src/local_deep_research/web/services/settings_service.py
index 5d1f702cb7..b336d65240 100644
--- a/src/local_deep_research/web/services/settings_service.py
+++ b/src/local_deep_research/web/services/settings_service.py
@@ -1,8 +1,7 @@
import logging
-from pathlib import Path
from typing import Any, Dict, Optional, Union
-from ..database.models import Setting, SettingType
+from ..database.models import Setting
from .settings_manager import SettingsManager
# Initialize logger
@@ -55,46 +54,18 @@ def set_setting(key: str, value: Any, commit: bool = True, db_session=None) -> b
return manager.set_setting(key, value, commit)
-def get_all_settings(
- setting_type: Optional[SettingType] = None, db_session=None
-) -> Dict[str, Any]:
+def get_all_settings(db_session=None) -> Dict[str, Any]:
"""
Get all settings, optionally filtered by type
Args:
- setting_type: Optional filter by type
db_session: Optional database session
Returns:
Dict[str, Any]: Dictionary of settings
"""
manager = get_settings_manager(db_session)
- return manager.get_all_settings(setting_type)
-
-
-def get_all_settings_as_dict(db_session=None) -> Dict[str, Dict[str, Any]]:
- """
- Get all settings as a structured dictionary
-
- Args:
- db_session: Optional database session
-
- Returns:
- Dict[str, Dict[str, Any]]: Dictionary of settings grouped by type
- """
- # Get settings manager
- manager = get_settings_manager(db_session)
-
- # Get all settings
- all_settings = {}
-
- for setting_type in SettingType:
- type_key = setting_type.value.lower()
- type_settings = manager.get_all_settings(setting_type)
- if type_settings:
- all_settings[type_key] = type_settings
-
- return all_settings
+ return manager.get_all_settings()
def create_or_update_setting(
@@ -147,30 +118,6 @@ def bulk_update_settings(
return success
-def import_settings_from_file(
- main_settings_file: Union[str, Path],
- search_engines_file: Union[str, Path],
- collections_file: Union[str, Path],
- db_session=None,
-) -> bool:
- """
- Import settings from default configuration files
-
- Args:
- main_settings_file: Path to the main settings file
- search_engines_file: Path to the search engines file
- collections_file: Path to the collections file
- db_session: Optional database session
-
- Returns:
- bool: True if import was successful
- """
- manager = get_settings_manager(db_session)
- return manager.import_settings(
- main_settings_file, search_engines_file, collections_file
- )
-
-
def validate_setting(setting: Setting, value: Any) -> tuple[bool, Optional[str]]:
"""
Validate a setting value based on its type and constraints