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.

added search engine config

LearningCircuit0a4a588146dc
diff --git a/src/local_deep_research/config.py b/src/local_deep_research/config.py
index b08c84daaa..561cdc13b4 100644
--- a/src/local_deep_research/config.py
+++ b/src/local_deep_research/config.py
@@ -20,6 +20,8 @@ CONFIG_DIR.mkdir(parents=True, exist_ok=True)
SETTINGS_FILE = CONFIG_DIR / "settings.toml"
SECRETS_FILE = CONFIG_DIR / ".secrets.toml"
LLM_CONFIG_FILE = CONFIG_DIR / "llm_config.py"
+SEARCH_ENGINES_FILE = CONFIG_DIR / "search_engines.toml"
+
LOCAL_COLLECTIONS_FILE = CONFIG_DIR / "local_collections.toml"
print("CONFIGDIR:", CONFIG_DIR)
print("SECRETS_FILE:", SECRETS_FILE)
@@ -112,8 +114,6 @@ def init_config_files():
shutil.copy(defaults_dir / "main.toml", settings_file)
logger.info(f"Created settings.toml at {settings_file}")
-
-
# Create llm_config.py if it doesn't exist
llm_config_file = CONFIG_DIR / "llm_config.py"
if not llm_config_file.exists():
@@ -125,6 +125,12 @@ def init_config_files():
if not collections_file.exists():
shutil.copy(defaults_dir / "local_collections.toml", collections_file)
logger.info(f"Created local_collections.toml at {collections_file}")
+
+ # Create search_engines.toml if it doesn't exist
+ search_engines_file = CONFIG_DIR / "search_engines.toml"
+ if not search_engines_file.exists():
+ shutil.copy(defaults_dir / "search_engines.toml", search_engines_file)
+ logger.info(f"Created search_engines.toml at {search_engines_file}")
secrets_file = CONFIG_DIR / ".secrets.toml"
if not secrets_file.exists():
@@ -148,13 +154,13 @@ secrets_file = Path(SECRETS_FILE)
settings = Dynaconf(
settings_files=[
str(SETTINGS_FILE),
- str(LOCAL_COLLECTIONS_FILE), # Add this line
-
+ str(LOCAL_COLLECTIONS_FILE),
+ str(SEARCH_ENGINES_FILE),
],
secrets=str(SECRETS_FILE),
env_prefix="LDR",
load_dotenv=True,
envvar_prefix="LDR",
- env_file=str(CONFIG_DIR / ".env"), # Add this line
+ env_file=str(CONFIG_DIR / ".env"),
)
diff --git a/src/local_deep_research/defaults/__init__.py b/src/local_deep_research/defaults/__init__.py
index f0101379c3..1e42005256 100644
--- a/src/local_deep_research/defaults/__init__.py
+++ b/src/local_deep_research/defaults/__init__.py
@@ -17,6 +17,7 @@ DEFAULTS_DIR = Path(__file__).parent
DEFAULT_FILES = {
"main.toml": DEFAULTS_DIR / "main.toml",
"local_collections.toml": DEFAULTS_DIR / "local_collections.toml",
+ "search_engines.toml": DEFAULTS_DIR / "search_engines.toml",
"llm_config.py": DEFAULTS_DIR / "llm_config.py"
}
diff --git a/src/local_deep_research/defaults/search_engines.toml b/src/local_deep_research/defaults/search_engines.toml
new file mode 100644
index 0000000000..b2bf2b4ccf
--- /dev/null
+++ b/src/local_deep_research/defaults/search_engines.toml
@@ -0,0 +1,244 @@
+# Search Engines Configuration for Local Deep Research
+# This file defines all available search engines and their properties
+
+[wikipedia]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_wikipedia"
+class_name = "WikipediaSearchEngine"
+requires_api_key = false
+reliability = 0.95
+strengths = [
+ "factual information", "general knowledge", "definitions",
+ "historical facts", "biographies", "overview information"
+]
+weaknesses = ["recent events", "specialized academic topics", "product comparisons"]
+
+[wikipedia.default_params]
+max_results = 20
+include_content = true
+
+[arxiv]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_arxiv"
+class_name = "ArXivSearchEngine"
+requires_api_key = false
+reliability = 0.9
+strengths = [
+ "scientific papers", "academic research", "physics", "computer science",
+ "mathematics", "statistics", "machine learning", "preprints"
+]
+weaknesses = ["non-academic topics", "consumer products", "news", "general information"]
+
+[arxiv.default_params]
+max_results = 20
+sort_by = "relevance"
+sort_order = "descending"
+
+[pubmed]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_pubmed"
+class_name = "PubMedSearchEngine"
+requires_api_key = false
+api_key_env = "NCBI_API_KEY"
+reliability = 0.95
+strengths = [
+ "biomedical literature", "medical research", "clinical studies",
+ "life sciences", "health information", "scientific papers"
+]
+weaknesses = [
+ "non-medical topics", "very recent papers may be missing",
+ "limited to published research"
+]
+requires_llm = true
+
+[pubmed.default_params]
+max_results = 20
+get_abstracts = true
+get_full_text = false
+full_text_limit = 3
+days_limit = 0
+optimize_queries = true
+
+[github]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_github"
+class_name = "GitHubSearchEngine"
+requires_api_key = false
+reliability = 0.99
+strengths = [
+ "code repositories", "software documentation", "open source projects",
+ "programming issues", "developer information", "technical documentation"
+]
+weaknesses = ["non-technical content", "content outside GitHub", "rate limits without API key"]
+supports_full_search = true
+
+[github.default_params]
+max_results = 15
+search_type = "repositories"
+include_readme = true
+include_issues = false
+
+[serpapi]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_serpapi"
+class_name = "SerpAPISearchEngine"
+requires_api_key = true
+api_key_env = "SERP_API_KEY"
+reliability = 0.6
+strengths = [
+ "comprehensive web search", "product information", "reviews",
+ "recent content", "news", "broad coverage"
+]
+weaknesses = ["requires API key with usage limits", "not specialized for academic content"]
+supports_full_search = true
+full_search_module = "local_deep_research.web_search_engines.engines.full_serp_search_results_old"
+full_search_class = "FullSerpAPISearchResults"
+
+[serpapi.default_params]
+region = "us"
+time_period = "y"
+safe_search = true
+search_language = "English"
+
+[google_pse]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_google_pse"
+class_name = "GooglePSESearchEngine"
+requires_api_key = true
+api_key_env = "GOOGLE_PSE_API_KEY"
+reliability = 0.9
+strengths = [
+ "custom search scope", "high-quality results", "domain-specific search",
+ "configurable search experience", "control over search index"
+]
+weaknesses = [
+ "requires API key with usage limits",
+ "limited to 10,000 queries/day on free tier",
+ "requires search engine configuration in Google Control Panel"
+]
+supports_full_search = true
+full_search_module = "local_deep_research.web_search_engines.engines.full_search"
+full_search_class = "FullSearchResults"
+
+[google_pse.default_params]
+region = "us"
+safe_search = true
+search_language = "English"
+
+[brave]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_brave"
+class_name = "BraveSearchEngine"
+requires_api_key = true
+api_key_env = "BRAVE_API_KEY"
+reliability = 0.7
+strengths = [
+ "privacy-focused web search", "product information", "reviews",
+ "recent content", "news", "broad coverage"
+]
+weaknesses = ["requires API key with usage limits", "smaller index than Google"]
+supports_full_search = true
+full_search_module = "local_deep_research.web_search_engines.engines.full_search"
+full_search_class = "FullSearchResults"
+
+[brave.default_params]
+region = "US"
+time_period = "y"
+safe_search = true
+search_language = "English"
+
+[wayback]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_wayback"
+class_name = "WaybackSearchEngine"
+requires_api_key = false
+reliability = 0.5
+strengths = [
+ "historical web content", "archived websites", "content verification",
+ "deleted or changed web pages", "website evolution tracking"
+]
+weaknesses = [
+ "limited to previously archived content", "may miss recent changes",
+ "archiving quality varies"
+]
+supports_full_search = true
+
+[wayback.default_params]
+max_results = 15
+max_snapshots_per_url = 3
+closest_only = false
+language = "English"
+
+[auto]
+module_path = "local_deep_research.web_search_engines.engines.meta_search_engine"
+class_name = "MetaSearchEngine"
+requires_api_key = false
+reliability = 0.85
+strengths = [
+ "intelligent engine selection", "adaptable to query type",
+ "fallback capabilities"
+]
+weaknesses = ["slightly slower due to LLM analysis"]
+requires_llm = true
+
+[auto.default_params]
+use_api_key_services = true
+max_engines_to_try = 3
+
+[local_all]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_local_all"
+class_name = "LocalAllSearchEngine"
+requires_api_key = false
+reliability = 0.85
+strengths = ["searches all local collections", "personal documents", "offline access"]
+weaknesses = ["may return too many results", "requires indexing"]
+requires_llm = true
+
+# Default search engine to use if none specified
+DEFAULT_SEARCH_ENGINE = "wikipedia"
+
+# Additional search engines can be added below
+# Uncomment and modify these templates as needed
+
+# [duckduckgo]
+# module_path = "local_deep_research.web_search_engines.engines.search_engine_ddg"
+# class_name = "DuckDuckGoSearchEngine"
+# requires_api_key = false
+# reliability = 0.4
+# strengths = [
+# "web search", "product information", "reviews", "recent information",
+# "news", "general queries", "broad coverage"
+# ]
+# weaknesses = ["inconsistent due to rate limits", "not specialized for academic content"]
+# supports_full_search = true
+# full_search_module = "local_deep_research.web_search_engines.engines.full_search"
+# full_search_class = "FullSearchResults"
+#
+# [duckduckgo.default_params]
+# region = "us"
+# safe_search = true
+
+# [guardian]
+# module_path = "local_deep_research.web_search_engines.engines.search_engine_guardian"
+# class_name = "GuardianSearchEngine"
+# requires_api_key = true
+# api_key_env = "GUARDIAN_API_KEY"
+# reliability = 0.5
+# strengths = [
+# "news articles", "current events", "opinion pieces", "journalism",
+# "UK and global news", "political analysis"
+# ]
+# weaknesses = ["primarily focused on news", "limited historical content pre-1999"]
+#
+# [guardian.default_params]
+# order_by = "relevance"
+
+# [medrxiv]
+# module_path = "local_deep_research.web_search_engines.engines.search_engine_medrxiv"
+# class_name = "MedRxivSearchEngine"
+# requires_api_key = false
+# reliability = 0.85
+# strengths = [
+# "medical preprints", "health research", "covid-19 research",
+# "clinical studies", "medical sciences", "preliminary results"
+# ]
+# weaknesses = ["not peer-reviewed", "preliminary findings", "limited to medical research"]
+# requires_llm = true
+#
+# [medrxiv.default_params]
+# sort_by = "relevance_score"
+# sort_order = "desc"
+# include_full_text = false
+# optimize_queries = true
\ No newline at end of file
diff --git a/src/local_deep_research/web/app.py b/src/local_deep_research/web/app.py
index 1121b499e5..b9d92babe1 100644
--- a/src/local_deep_research/web/app.py
+++ b/src/local_deep_research/web/app.py
@@ -906,6 +906,66 @@ def api_keys_config_page():
secrets_file = CONFIG_DIR / ".secrets.toml"
return render_template('api_keys_config.html', secrets_file_path=secrets_file)
+# Add to the imports section
+from local_deep_research.config import SEARCH_ENGINES_FILE
+
+# Add a new route for search engines configuration page
+@research_bp.route('/settings/search_engines', methods=['GET'])
+def search_engines_config_page():
+ """Edit search engines configuration using raw file editor"""
+ # Read the current config file
+ raw_config = ""
+ try:
+ with open(SEARCH_ENGINES_FILE, 'r') as f:
+ raw_config = f.read()
+ except Exception as e:
+ flash(f'Error reading search engines configuration: {str(e)}', 'error')
+ raw_config = "# Error reading configuration file"
+
+ # Get list of engine names for display
+ engine_names = []
+ try:
+ from local_deep_research.web_search_engines.search_engines_config import SEARCH_ENGINES
+ engine_names = list(SEARCH_ENGINES.keys())
+ engine_names.sort() # Alphabetical order
+ except Exception as e:
+ logger.error(f"Error getting engine names: {e}")
+
+ return render_template('search_engines_config.html',
+ search_engines_file_path=SEARCH_ENGINES_FILE,
+ raw_config=raw_config,
+ engine_names=engine_names)
+
+# Add a route to save search engines configuration
+@research_bp.route('/api/save_search_engines_config', methods=['POST'])
+def save_search_engines_config():
+ try:
+ data = request.get_json()
+ raw_config = data.get('raw_config', '')
+
+ # Validate TOML syntax
+ try:
+ toml.loads(raw_config)
+ except toml.TomlDecodeError as e:
+ return jsonify({'success': False, 'error': f'TOML syntax error: {str(e)}'})
+
+ # Ensure directory exists
+ os.makedirs(os.path.dirname(SEARCH_ENGINES_FILE), exist_ok=True)
+
+ # Create a backup first
+ backup_path = f"{SEARCH_ENGINES_FILE}.bak"
+ if os.path.exists(SEARCH_ENGINES_FILE):
+ import shutil
+ shutil.copy2(SEARCH_ENGINES_FILE, backup_path)
+
+ # Write new config
+ with open(SEARCH_ENGINES_FILE, 'w') as f:
+ f.write(raw_config)
+
+ return jsonify({'success': True})
+ except Exception as e:
+ return jsonify({'success': False, 'error': str(e)})
+
# API endpoint to save raw LLM config
@research_bp.route('/api/save_llm_config', methods=['POST'])
diff --git a/src/local_deep_research/web/templates/search_engines_config.html b/src/local_deep_research/web/templates/search_engines_config.html
new file mode 100644
index 0000000000..4fc213dadd
--- /dev/null
+++ b/src/local_deep_research/web/templates/search_engines_config.html
@@ -0,0 +1,154 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Deep Research System - Search Engines</title>
+ <link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
+ <link rel="icon" type="image/png" href="{{ url_for('static', filename='favicon.ico') }}">
+</head>
+<body>
+ <div class="app-container">
+ <!-- Sidebar -->
+ <aside class="sidebar">
+ <!-- Sidebar content (keep as is) -->
+ </aside>
+
+ <!-- Main Content -->
+ <main class="main-content">
+ <div class="page active" id="search-engines-settings">
+ <div class="page-header">
+ <div class="results-header">
+ <h1>Search Engines Configuration</h1>
+ <div class="results-actions">
+ <a href="{{ url_for('research.settings_page') }}" class="btn btn-outline">
+ <i class="fas fa-arrow-left"></i> Back to Settings
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <div class="card">
+ <div class="card-content">
+ <h2>Search Engines Configuration File</h2>
+ <p>To edit your search engines configuration, open this file with your preferred text editor:</p>
+ <div class="file-path">{{ search_engines_file_path }}</div>
+
+ <button onclick="openFileLocation('{{ search_engines_file_path }}')" class="btn btn-primary">
+ <i class="fas fa-folder-open"></i> Open Containing Folder
+ </button>
+
+ <h3 class="mt-4">Edit Raw Configuration</h3>
+ <div id="editor-container">
+ <div class="editor-header">
+ <h3>Search Engines Configuration (TOML format)</h3>
+ <span class="editor-lang">TOML</span>
+ </div>
+ <textarea id="raw_config_editor" class="config-raw-editor" rows="25">{{ raw_config }}</textarea>
+ <div class="form-actions">
+ <button type="button" class="btn btn-primary" onclick="saveRawConfig()">
+ <i class="fas fa-save"></i> Save Configuration
+ </button>
+ <button type="button" class="btn btn-outline" onclick="resetEditor()">
+ <i class="fas fa-undo"></i> Reset Changes
+ </button>
+ </div>
+ </div>
+
+ <h3 class="mt-4">Structure Reference</h3>
+ <p>Search engines are defined in TOML format with the following structure:</p>
+ <pre class="config-example">
+# Define a search engine named "example_engine"
+[example_engine]
+module_path = "local_deep_research.web_search_engines.engines.search_engine_example"
+class_name = "ExampleSearchEngine"
+requires_api_key = false # or true if API key is required
+reliability = 0.9 # Value between 0 and 1
+strengths = ["strength1", "strength2"] # Array of strengths
+weaknesses = ["weakness1", "weakness2"] # Array of weaknesses
+supports_full_search = true # Whether this engine supports retrieving full content
+
+# Optional: Define which API key environment variable to use
+api_key_env = "EXAMPLE_API_KEY" # Only needed if requires_api_key is true
+
+# Default parameters for this search engine
+[example_engine.default_params]
+max_results = 20
+param1 = "value1"
+param2 = true
+
+# Special setting to define the default search engine
+DEFAULT_SEARCH_ENGINE = "wikipedia"
+ </pre>
+
+ <h3 class="mt-4">Available Search Engines</h3>
+ <p>The following search engines are currently defined:</p>
+ <ul id="available-engines">
+ {% for engine_name in engine_names %}
+ <li><strong>{{ engine_name }}</strong></li>
+ {% endfor %}
+ </ul>
+
+ <div class="alert alert-info mt-4">
+ <i class="fas fa-info-circle"></i> Changes to search engines configuration will take effect after restarting the application.
+ </div>
+ </div>
+ </div>
+ </div>
+ </main>
+ </div>
+
+ <script>
+ // Original config for reset functionality
+ const originalConfig = document.getElementById('raw_config_editor').value;
+
+ function openFileLocation(filePath) {
+ // Create a hidden form and submit it to a route that will open the file location
+ const form = document.createElement('form');
+ form.method = 'POST';
+ form.action = "{{ url_for('research.open_file_location') }}";
+
+ const input = document.createElement('input');
+ input.type = 'hidden';
+ input.name = 'file_path';
+ input.value = filePath;
+
+ form.appendChild(input);
+ document.body.appendChild(form);
+ form.submit();
+ }
+
+ function resetEditor() {
+ if (confirm('Are you sure you want to reset all changes?')) {
+ document.getElementById('raw_config_editor').value = originalConfig;
+ }
+ }
+
+ function saveRawConfig() {
+ const rawConfig = document.getElementById('raw_config_editor').value;
+
+ fetch('{{ url_for("research.save_search_engines_config") }}', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ raw_config: rawConfig }),
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ alert('Configuration saved successfully. Changes will take effect after restarting the application.');
+ // Reload the page to refresh the content
+ window.location.reload();
+ } else {
+ alert('Error saving configuration: ' + data.error);
+ }
+ })
+ .catch(error => {
+ alert('Error saving configuration: ' + error);
+ });
+ }
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/src/local_deep_research/web/templates/settings_dashboard.html b/src/local_deep_research/web/templates/settings_dashboard.html
index 7b2ece5576..8ef8fd7e1b 100644
--- a/src/local_deep_research/web/templates/settings_dashboard.html
+++ b/src/local_deep_research/web/templates/settings_dashboard.html
@@ -154,6 +154,22 @@
</div>
</div>
</div>
+ <div class="card settings-card">
+ <div class="card-content">
+ <div class="settings-icon">
+ <i class="fas fa-search-plus"></i>
+ </div>
+ <h3 class="settings-title">Search Engines Settings</h3>
+ <p class="settings-description">
+ Configure search engines, their parameters, and specify which search engines to use for different types of queries.
+ </p>
+ <div class="card-actions">
+ <a href="{{ url_for('research.search_engines_config_page') }}" class="btn btn-primary">
+ <i class="fas fa-cog"></i> Configure
+ </a>
+ </div>
+ </div>
+ </div>
</div>
</div>
</main>
diff --git a/src/local_deep_research/web_search_engines/search_engines_config.py b/src/local_deep_research/web_search_engines/search_engines_config.py
index 9bb1384127..e70902dce4 100644
--- a/src/local_deep_research/web_search_engines/search_engines_config.py
+++ b/src/local_deep_research/web_search_engines/search_engines_config.py
@@ -1,260 +1,54 @@
"""
Configuration file for search engines.
-Add or modify search engines here without changing code elsewhere.
+Loads search engine definitions from the user's configuration.
"""
import logging
-logger = logging.getLogger(__name__)
-
-# Registry of all available search engines
-SEARCH_ENGINES = {
- # Wikipedia search engine
- "wikipedia": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_wikipedia",
- "class_name": "WikipediaSearchEngine",
- "requires_api_key": False,
- "reliability": 0.95,
- "strengths": ["factual information", "general knowledge", "definitions",
- "historical facts", "biographies", "overview information"],
- "weaknesses": ["recent events", "specialized academic topics", "product comparisons"],
- "default_params": {
- "max_results": 20,
- "include_content": True
- }
- },
-
- # arXiv search engine
- "arxiv": {
-
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_arxiv",
- "class_name": "ArXivSearchEngine",
- "requires_api_key": False,
- "reliability": 0.9,
- "strengths": ["scientific papers", "academic research", "physics", "computer science",
- "mathematics", "statistics", "machine learning", "preprints"],
- "weaknesses": ["non-academic topics", "consumer products", "news", "general information"],
- "default_params": {
- "max_results": 20,
- "sort_by": "relevance",
- "sort_order": "descending"
- }
- },
+import os
+import toml
+from pathlib import Path
+from local_deep_research.config import CONFIG_DIR
- # medRxiv search engine
- #"medrxiv": {
- # "module_path": "local_deep_research.web_search_engines.engines.search_engine_medrxiv",
- # "class_name": "MedRxivSearchEngine",
- # "requires_api_key": False,
- # "reliability": 0.85,
- # "strengths": ["medical preprints", "health research", "covid-19 research",
- # "clinical studies", "medical sciences", "preliminary results"],
- # "weaknesses": ["not peer-reviewed", "preliminary findings", "limited to medical research"],
- # "default_params": {
- # "sort_by": "relevance_score",
- # "sort_order": "desc",
- # "include_full_text": False,
- # "optimize_queries": True # Use LLM to optimize natural language queries
- # },
- # "requires_llm": True # Needs LLM for query optimization
- #},
- # PubMed search engine
- "pubmed": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_pubmed",
- "class_name": "PubMedSearchEngine",
- "requires_api_key": False, # Works without API key but with rate limits
- "api_key_env": "NCBI_API_KEY", # Optional for higher rate limits
- "reliability": 0.95,
- "strengths": ["biomedical literature", "medical research", "clinical studies",
- "life sciences", "health information", "scientific papers"],
- "weaknesses": ["non-medical topics", "very recent papers may be missing",
- "limited to published research"],
- "default_params": {
- "max_results": 20,
- "get_abstracts": True,
- "get_full_text": False, # Default to abstracts only, not full text
- "full_text_limit": 3, # Limit full text retrieval to top 3 articles when enabled
- "days_limit": None, # No default time limit
- "optimize_queries": True # Use LLM to optimize natural language queries
- },
- "requires_llm": True # Needs LLM for query optimization
- },
- # GitHub search engine
- "github": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_github",
- "class_name": "GitHubSearchEngine",
- "requires_api_key": False, # Works without API key but rate limited
- #"api_key_env": "GITHUB_API_KEY",
- "reliability": 0.99,
- "strengths": ["code repositories", "software documentation", "open source projects",
- "programming issues", "developer information", "technical documentation"],
- "weaknesses": ["non-technical content", "content outside GitHub", "rate limits without API key"],
- "default_params": {
- "max_results": 15,
- "search_type": "repositories", # Options: "repositories", "code", "issues", "users"
- "include_readme": True,
- "include_issues": False
- },
- "supports_full_search": True
- },
- # DuckDuckGo search engine
- # "duckduckgo": {
- # "module_path": "local_deep_research.web_search_engines.engines.search_engine_ddg",
- # "class_name": "DuckDuckGoSearchEngine",
- # "requires_api_key": False,
- # "reliability": 0.4,
- # "strengths": ["web search", "product information", "reviews", "recent information",
- # "news", "general queries", "broad coverage"],
- # "weaknesses": ["inconsistent due to rate limits", "not specialized for academic content"],
- # "default_params": {
- # "region": "us",
- # "safe_search": True
- # },
- # "supports_full_search": True,
- # "full_search_module": "local_deep_research.web_search_engines.engines.full_search",
- # "full_search_class": "FullSearchResults"
- # },
-
- # SerpAPI search engine
- "serpapi": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_serpapi",
- "class_name": "SerpAPISearchEngine",
- "requires_api_key": True,
- "api_key_env": "SERP_API_KEY",
- "reliability": 0.6,
- "strengths": ["comprehensive web search", "product information", "reviews",
- "recent content", "news", "broad coverage"],
- "weaknesses": ["requires API key with usage limits", "not specialized for academic content"],
- "default_params": {
- "region": "us",
- "time_period": "y",
- "safe_search": True,
- "search_language": "English"
- },
- "supports_full_search": True,
- "full_search_module": "local_deep_research.web_search_engines.engines.full_serp_search_results_old",
- "full_search_class": "FullSerpAPISearchResults"
- },
-
- # Google Programmable Search Engine
- "google_pse": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_google_pse",
- "class_name": "GooglePSESearchEngine",
- "requires_api_key": True,
- "api_key_env": "GOOGLE_PSE_API_KEY",
- "reliability": 0.9,
- "strengths": ["custom search scope", "high-quality results", "domain-specific search",
- "configurable search experience", "control over search index"],
- "weaknesses": ["requires API key with usage limits", "limited to 10,000 queries/day on free tier",
- "requires search engine configuration in Google Control Panel"],
- "default_params": {
- "region": "us",
- "safe_search": True,
- "search_language": "English"
- },
- "supports_full_search": True,
- "full_search_module": "local_deep_research.web_search_engines.engines.full_search",
- "full_search_class": "FullSearchResults"
- },
-
- # Brave search engine
- "brave": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_brave",
- "class_name": "BraveSearchEngine",
- "requires_api_key": True,
- "api_key_env": "BRAVE_API_KEY",
- "reliability": 0.7,
- "strengths": ["privacy-focused web search", "product information", "reviews",
- "recent content", "news", "broad coverage"],
- "weaknesses": ["requires API key with usage limits", "smaller index than Google"],
- "default_params": {
- "region": "US",
- "time_period": "y",
- "safe_search": True,
- "search_language": "English"
- },
- "supports_full_search": True,
- "full_search_module": "local_deep_research.web_search_engines.engines.full_search",
- "full_search_class": "FullSearchResults"
- },
+logger = logging.getLogger(__name__)
- # The Guardian search engine - search seem to often provide irrelevant results.
- #"guardian": {
- # "module_path": "local_deep_research.web_search_engines.engines.search_engine_guardian",
- # "class_name": "GuardianSearchEngine",
- # "requires_api_key": True,
- # "api_key_env": "GUARDIAN_API_KEY",
- # "reliability": 0.5,
- # "strengths": ["news articles", "current events", "opinion pieces", "journalism",
- # "UK and global news", "political analysis"],
- # "weaknesses": ["primarily focused on news", "limited historical content pre-1999"],
- # "default_params": {
- # "order_by": "relevance"
- # }
- #},
- # Wayback Machine search engine - not sure if it is usefull
- "wayback": {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_wayback",
- "class_name": "WaybackSearchEngine",
- "requires_api_key": False,
- "reliability": 0.5,
- "strengths": ["historical web content", "archived websites", "content verification",
- "deleted or changed web pages", "website evolution tracking"],
- "weaknesses": ["limited to previously archived content", "may miss recent changes",
- "archiving quality varies"],
- "default_params": {
- "max_results": 15,
- "max_snapshots_per_url": 3,
- "closest_only": False,
- "language": "English"
- },
- "supports_full_search": True
- },
- # Meta search engine (intelligent engine selection)
- "auto": {
- "module_path": "local_deep_research.web_search_engines.engines.meta_search_engine",
- "class_name": "MetaSearchEngine",
- "requires_api_key": False,
- "reliability": 0.85,
- "strengths": ["intelligent engine selection", "adaptable to query type", "fallback capabilities"],
- "weaknesses": ["slightly slower due to LLM analysis"],
- "default_params": {
- "use_api_key_services": True,
- "max_engines_to_try": 3
- },
- "requires_llm": True
- }
-}
+# Get search engines configuration directly from TOML file
+SEARCH_ENGINES = {}
+DEFAULT_SEARCH_ENGINE = "wikipedia" # Default fallback if not specified in config
-# Add 'auto' as an alias for 'meta'
-SEARCH_ENGINES["auto"] = SEARCH_ENGINES["auto"]
+# Path to the search engines configuration file
+SEARCH_ENGINES_FILE = CONFIG_DIR / "search_engines.toml"
-# Default search engine to use if none specified
-DEFAULT_SEARCH_ENGINE = "wikipedia"
+# Load directly from TOML file
+if os.path.exists(SEARCH_ENGINES_FILE):
+ try:
+ # Load the TOML file directly
+ config_data = toml.load(SEARCH_ENGINES_FILE)
+
+ # Extract search engine definitions
+ for key, value in config_data.items():
+ if key == "DEFAULT_SEARCH_ENGINE":
+ DEFAULT_SEARCH_ENGINE = value
+ elif isinstance(value, dict):
+ SEARCH_ENGINES[key] = value
+
+ logger.info(f"Loaded {len(SEARCH_ENGINES)} search engines from configuration file")
+ except Exception as e:
+ logger.error(f"Error loading search engines from TOML file: {e}")
+else:
+ logger.warning(f"Search engines configuration file not found: {SEARCH_ENGINES_FILE}")
+# Add alias for 'auto' if it exists
+if 'auto' in SEARCH_ENGINES and 'meta' not in SEARCH_ENGINES:
+ SEARCH_ENGINES['meta'] = SEARCH_ENGINES['auto']
+# Register local document collections
try:
from local_deep_research.local_collections import register_local_collections
-
- # Register all enabled local collections as search engines
register_local_collections(SEARCH_ENGINES)
-
logger.info(f"Registered local document collections as search engines")
except ImportError:
logger.info("No local collections configuration found. Local document search is disabled.")
-
-# Optionally, also register a "local_all" search engine that searches all collections
-# This is useful when users want to search across all their local collections
-SEARCH_ENGINES["local_all"] = {
- "module_path": "local_deep_research.web_search_engines.engines.search_engine_local_all",
- "class_name": "LocalAllSearchEngine",
- "requires_api_key": False,
- "reliability": 0.85,
- "strengths": ["searches all local collections", "personal documents", "offline access"],
- "weaknesses": ["may return too many results", "requires indexing"],
- "default_params": {},
- "requires_llm": True
-}
-# Ensure the meta search engine is still available at the end
-meta_config = SEARCH_ENGINES["auto"]
-del SEARCH_ENGINES["auto"]
-SEARCH_ENGINES["auto"] = meta_config
+# Ensure the meta search engine is still available at the end if it exists
+if 'auto' in SEARCH_ENGINES:
+ meta_config = SEARCH_ENGINES["auto"]
+ SEARCH_ENGINES["auto"] = meta_config
\ No newline at end of file