~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
fix: Address PR review comments from djpetti
LearningCircuitae6d8abdcd1b
diff --git a/pdm.lock b/pdm.lockindex 964381d270..d823c54df1 100644--- a/pdm.lock+++ b/pdm.lock@@ -5,7 +5,7 @@groups = ["default", "dev"]strategy = ["inherit_metadata"]lock_version = "4.5.0"-content_hash = "sha256:88a559f826c10bf50dd6ef3fb737d447901134cd0bb1edfc82636c6983c3ab82"+content_hash = "sha256:54cf1618544e71640ad9f7f4f12f2a670ed762de5585025921833e86542e46fb"[[metadata.targets]]requires_python = ">=3.10"@@ -3801,7 +3801,7 @@ files = [[[package]]name = "pre-commit"-version = "4.2.0"+version = "4.3.0"requires_python = ">=3.9"summary = "A framework for managing and maintaining multi-language pre-commit hooks."groups = ["dev"]@@ -3813,8 +3813,8 @@ dependencies = ["virtualenv>=20.10.0",]files = [- {file = "pre_commit-4.2.0-py2.py3-none-any.whl", hash = "sha256:a009ca7205f1eb497d10b845e52c838a98b6cdd2102a6c8e4540e94ee75c58bd"},- {file = "pre_commit-4.2.0.tar.gz", hash = "sha256:601283b9757afd87d40c4c4a9b2b5de9637a8ea02eaff7adc2d0fb4e04841146"},+ {file = "pre_commit-4.3.0-py2.py3-none-any.whl", hash = "sha256:2b0747ad7e6e967169136edffee14c16e148a778a54e4f967921aa1ebf2308d8"},+ {file = "pre_commit-4.3.0.tar.gz", hash = "sha256:499fe450cc9d42e9d58e606262795ecb64dd05438943c62b66f6a8673da30b16"},][[package]]diff --git a/pyproject.toml b/pyproject.tomlindex 3551698c85..f108bb61ed 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -98,6 +98,7 @@ include-package-data = true+[tool.pdm]distribution = trueversion = { source = "file", path = "src/local_deep_research/__version__.py" }@@ -108,7 +109,7 @@ include_packages = ["torch", "torch*"][dependency-groups]dev = [- "pre-commit>=4.2.0",+ "pre-commit>=4.3.0","jupyter>=1.1.1","cookiecutter>=2.6.0","pandas>=2.2.3",diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.pyindex d896316c95..f841cfd791 100644--- a/src/local_deep_research/config/llm_config.py+++ b/src/local_deep_research/config/llm_config.py@@ -477,13 +477,10 @@ def get_llm(api_key = get_setting_from_snapshot("llm.openai.api_key", settings_snapshot=settings_snapshot)- # If API key not in settings, check environment variable- if not api_key:- api_key = os.environ.get("OPENAI_API_KEY")if not api_key:logger.warning(- "OPENAI_API_KEY not found. Falling back to default model."+ "OpenAI API key not found in settings. Falling back to default model.")return get_fallback_model(temperature)diff --git a/src/local_deep_research/news/api.py b/src/local_deep_research/news/api.pyindex 9bf8bac43e..5333846b4b 100644--- a/src/local_deep_research/news/api.py+++ b/src/local_deep_research/news/api.py@@ -983,8 +983,11 @@ def create_subscription(refresh_minutes = settings_manager.get_setting("news.subscription.refresh_minutes", 240)- except Exception:+ except (ImportError, AttributeError, TypeError):# Fallback for when settings DB is not available (e.g., programmatic API usage)+ logger.debug(+ "Settings manager not available, using default refresh_minutes"+ )refresh_minutes = 240 # Default to 4 hours# Create new subscriptionsubscription = NewsSubscription(diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_google_pse.py b/src/local_deep_research/web_search_engines/engines/search_engine_google_pse.pyindex 757d3b0acf..3a7be689cb 100644--- a/src/local_deep_research/web_search_engines/engines/search_engine_google_pse.py+++ b/src/local_deep_research/web_search_engines/engines/search_engine_google_pse.py@@ -90,7 +90,10 @@ class GooglePSESearchEngine(BaseSearchEngine):self.region = region# API key and Search Engine ID - check params, env vars, or database- from ...config.thread_settings import get_setting_from_snapshot+ from ...config.thread_settings import (+ get_setting_from_snapshot,+ NoSettingsContextError,+ )self.api_key = api_keyif not self.api_key:@@ -100,8 +103,11 @@ class GooglePSESearchEngine(BaseSearchEngine):default=None,settings_snapshot=self.settings_snapshot,)- except Exception:+ except NoSettingsContextError:# No settings context available+ logger.debug(+ "No settings context available for Google PSE API key"+ )passself.search_engine_id = search_engine_id@@ -112,8 +118,11 @@ class GooglePSESearchEngine(BaseSearchEngine):default=None,settings_snapshot=self.settings_snapshot,)- except Exception:+ except NoSettingsContextError:# No settings context available+ logger.debug(+ "No settings context available for Google PSE engine ID"+ )passif not self.api_key:diff --git a/tests/test_openai_api_key_usage.py b/tests/test_openai_api_key_usage.pyindex 89a46c088f..8a9acb6bb1 100644--- a/tests/test_openai_api_key_usage.py+++ b/tests/test_openai_api_key_usage.py@@ -78,26 +78,24 @@ class TestOpenAIAPIKeyUsage:reason="Skipped in CI - requires environment variable configuration",)def test_openai_api_key_from_environment(self, openai_settings_snapshot):- """Test fallback to environment variable if API key not in settings."""+ """Test that when API key is not in settings, it falls back to the default model."""# Modify settings to have no API keysettings_no_key = openai_settings_snapshot.copy()settings_no_key["llm.openai.api_key"] = {"value": None, "type": "str"}- # Set environment variable+ # The old OPENAI_API_KEY env var should no longer be usedwith patch.dict(os.environ, {"OPENAI_API_KEY": "sk-env-test-key"}):with patch(- "local_deep_research.config.llm_config.ChatOpenAI"- ) as mock_openai:+ "local_deep_research.config.llm_config.get_fallback_model"+ ) as mock_fallback:mock_llm_instance = Mock()- mock_openai.return_value = mock_llm_instance+ mock_fallback.return_value = mock_llm_instance- get_llm(settings_snapshot=settings_no_key)+ result = get_llm(settings_snapshot=settings_no_key)- # Should use environment variable- call_args = mock_openai.call_args- assert call_args is not None- assert len(call_args) > 1- assert call_args[1]["api_key"] == "sk-env-test-key"+ # Should call fallback model since no API key in settings+ mock_fallback.assert_called_once()+ assert result == mock_llm_instancedef test_openai_api_key_in_research_flow(self, openai_settings_snapshot):"""Test that API key is properly passed through research flow to OpenAI."""