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.

working on advanced search system

LearningCircuitc8468d1bc95c
diff --git a/src/local_deep_research/advanced_search_system/findings/base_findings.py b/src/local_deep_research/advanced_search_system/findings/base_findings.py
index d7d821188e..13e19ed1b4 100644
--- a/src/local_deep_research/advanced_search_system/findings/base_findings.py
+++ b/src/local_deep_research/advanced_search_system/findings/base_findings.py
@@ -59,7 +59,11 @@ class BaseFindingsRepository(ABC):
@abstractmethod
def synthesize_findings(
- self, query: str, sub_queries: List[str], findings: List[str]
+ self,
+ query: str,
+ sub_queries: List[str],
+ findings: List[str],
+ accumulated_knowledge: str,
) -> str:
"""
Synthesize findings from sub-queries into a final answer.
diff --git a/src/local_deep_research/advanced_search_system/findings/repository.py b/src/local_deep_research/advanced_search_system/findings/repository.py
index 3d9b649e09..09095fcadb 100644
--- a/src/local_deep_research/advanced_search_system/findings/repository.py
+++ b/src/local_deep_research/advanced_search_system/findings/repository.py
@@ -143,7 +143,12 @@ class FindingsRepository(BaseFindingsRepository):
return f"Error during final formatting. Raw Synthesized Content:\n\n{synthesized_content}"
def synthesize_findings(
- self, query: str, sub_queries: List[str], findings: List[str]
+ self,
+ query: str,
+ sub_queries: List[str],
+ findings: List[str],
+ accumulated_knowledge: str,
+ old_formatting=True,
) -> str:
"""
Synthesize accumulated knowledge into a final answer.
@@ -156,6 +161,13 @@ class FindingsRepository(BaseFindingsRepository):
Returns:
str: Synthesized final answer content.
"""
+ if old_formatting:
+ return format_findings(
+ findings_list=findings,
+ current_knowledge=accumulated_knowledge,
+ questions_by_iteration=self.questions_by_iteration,
+ )
+
try:
# Convert findings list to accumulated knowledge string
current_knowledge = "\n\n".join(findings) if findings else ""
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 9b2f38c9dc..d49b45ad10 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
@@ -250,7 +250,10 @@ Initial Search Results:
# Synthesize findings into a final answer
final_answer = self.findings_repository.synthesize_findings(
- query, sub_queries, finding_contents
+ query,
+ sub_queries,
+ finding_contents,
+ accumulated_knowledge=current_knowledge,
)
# Create a synthesis finding
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 408b319c0a..8c2a2c654f 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
@@ -268,18 +268,17 @@ class StandardSearchStrategy(BaseSearchStrategy):
{"phase": "iteration_complete", "iteration": iteration},
)
- try:
- # Extract content from findings for synthesis
- finding_contents = [f["content"] for f in findings if "content" in f]
-
- formatted_findings = self.findings_repository.synthesize_findings(
- query, finding_contents, finding_contents
- )
- # Add the formatted findings to the repository
- self.findings_repository.add_finding(query, formatted_findings)
- except Exception as e:
- logger.error(f"Error saving findings: {str(e)}")
- formatted_findings = "Error: Could not format findings due to an error."
+ # Extract content from findings for synthesis
+ finding_contents = [f["content"] for f in findings if "content" in f]
+
+ formatted_findings = self.findings_repository.synthesize_findings(
+ query,
+ finding_contents,
+ finding_contents,
+ accumulated_knowledge=current_knowledge,
+ )
+ # Add the formatted findings to the repository
+ self.findings_repository.add_finding(query, formatted_findings)
self._update_progress("Research complete", 95, {"phase": "complete"})
diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.py
index c9178b5a4f..1be4caf42f 100644
--- a/src/local_deep_research/search_system.py
+++ b/src/local_deep_research/search_system.py
@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
class AdvancedSearchSystem:
- def __init__(self, strategy_name: str = "iterdrag"):
+ def __init__(self, strategy_name: str = "standard"):
"""
Initialize the advanced search system.
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index d3691b20b1..623dc09762 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -348,6 +348,32 @@ def run_research_process(
# Quick Summary
if results.get("findings") or results.get("formatted_findings"):
raw_formatted_findings = results["formatted_findings"]
+
+ # Check if formatted_findings contains an error message
+ if isinstance(
+ raw_formatted_findings, str
+ ) and raw_formatted_findings.startswith("Error:"):
+ # Extract synthesized content from findings if available
+ synthesized_content = ""
+ for finding in results.get("findings", []):
+ if finding.get("phase") == "Final synthesis":
+ synthesized_content = finding.get("content", "")
+ break
+
+ # Use synthesized content as fallback
+ if synthesized_content:
+ raw_formatted_findings = synthesized_content
+ # Or use current_knowledge as another fallback
+ elif results.get("current_knowledge"):
+ raw_formatted_findings = results["current_knowledge"]
+ # Or combine all finding contents as last resort
+ elif results.get("findings"):
+ raw_formatted_findings = "\n\n".join(
+ f"## {finding.get('phase', 'Finding')}\n\n{finding.get('content', '')}"
+ for finding in results.get("findings", [])
+ if finding.get("content")
+ )
+
logger.info(
f"Found formatted_findings of length: {len(str(raw_formatted_findings))}"
)