~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
LearningCircuit576961449c65
diff --git a/.pre-commit-hooks/custom-checks.py b/.pre-commit-hooks/custom-checks.pyindex 5872cd31e9..06b47022b3 100755--- a/.pre-commit-hooks/custom-checks.py+++ b/.pre-commit-hooks/custom-checks.py@@ -263,12 +263,8 @@ def check_raw_sql(content: str, filename: str) -> List[Tuple[int, str]]:or "encrypted_db.py" in filename)- # Allow raw SQL in migrations, db utils, and some test contexts- if not (- is_migration- or is_db_util- or (is_test and "schema" in line.lower())- ):+ # Allow raw SQL in migrations, db utils, and all test files+ if not (is_migration or is_db_util or is_test):errors.append((line_num,@@ -296,12 +292,8 @@ def check_raw_sql(content: str, filename: str) -> List[Tuple[int, str]]:or "encrypted_db.py" in filename)- # Allow raw SQL in migrations, db utils, and some test contexts- if not (- is_migration- or is_db_util- or (is_test and "schema" in line.lower())- ):+ # Allow raw SQL in migrations, db utils, and all test files+ if not (is_migration or is_db_util or is_test):errors.append((line_num,diff --git a/src/local_deep_research/advanced_search_system/questions/__init__.py b/src/local_deep_research/advanced_search_system/questions/__init__.pyindex 85b7cfc44c..1818663f08 100644--- a/src/local_deep_research/advanced_search_system/questions/__init__.py+++ b/src/local_deep_research/advanced_search_system/questions/__init__.py@@ -5,6 +5,7 @@ from .base_question import BaseQuestionGeneratorfrom .browsecomp_question import BrowseCompQuestionGeneratorfrom .decomposition_question import DecompositionQuestionGeneratorfrom .entity_aware_question import EntityAwareQuestionGenerator+from .news_question import NewsQuestionGeneratorfrom .standard_question import StandardQuestionGenerator__all__ = [@@ -13,5 +14,6 @@ __all__ = ["BrowseCompQuestionGenerator","DecompositionQuestionGenerator","EntityAwareQuestionGenerator",+ "NewsQuestionGenerator","StandardQuestionGenerator",]diff --git a/src/local_deep_research/advanced_search_system/questions/news_question.py b/src/local_deep_research/advanced_search_system/questions/news_question.pynew file mode 100644index 0000000000..9e90618308--- /dev/null+++ b/src/local_deep_research/advanced_search_system/questions/news_question.py@@ -0,0 +1,49 @@+"""+News question generation implementation.+"""++from datetime import datetime+from typing import List, Dict++from loguru import logger++from .base_question import BaseQuestionGenerator+++class NewsQuestionGenerator(BaseQuestionGenerator):+ """News-specific question generator for aggregating current news."""++ def generate_questions(+ self,+ current_knowledge: str,+ query: str,+ questions_per_iteration: int = 8,+ questions_by_iteration: Dict[int, List[str]] = None,+ ) -> List[str]:+ """Generate news-specific search queries."""+ date_str = datetime.now().strftime("%B %d, %Y")++ logger.info("Generating news search queries...")++ # Build diverse news queries+ base_queries = [+ f"breaking news today {date_str}",+ f"major incidents casualties today {date_str}",+ f"unexpected news surprising today {date_str}",+ "economic news market movement today",+ f"political announcements today {date_str}",+ "technology breakthrough announcement today",+ "natural disaster emergency today",+ "international news global impact today",+ ]++ # If user provided specific focus, add those queries+ if query and query != "latest important news today":+ focus_queries = [+ f"{query} {date_str}",+ f"{query} breaking news today",+ f"{query} latest developments",+ ]+ return focus_queries + base_queries[:5]++ return base_queries[:questions_per_iteration]diff --git a/src/local_deep_research/advanced_search_system/strategies/news_strategy.py b/src/local_deep_research/advanced_search_system/strategies/news_strategy.pyindex 4c5dad8830..452feff1c5 100644--- a/src/local_deep_research/advanced_search_system/strategies/news_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/news_strategy.py@@ -10,6 +10,7 @@ import refrom loguru import loggerfrom .base_strategy import BaseSearchStrategy+from ..questions.news_question import NewsQuestionGeneratorclass NewsAggregationStrategy(BaseSearchStrategy):@@ -30,34 +31,16 @@ class NewsAggregationStrategy(BaseSearchStrategy):self.strategy_name = "news_aggregation"self.max_iterations = 1 # News needs broad coverage, not deep iterationself.questions_per_iteration = 8 # More parallel searches for news+ self.question_generator = NewsQuestionGenerator(self.model)def generate_questions(self, query: str, context: str) -> List[str]:- """Generate news-specific search queries"""-- date_str = datetime.now().strftime("%B %d, %Y")-- # Build diverse news queries- base_queries = [- f"breaking news today {date_str}",- f"major incidents casualties today {date_str}",- f"unexpected news surprising today {date_str}",- "economic news market movement today",- f"political announcements today {date_str}",- "technology breakthrough announcement today",- "natural disaster emergency today",- "international news global impact today",- ]-- # If user provided specific focus, add those queries- if query and query != "latest important news today":- focus_queries = [- f"{query} {date_str}",- f"{query} breaking news today",- f"{query} latest developments",- ]- return focus_queries + base_queries[:5]-- return base_queries+ """Generate news-specific search queries using the NewsQuestionGenerator"""+ return self.question_generator.generate_questions(+ current_knowledge=context,+ query=query,+ questions_per_iteration=self.questions_per_iteration,+ questions_by_iteration=self.questions_by_iteration,+ )async def analyze_findings(self, all_findings: List[Dict]@@ -116,7 +99,7 @@ class NewsAggregationStrategy(BaseSearchStrategy):return self._fallback_news_extraction(snippets)except Exception as e:- logger.error(f"Error analyzing news findings: {e}")+ logger.exception(f"Error analyzing news findings: {e}")return self._fallback_news_extraction(snippets)def _create_news_analysis_prompt(self, snippets: List[Dict]) -> str:@@ -176,7 +159,7 @@ Ensure variety across different categories when possible.if json_match:return json.loads(json_match.group())except Exception as e:- logger.error(f"Error extracting JSON: {e}")+ logger.exception(f"Error extracting JSON: {e}")return Nonedef _format_news_summary(self, news_items: List[Dict]) -> str:@@ -266,7 +249,7 @@ Ensure variety across different categories when possible.if results:all_findings.extend(results)except Exception as e:- logger.error(f"Search error: {e}")+ logger.exception(f"Search error: {e}")continue# Analyze findings - handle both sync and async contextsdiff --git a/src/local_deep_research/api/__init__.py b/src/local_deep_research/api/__init__.pyindex 47019da111..a50441531d 100644--- a/src/local_deep_research/api/__init__.py+++ b/src/local_deep_research/api/__init__.py@@ -15,24 +15,13 @@ from .settings_utils import (extract_setting_value,)-try:- from ..news import (- get_news_feed,- research_news_item,- submit_news_feedback,- save_news_preferences,- get_news_categories,- )-- NEWS_AVAILABLE = True-except ImportError:- NEWS_AVAILABLE = False- # Define placeholders to avoid NameErrors- get_news_feed = None- research_news_item = None- submit_news_feedback = None- save_news_preferences = None- get_news_categories = None+from ..news import (+ get_news_feed,+ research_news_item,+ submit_news_feedback,+ save_news_preferences,+ get_news_categories,+)__all__ = ["analyze_documents",@@ -42,15 +31,9 @@ __all__ = ["create_settings_snapshot","get_default_settings_snapshot","extract_setting_value",+ "get_news_feed",+ "research_news_item",+ "submit_news_feedback",+ "save_news_preferences",+ "get_news_categories",]--if NEWS_AVAILABLE:- __all__.extend(- [- "get_news_feed",- "research_news_item",- "submit_news_feedback",- "save_news_preferences",- "get_news_categories",- ]- )diff --git a/src/local_deep_research/benchmarks/cli/benchmark_commands.py b/src/local_deep_research/benchmarks/cli/benchmark_commands.pyindex 91a65c90ff..45fd4f33a3 100644--- a/src/local_deep_research/benchmarks/cli/benchmark_commands.py+++ b/src/local_deep_research/benchmarks/cli/benchmark_commands.py@@ -17,8 +17,6 @@ from .. import (run_simpleqa_benchmark,)-# logger = logging.getLogger(__name__) - using loguru logger directly-def setup_benchmark_parser(subparsers):"""diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.pyindex 3ba3f80906..6dc66f2b16 100644--- a/src/local_deep_research/search_system.py+++ b/src/local_deep_research/search_system.py@@ -590,18 +590,25 @@ class AdvancedSearchSystem:if hasattr(self, "strategy"):self.strategy.set_progress_callback(callback)- def analyze_topic(self, query: str, **kwargs) -> Dict:+ def analyze_topic(+ self,+ query: str,+ is_user_search: bool = True,+ is_news_search: bool = False,+ user_id: str = "anonymous",+ search_id: str = None,+ **kwargs,+ ) -> Dict:"""Analyze a topic using the current strategy.Args:query: The research query to analyze- **kwargs: Additional arguments (is_user_search, is_news_search, user_id)+ is_user_search: Whether this is a user-initiated search+ is_news_search: Whether this is a news search+ user_id: The user ID for tracking+ search_id: The search ID (auto-generated if not provided)+ **kwargs: Additional arguments"""- # Determine search type- is_user_search = kwargs.get("is_user_search", True)- is_news_search = kwargs.get("is_news_search", False)- user_id = kwargs.get("user_id", "anonymous")- search_id = kwargs.get("search_id", None)# Generate search ID if not providedif search_id is None:@@ -717,8 +724,6 @@ class AdvancedSearchSystem:"search_id": search_id,}callback(query, result, context)- except ImportError:- passexcept Exception as e:logger.exception(f"Error in news callback: {e}")diff --git a/src/local_deep_research/settings/manager.py b/src/local_deep_research/settings/manager.pyindex 142d173d9c..a01e24c79f 100644--- a/src/local_deep_research/settings/manager.py+++ b/src/local_deep_research/settings/manager.py@@ -823,46 +823,6 @@ class SettingsManager(ISettingsManager):"LDR_USE_FALLBACK_LLM": "Use fallback LLM for testing",}- @staticmethod- def get_all_env_vars() -> Dict[str, Dict[str, str]]:- """- Get all environment variables organized by category.-- Returns:- Dict with categories as keys, each containing env vars and descriptions- """- return {- "bootstrap": SettingsManager.get_bootstrap_env_vars(),- "app": {- "LDR_DEBUG": "Enable debug mode (maps to app.debug)",- "LDR_HOST": "Host to bind web server (maps to app.host)",- "LDR_PORT": "Port for web server (maps to app.port)",- "LDR_USE_HTTPS": "Enable HTTPS (maps to app.use_https)",- "LDR_MAX_CONCURRENT": "Max concurrent researches (maps to app.max_concurrent_researches)",- "LDR_QUEUE_MODE": "Queue processing mode: direct or queue (maps to app.queue_mode)",- },- "llm": {- "LDR_LLM__PROVIDER": "LLM provider (maps to llm.provider)",- "LDR_LLM__MODEL": "LLM model name (maps to llm.model)",- "LDR_LLM__ANTHROPIC_API_KEY": "Anthropic API key (maps to llm.anthropic.api_key)",- "LDR_LLM__OPENAI_API_KEY": "OpenAI API key (maps to llm.openai.api_key)",- "LDR_LLM__OPENAI_ENDPOINT_API_KEY": "OpenAI-compatible endpoint API key",- "LDR_LLM__OPENAI_ENDPOINT_URL": "OpenAI-compatible endpoint URL",- "LDR_LLM__OLLAMA_URL": "Ollama API URL (maps to llm.ollama.url)",- },- "search": {- "LDR_SEARCH__TOOL": "Default search tool (maps to search.tool)",- "LDR_SEARCH__ENGINE__WEB__BRAVE__API_KEY": "Brave API key (maps to search.engine.web.brave.api_key)",- "LDR_SEARCH__ENGINE__WEB__TAVILY__API_KEY": "Tavily API key (maps to search.engine.web.tavily.api_key)",- "LDR_SEARCH__ENGINE__WEB__SERPAPI__API_KEY": "SerpAPI key (maps to search.engine.web.serpapi.api_key)",- "LDR_SEARCH__ENGINE__WEB__GITHUB__API_KEY": "GitHub API key (maps to search.engine.web.github.api_key)",- "LDR_SEARCH__ENGINE__WEB__GUARDIAN__API_KEY": "Guardian API key (maps to search.engine.web.guardian.api_key)",- "LDR_SEARCH__ENGINE__WEB__PUBMED__API_KEY": "PubMed API key (maps to search.engine.web.pubmed.api_key)",- "LDR_SEARCH__ENGINE__WEB__GOOGLE_PSE__API_KEY": "Google PSE API key (maps to search.engine.web.google_pse.api_key)",- "LDR_SEARCH__ENGINE__WEB__SEARXNG__DEFAULT_PARAMS__DELAY_BETWEEN_REQUESTS": "SearXNG request delay (maps to search.engine.web.searxng.default_params.delay_between_requests)",- },- }-@staticmethoddef is_bootstrap_env_var(env_var: str) -> bool:"""@@ -886,12 +846,10 @@ class SettingsManager(ISettingsManager):setting_key: Setting key (e.g., "app.host")Returns:- Environment variable name (e.g., "LDR_APP__HOST")+ Environment variable name (e.g., "LDR_APP_HOST")"""- # Convert dots to double underscores and uppercase- parts = setting_key.split(".")- env_var = "LDR_" + "__".join(part.upper() for part in parts)- return env_var+ # Use the same logic as check_env_setting for consistency+ return f"LDR_{'_'.join(setting_key.split('.')).upper()}"@staticmethoddef get_setting_key_for_env_var(env_var: str) -> Optional[str]:@@ -899,7 +857,7 @@ class SettingsManager(ISettingsManager):Get the setting key for a given environment variable.Args:- env_var: Environment variable name (e.g., "LDR_APP__HOST")+ env_var: Environment variable name (e.g., "LDR_APP_HOST")Returns:Setting key (e.g., "app.host") or None if not a valid LDR env var@@ -909,11 +867,6 @@ class SettingsManager(ISettingsManager):# Remove LDR_ prefix and convert to lowercasewithout_prefix = env_var[4:]-- # Handle single underscore (old format) vs double underscore (new format)- if "__" in without_prefix:- parts = without_prefix.split("__")- else:- parts = without_prefix.split("_")+ parts = without_prefix.split("_")return ".".join(part.lower() for part in parts)