~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
wrap the db_settings calls in search_config.py like llm_config before
ScottVR2ccd15d53fb3
diff --git a/src/local_deep_research/config/search_config.py b/src/local_deep_research/config/search_config.pyindex 369bdf31f0..0504ceba94 100644--- a/src/local_deep_research/config/search_config.py+++ b/src/local_deep_research/config/search_config.py@@ -7,8 +7,16 @@ from .llm_config import get_llm# Whether to check the quality search results using the LLM.QUALITY_CHECK_DDG_URLS = True-# Whether to only retrieve snippets instead of full search results.-SEARCH_SNIPPETS_ONLY = get_db_setting("search.snippets_only", True)++# REMOVE or COMMENT OUT this problematic module-level assignment:+# SEARCH_SNIPPETS_ONLY = get_db_setting("search.snippets_only", True)++# Instead, create a function to retrieve SEARCH_SNIPPETS_ONLY lazily+def get_search_snippets_only_setting():+ """+ Lazily retrieve the 'search.snippets_only' setting.+ """+ return get_db_setting("search.snippets_only", True)# Expose get_search function@@ -36,7 +44,8 @@ def get_search(search_tool=None, llm_instance=None):"region": get_db_setting("search.region", "wt-wt"),"time_period": get_db_setting("search.time_period", "all"),"safe_search": get_db_setting("search.safe_search", True),- "search_snippets_only": SEARCH_SNIPPETS_ONLY,+ # NOW, retrieve the setting value by calling the new function:+ "search_snippets_only": get_search_snippets_only_setting(),"search_language": get_db_setting("search.search_language", "English"),"max_filtered_results": get_db_setting("search.max_filtered_results", 5),}@@ -57,4 +66,4 @@ def get_search(search_tool=None, llm_instance=None):else:logger.error(f"Failed to create search engine for tool: {tool}")- return search_engine+ return search_engine\ No newline at end of filediff --git a/tests/conftest.py b/tests/conftest.pyindex 2da4dd69f1..6b6bd68820 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1,28 +1,53 @@-import os # Import os for additional path debugging-import pytestfrom sqlalchemy import create_engine-from sqlalchemy.exc import SQLAlchemyErrorfrom sqlalchemy.orm import sessionmaker+from sqlalchemy.exc import SQLAlchemyError+from pathlib import Path+import sys+import os # Import os for additional path debugging-import src.local_deep_research.utilities.db_utils as db_utils_module-from src.local_deep_research.web.database.models import Base-from src.local_deep_research.web.services.settings_manager import SettingsManager+# Add debug messages for path setup+current_file_path = Path(__file__).resolve()+project_root = current_file_path.parent.parent+print(f"DEBUG: conftest.py path: {current_file_path}")+print(f"DEBUG: Calculated project root: {project_root}")+sys.path.append(str(project_root))+print(f"DEBUG: sys.path after appending project root: {sys.path}")-# Remove the custom session_mocker_fixture definition.-# Pytest-mock should provide 'session_mocker' directly.+from src.local_deep_research.web.database.models import Base, Setting, SettingType+import src.local_deep_research.utilities.db_utils as db_utils_module+from src.local_deep_research.web.services.settings_manager import SettingsManager@pytest.fixture(scope="session", autouse=True)-def setup_database_for_all_tests(- tmp_path_factory, session_mocker-): # Directly use the session_mocker provided by pytest-mock+def setup_database_for_all_tests(tmp_path_factory, session_mocker): # Directly use the session_mocker provided by pytest-mock"""Provides a database setup for a temporary SQLite file database for the entire test session.It patches db_utils.get_db_session and db_utils.get_settings_manager to use this test DB."""print("\nDEBUG: Entering setup_database_for_all_tests fixture.")++ # Call cache_clear on the functions from db_utils_module.+ # This ensures any pre-existing cached instances are gone.+ # We must ensure db_utils_module is imported before this point.+ try:+ print("DEBUG: Performing aggressive cache clear on db_utils functions.")+ if hasattr(db_utils_module.get_db_session, 'cache_clear'):+ db_utils_module.get_db_session.cache_clear()+ print("DEBUG: db_utils_module.get_db_session cache cleared.")+ if hasattr(db_utils_module.get_settings_manager, 'cache_clear'):+ db_utils_module.get_settings_manager.cache_clear()+ print("DEBUG: db_utils_module.get_settings_manager cache cleared.")+ if hasattr(db_utils_module.get_db_setting, 'cache_clear'):+ db_utils_module.get_db_setting.cache_clear() # Clear get_db_setting's cache too+ print("DEBUG: db_utils_module.get_db_setting cache cleared.")++ except Exception as e:+ print(f"ERROR: Failed to clear db_utils caches aggressively: {e}")+ # This shouldn't prevent test run, but indicates a problem with cache_clear++# Debug tmp_path_factory behaviortemp_dir = tmp_path_factory.mktemp("db_test_data")db_file = temp_dir / "test_settings.db"@@ -62,18 +87,18 @@ def setup_database_for_all_tests(print("DEBUG: SessionLocal sessionmaker created.")temp_session = SessionLocal()temp_settings_manager = SettingsManager(db_session=temp_session)-+try:print("DEBUG: Loading default settings into the test database.")temp_settings_manager.load_from_defaults_file(commit=True)print("DEBUG: Default settings loaded successfully.")except Exception as e:print(f"ERROR: Failed to load default settings: {e}")- temp_session.rollback() # Rollback if default loading fails- raise # Re-raise to fail the test if default loading is critical+ temp_session.rollback() # Rollback if default loading fails+ raise # Re-raise to fail the test if default loading is criticalfinally:- temp_session.close() # Close the temporary session used for loading defaults-+ temp_session.close() # Close the temporary session used for loading defaults+# Clear caches and patchprint("DEBUG: Clearing db_utils.get_db_session cache.")db_utils_module.get_db_session.cache_clear()@@ -81,31 +106,21 @@ def setup_database_for_all_tests(db_utils_module.get_settings_manager.cache_clear()print("DEBUG: Patching src.local_deep_research.utilities.db_utils.get_db_session.")- mock_get_db_session = session_mocker.patch(- "src.local_deep_research.utilities.db_utils.get_db_session"- )+ mock_get_db_session = session_mocker.patch("src.local_deep_research.utilities.db_utils.get_db_session")mock_get_db_session.side_effect = SessionLocalprint(f"DEBUG: get_db_session patched to use SessionLocal: {SessionLocal}")- print(- "DEBUG: Patching src.local_deep_research.utilities.db_utils.get_settings_manager."- )- mock_get_settings_manager = session_mocker.patch(- "src.local_deep_research.utilities.db_utils.get_settings_manager"- )- mock_get_settings_manager.side_effect = lambda: SettingsManager(- db_session=mock_get_db_session()- )- print(- "DEBUG: get_settings_manager patched to return SettingsManager with mock_get_db_session."- )+ print("DEBUG: Patching src.local_deep_research.utilities.db_utils.get_settings_manager.")+ mock_get_settings_manager = session_mocker.patch("src.local_deep_research.utilities.db_utils.get_settings_manager")+ mock_get_settings_manager.side_effect = lambda: SettingsManager(db_session=mock_get_db_session())+ print("DEBUG: get_settings_manager patched to return SettingsManager with mock_get_db_session.")print("DEBUG: Yielding SessionLocal from setup_database_for_all_tests fixture.")- yield SessionLocal # Yield the SessionLocal class for individual tests to create sessions+ yield SessionLocal # Yield the SessionLocal class for individual tests to create sessionsprint("DEBUG: Teardown: Disposing SQLAlchemy engine.")if engine:- engine.dispose() # Dispose the engine to close all connections+ engine.dispose() # Dispose the engine to close all connectionsprint("DEBUG: SQLAlchemy engine disposed.")else:print("DEBUG: Engine was not initialized, no dispose needed.")@@ -118,8 +133,7 @@ def mock_db_session(mocker):print("DEBUG: Providing mock_db_session fixture.")return mocker.MagicMock()-@pytest.fixturedef mock_logger(mocker):print("DEBUG: Providing mock_logger fixture.")- return mocker.patch("src.local_deep_research.web.services.settings_manager.logger")+ return mocker.patch("src.local_deep_research.web.services.settings_manager.logger")\ No newline at end of file