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.

fixed sources from old searches

LearningCircuitfd32c3ea3d3c
diff --git a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
index 42c11eb07a..6f3aba11d1 100644
--- a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
@@ -13,11 +13,14 @@ logger = logging.getLogger(__name__)
class BaseSearchStrategy(ABC):
"""Abstract base class for all search strategies."""
- def __init__(self, all_links_of_system=[]):
+ def __init__(self, all_links_of_system=None):
"""Initialize the base strategy with common attributes."""
self.progress_callback = None
self.questions_by_iteration = {}
- self.all_links_of_system = all_links_of_system
+ # Create a new list if None is provided (avoiding mutable default argument)
+ self.all_links_of_system = (
+ all_links_of_system if all_links_of_system is not None else []
+ )
def set_progress_callback(self, callback: Callable[[str, int, dict], None]) -> None:
"""Set a callback function to receive progress updates."""
diff --git a/src/local_deep_research/advanced_search_system/strategies/iterdrag_strategy.py b/src/local_deep_research/advanced_search_system/strategies/iterdrag_strategy.py
index 09c1a73d8e..93d2452bba 100644
--- a/src/local_deep_research/advanced_search_system/strategies/iterdrag_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/iterdrag_strategy.py
@@ -7,8 +7,6 @@ import logging
from datetime import datetime
from typing import Dict, List
-from langchain_core.language_models import BaseLLM
-
from ...citation_handler import CitationHandler
from ...config.llm_config import get_llm
from ...config.search_config import get_search
@@ -26,18 +24,34 @@ class IterDRAGStrategy(BaseSearchStrategy):
"""IterDRAG strategy that breaks queries into sub-queries."""
def __init__(
- self, model: BaseLLM | None = None, search=None, citation_handler=None
+ self,
+ search=None,
+ model=None,
+ max_iterations=3,
+ subqueries_per_iteration=2,
+ all_links_of_system=None,
):
- """Initialize the strategy with optional dependency injection for testing."""
- super().__init__()
- self.model = model or get_llm()
+ """Initialize the IterDRAG strategy with search and LLM.
+
+ Args:
+ search: Search engine to use for web queries
+ model: LLM to use for text generation and reasoning
+ max_iterations: Maximum number of iterations to run
+ subqueries_per_iteration: Number of sub-queries to generate per iteration
+ all_links_of_system: Optional list of links to initialize with
+ """
+ super().__init__(all_links_of_system=all_links_of_system)
self.search = search or get_search()
+ self.model = model or get_llm()
+ self.max_iterations = max_iterations
+ self.subqueries_per_iteration = subqueries_per_iteration
+
+ # Initialize progress callback
self.progress_callback = None
- self.all_links_of_system = list()
self.questions_by_iteration = {}
# Use provided citation_handler or create one
- self.citation_handler = citation_handler or CitationHandler(self.model)
+ self.citation_handler = CitationHandler(self.model)
# Initialize components
self.question_generator = DecompositionQuestionGenerator(self.model)
diff --git a/src/local_deep_research/advanced_search_system/strategies/parallel_search_strategy.py b/src/local_deep_research/advanced_search_system/strategies/parallel_search_strategy.py
index 9bce663f09..84591670be 100644
--- a/src/local_deep_research/advanced_search_system/strategies/parallel_search_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/parallel_search_strategy.py
@@ -35,6 +35,7 @@ class ParallelSearchStrategy(BaseSearchStrategy):
filter_reorder: bool = True,
filter_reindex: bool = True,
filter_max_results: int = 20,
+ all_links_of_system=None,
):
"""Initialize with optional dependency injection for testing.
@@ -47,12 +48,12 @@ class ParallelSearchStrategy(BaseSearchStrategy):
filter_reorder: Whether to reorder results by relevance
filter_reindex: Whether to update result indices after filtering
filter_max_results: Maximum number of results to keep after filtering
+ all_links_of_system: Optional list of links to initialize with
"""
- super().__init__()
+ super().__init__(all_links_of_system=all_links_of_system)
self.search = search or get_search()
self.model = model or get_llm()
self.progress_callback = None
- self.all_links_of_system = list()
self.questions_by_iteration = {}
self.include_text_content = include_text_content
self.use_cross_engine_filter = use_cross_engine_filter
diff --git a/src/local_deep_research/advanced_search_system/strategies/rapid_search_strategy.py b/src/local_deep_research/advanced_search_system/strategies/rapid_search_strategy.py
index b88e226674..af2bf6b6ef 100644
--- a/src/local_deep_research/advanced_search_system/strategies/rapid_search_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/rapid_search_strategy.py
@@ -23,13 +23,14 @@ class RapidSearchStrategy(BaseSearchStrategy):
a single synthesis step at the end, optimized for speed.
"""
- def __init__(self, search=None, model=None, citation_handler=None):
+ def __init__(
+ self, search=None, model=None, citation_handler=None, all_links_of_system=None
+ ):
"""Initialize with optional dependency injection for testing."""
- super().__init__()
+ super().__init__(all_links_of_system=all_links_of_system)
self.search = search or get_search()
self.model = model or get_llm()
self.progress_callback = None
- self.all_links_of_system = list()
self.questions_by_iteration = {}
# Use provided citation_handler or create one
diff --git a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
index 4494a969db..37270be6dc 100644
--- a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
@@ -30,9 +30,10 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
filter_reorder: bool = True,
filter_reindex: bool = True,
filter_max_results: int = 20,
- all_links_of_system: list = [],
+ all_links_of_system=None,
):
"""Initialize with optional dependency injection for testing."""
+ # Pass the links list to the parent class
super().__init__(all_links_of_system=all_links_of_system)
self.search = search or get_search()
self.model = model or get_llm()
diff --git a/src/local_deep_research/advanced_search_system/strategies/standard_strategy.py b/src/local_deep_research/advanced_search_system/strategies/standard_strategy.py
index f81381bec6..f4c6bf325e 100644
--- a/src/local_deep_research/advanced_search_system/strategies/standard_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/standard_strategy.py
@@ -19,8 +19,11 @@ logger = logging.getLogger(__name__)
class StandardSearchStrategy(BaseSearchStrategy):
"""Standard iterative search strategy that generates follow-up questions."""
- def __init__(self, search=None, model=None, citation_handler=None):
+ def __init__(
+ self, search=None, model=None, citation_handler=None, all_links_of_system=None
+ ):
"""Initialize with optional dependency injection for testing."""
+ super().__init__(all_links_of_system=all_links_of_system)
self.search = search or get_search()
self.model = model or get_llm()
self.max_iterations = int(get_db_setting("search.iterations"))
@@ -42,7 +45,6 @@ class StandardSearchStrategy(BaseSearchStrategy):
# Initialize other attributes
self.progress_callback = None
- self.all_links_of_system = list()
def _update_progress(
self, message: str, progress_percent: int = None, metadata: dict = None
diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.py
index e29c5701ce..5b162a335a 100644
--- a/src/local_deep_research/search_system.py
+++ b/src/local_deep_research/search_system.py
@@ -79,7 +79,11 @@ class AdvancedSearchSystem:
# Initialize strategy based on name
if strategy_name.lower() == "iterdrag":
logger.info("Creating IterDRAGStrategy instance")
- self.strategy = IterDRAGStrategy(model=self.model, search=self.search)
+ self.strategy = IterDRAGStrategy(
+ model=self.model,
+ search=self.search,
+ all_links_of_system=self.all_links_of_system,
+ )
elif strategy_name.lower() == "source-based":
logger.info("Creating SourceBasedSearchStrategy instance")
self.strategy = SourceBasedSearchStrategy(
@@ -87,6 +91,7 @@ class AdvancedSearchSystem:
search=self.search,
include_text_content=include_text_content,
use_cross_engine_filter=use_cross_engine_filter,
+ all_links_of_system=self.all_links_of_system,
)
elif strategy_name.lower() == "parallel":
logger.info("Creating ParallelSearchStrategy instance")
@@ -95,13 +100,22 @@ class AdvancedSearchSystem:
search=self.search,
include_text_content=include_text_content,
use_cross_engine_filter=use_cross_engine_filter,
+ all_links_of_system=self.all_links_of_system,
)
elif strategy_name.lower() == "rapid":
logger.info("Creating RapidSearchStrategy instance")
- self.strategy = RapidSearchStrategy(model=self.model, search=self.search)
+ self.strategy = RapidSearchStrategy(
+ model=self.model,
+ search=self.search,
+ all_links_of_system=self.all_links_of_system,
+ )
else:
logger.info("Creating StandardSearchStrategy instance")
- self.strategy = StandardSearchStrategy(model=self.model, search=self.search)
+ self.strategy = StandardSearchStrategy(
+ model=self.model,
+ search=self.search,
+ all_links_of_system=self.all_links_of_system,
+ )
# Log the actual strategy class
logger.info(f"Created strategy of type: {type(self.strategy).__name__}")