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.

Get local search to work correctly.

Daniel Petti43aee2f95d8e
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_local.py b/src/local_deep_research/web_search_engines/engines/search_engine_local.py
index 8a0529806c..5bb6ff6a12 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_local.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_local.py
@@ -175,6 +175,10 @@ class LocalEmbeddingManager:
def _get_folder_hash(self, folder_path: str) -> str:
"""Generate a hash for a folder based on its path"""
+ # Strip trailing slashes if we have them.
+ if folder_path.endswith("/"):
+ folder_path = folder_path[:-1]
+
return hashlib.md5(folder_path.encode()).hexdigest()
def _get_index_path(self, folder_path: str) -> Path:
@@ -491,7 +495,7 @@ class LocalSearchEngine(BaseSearchEngine):
def __init__(
self,
- folder_paths: List[str],
+ paths: List[str],
llm: Optional[BaseLLM] = None,
max_results: int = 10,
max_filtered_results: Optional[int] = None,
@@ -509,7 +513,7 @@ class LocalSearchEngine(BaseSearchEngine):
Initialize the local search engine.
Args:
- folder_paths: List of folder paths to search in
+ paths: List of folder paths to search in
llm: Language model for relevance filtering
max_results: Maximum number of results to return
max_filtered_results: Maximum results after filtering
@@ -527,21 +531,21 @@ class LocalSearchEngine(BaseSearchEngine):
super().__init__(llm=llm, max_filtered_results=max_filtered_results)
# Validate folder paths
- self.folder_paths = folder_paths
+ self.folder_paths = paths
self.valid_folder_paths = []
- for path in folder_paths:
+ for path in paths:
if os.path.exists(path) and os.path.isdir(path):
self.valid_folder_paths.append(path)
else:
logger.warning(f"Folder not found or is not a directory: {path}")
# If no valid folders, log a clear message
- if not self.valid_folder_paths and folder_paths:
- logger.warning(f"No valid folders found among: {folder_paths}")
+ if not self.valid_folder_paths and paths:
+ logger.warning(f"No valid folders found among: {paths}")
logger.warning("This search engine will return no results until valid folders are configured")
self.max_results = max_results
- self.collections = collections or {"default": {"paths": folder_paths, "description": "Default collection"}}
+ self.collections = collections or {"default": {"paths": paths, "description": "Default collection"}}
# Initialize the embedding manager with only valid folders
self.embedding_manager = LocalEmbeddingManager(
@@ -885,7 +889,7 @@ class LocalSearchEngine(BaseSearchEngine):
cache_dir = config_dict.get("cache_dir", ".cache/local_search")
return cls(
- folder_paths=folder_paths,
+ paths=folder_paths,
collections=collections,
llm=llm,
max_results=max_results,
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_local_all.py b/src/local_deep_research/web_search_engines/engines/search_engine_local_all.py
index da49c0902a..2e63cfbd9b 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_local_all.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_local_all.py
@@ -4,11 +4,13 @@ Search engine that searches across all local collections
import logging
from typing import Dict, List, Any, Optional
+
+import toml
from langchain_core.language_models import BaseLLM
from local_deep_research.web_search_engines.search_engine_base import BaseSearchEngine
from local_deep_research.web_search_engines.search_engine_factory import create_search_engine
-from local_deep_research import config
+from local_deep_research.config import LOCAL_COLLECTIONS_FILE
# Setup logging
logger = logging.getLogger(__name__)
@@ -18,7 +20,7 @@ class LocalAllSearchEngine(BaseSearchEngine):
Search engine that searches across all local document collections.
Acts as a meta search engine specifically for local collections.
"""
-
+
def __init__(
self,
llm: Optional[BaseLLM] = None,
@@ -41,9 +43,9 @@ class LocalAllSearchEngine(BaseSearchEngine):
# Find all local collection search engines
self.local_engines = {}
try:
- from local_collections import LOCAL_COLLECTIONS
-
- for collection_id, collection in LOCAL_COLLECTIONS.items():
+ local_collections = toml.load(LOCAL_COLLECTIONS_FILE)
+
+ for collection_id, collection in local_collections.items():
if not collection.get("enabled", True):
continue
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 e70902dce4..45fbb04951 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
@@ -6,7 +6,7 @@ import logging
import os
import toml
from pathlib import Path
-from local_deep_research.config import CONFIG_DIR
+from local_deep_research.config import CONFIG_DIR, LOCAL_COLLECTIONS_FILE
logger = logging.getLogger(__name__)
@@ -41,12 +41,23 @@ 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_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.")
+if os.path.exists(LOCAL_COLLECTIONS_FILE):
+ try:
+ local_collections_data = toml.load(LOCAL_COLLECTIONS_FILE)
+
+ for collection, config in local_collections_data.items():
+ SEARCH_ENGINES[collection] = dict(
+ module_path="local_deep_research.web_search_engines.engines"
+ ".search_engine_local",
+ class_name="LocalSearchEngine",
+ default_params=config,
+ requires_llm=True
+ )
+ logger.info(f"Registered local document collections as search engines")
+ except Exception as e:
+ logger.error(f"Error loading local collections from TOML file: {e}")
+else:
+ logger.warning(f"Local collections configuration file not found: {LOCAL_COLLECTIONS_FILE}")
# Ensure the meta search engine is still available at the end if it exists
if 'auto' in SEARCH_ENGINES: