~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
Optimize auto search to prioritize SearXNG for most queries
LearningCircuit683f42fe6be4
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.jsonindex 6c2aee6179..ea227a791c 100644--- a/src/local_deep_research/defaults/default_settings.json+++ b/src/local_deep_research/defaults/default_settings.json@@ -3191,7 +3191,7 @@"step": 0.05,"type": "SEARCH","ui_element": "range",- "value": 0.9,+ "value": 1.0,"visible": true},"search.engine.web.searxng.requires_api_key": {@@ -3220,12 +3220,16 @@"type": "SEARCH","ui_element": "text","value": [- "privacy-focused",- "metasearch engine",- "self-hosted",- "no tracking",- "configurable",- "multiple engines in one"+ "comprehensive general information",+ "current events and news",+ "technical documentation",+ "factual queries",+ "historical information",+ "consumer products",+ "educational content",+ "multi-source aggregation",+ "real-time results",+ "combined results from major search engines"],"visible": true},diff --git a/src/local_deep_research/web_search_engines/engines/meta_search_engine.py b/src/local_deep_research/web_search_engines/engines/meta_search_engine.pyindex 2b12a09242..af6ad4f245 100644--- a/src/local_deep_research/web_search_engines/engines/meta_search_engine.py+++ b/src/local_deep_research/web_search_engines/engines/meta_search_engine.py@@ -117,6 +117,8 @@ class MetaSearchEngine(BaseSearchEngine):def analyze_query(self, query: str) -> List[str]:"""Analyze the query to determine the best search engines to use.+ Prioritizes SearXNG for general queries, but selects specialized engines+ for domain-specific queries (e.g., scientific papers, code).Args:query: The search query@@ -125,10 +127,57 @@ class MetaSearchEngine(BaseSearchEngine):List of search engine names sorted by suitability"""try:- # Check if the LLM is available to help select engines- if not self.llm:+ # First check if this is a specialized query that should use specific engines+ specialized_domains = {+ "scientific paper": ["arxiv", "pubmed", "wikipedia"],+ "medical research": ["pubmed", "searxng"],+ "clinical": ["pubmed", "searxng"],+ "github": ["github", "searxng"],+ "repository": ["github", "searxng"],+ "code": ["github", "searxng"],+ "programming": ["github", "searxng"],+ }++ # Quick heuristic check for specialized queries+ query_lower = query.lower()+ for term, engines in specialized_domains.items():+ if term in query_lower:+ valid_engines = []+ for engine in engines:+ if engine in self.available_engines:+ valid_engines.append(engine)++ if valid_engines:+ logger.info(+ f"Detected specialized query type: {term}, using engines: {valid_engines}"+ )+ return valid_engines++ # For searches containing "arxiv", prioritize the arxiv engine+ if "arxiv" in query_lower and "arxiv" in self.available_engines:+ return ["arxiv"] + [e for e in self.available_engines if e != "arxiv"]++ # For searches containing "pubmed", prioritize the pubmed engine+ if "pubmed" in query_lower and "pubmed" in self.available_engines:+ return ["pubmed"] + [e for e in self.available_engines if e != "pubmed"]++ # Check if SearXNG is available and prioritize it for general queries+ if "searxng" in self.available_engines:+ # For general queries, return SearXNG first followed by reliability-ordered engines+ engines_without_searxng = [+ e for e in self.available_engines if e != "searxng"+ ]+ reliability_sorted = sorted(+ engines_without_searxng,+ key=lambda x: search_config().get(x, {}).get("reliability", 0),+ reverse=True,+ )+ return ["searxng"] + reliability_sorted++ # If LLM is not available or SearXNG is not available, fall back to reliability+ if not self.llm or "searxng" not in self.available_engines:logger.warning(- "No LLM available for query analysis, using default engines"+ "No LLM available or SearXNG not available, using reliability-based engines")# Return engines sorted by reliabilityreturn sorted(@@ -168,6 +217,7 @@ class MetaSearchEngine(BaseSearchEngine):reverse=True,)+ # Use a stronger prompt that emphasizes SearXNG preference for general queriesprompt = f"""You are a search query analyst. Consider this search query:QUERY: {query}@@ -176,11 +226,17 @@ I have these search engines available:{chr(10).join(engines_info)}Determine which search engines would be most appropriate for answering this query.-First analyze the nature of the query (factual, scientific, code-related, etc.)-Then select the 1-3 most appropriate search engines for this type of query.+First analyze the nature of the query: Is it factual, scientific, code-related, medical, etc.?-Output ONLY a comma-separated list of the search engine names in order of most appropriate to least appropriate.-Example output: wikipedia,arxiv,github"""+IMPORTANT GUIDELINES:+- Use SearXNG for most general queries as it combines results from multiple search engines+- For academic/scientific searches, prefer arXiv+- For medical research, prefer PubMed+- For code repositories and programming, prefer GitHub+- For every other query type, SearXNG is usually the best option++Output ONLY a comma-separated list of 1-3 search engine names in order of most appropriate to least appropriate.+Example output: searxng,wikipedia,brave"""# Get analysis from LLMresponse = self.llm.invoke(prompt)@@ -198,7 +254,16 @@ Example output: wikipedia,arxiv,github"""if cleaned_name in self.available_engines:valid_engines.append(cleaned_name)- # If no valid engines were returned, use default order based on reliability+ # If SearXNG is available but not selected by the LLM, add it as a fallback+ if "searxng" in self.available_engines and "searxng" not in valid_engines:+ # Add it as the last option if the LLM selected others+ if valid_engines:+ valid_engines.append("searxng")+ # Use it as the first option if no valid engines were selected+ else:+ valid_engines = ["searxng"]++ # If still no valid engines, use reliability-based orderingif not valid_engines:valid_engines = sorted(self.available_engines,@@ -209,12 +274,19 @@ Example output: wikipedia,arxiv,github"""return valid_enginesexcept Exception:logger.exception("Error analyzing query with LLM")- # Fall back to reliability-based ordering- return sorted(- self.available_engines,- key=lambda x: search_config().get(x, {}).get("reliability", 0),- reverse=True,- )+ # Fall back to SearXNG if available, then reliability-based ordering+ if "searxng" in self.available_engines:+ return ["searxng"] + sorted(+ [e for e in self.available_engines if e != "searxng"],+ key=lambda x: search_config().get(x, {}).get("reliability", 0),+ reverse=True,+ )+ else:+ return sorted(+ self.available_engines,+ key=lambda x: search_config().get(x, {}).get("reliability", 0),+ reverse=True,+ )def _get_previews(self, query: str) -> List[Dict[str, Any]]:"""