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.

merged again

LearningCircuited59674a3988
diff --cc README.md
index b5c6ac3486,c7a5cd4ccf..84c10402ae
--- a/README.md
+++ b/README.md
@@@ -65,10 -66,10 +66,10 @@@ This example showcases the system's abi
1. Clone the repository:
```bash
- git clone https://github.com/yourusername/local-deep-research.git
+ git clone https://github.com/LearningCircuit/local-deep-research.git
cd local-deep-research
```
-
+(experimental pip install with new features (but not so well tested yet): **pip install local-deep-research** )
2. Install dependencies:
```bash
pip install -r requirements.txt
diff --cc src/local_deep_research/search_system.py
index 77541a8a0b,ae5c49e315..954eb38265
--- a/src/local_deep_research/search_system.py
+++ b/src/local_deep_research/search_system.py
@@@ -25,9 -20,12 +25,14 @@@ class AdvancedSearchSystem
self.citation_handler = CitationHandler(self.model)
self.progress_callback = None
self.all_links_of_system = list()
+
+ # Check if search is available, log warning if not
+ if self.search is None:
+ print("WARNING: Search system initialized with no search engine! Research will not be effective.")
+ self._update_progress("WARNING: No search engine available", None, {"error": "No search engine configured properly"})
+
+
def set_progress_callback(self, callback: Callable[[str, int, dict], None]) -> None:
"""Set a callback function to receive progress updates.
@@@ -155,50 -180,63 +191,108 @@@
int(question_progress_base + 5),
{"phase": "analysis"})
print("NR OF SOURCES: ", len(self.all_links_of_system))
++<<<<<<< HEAD:src/local_deep_research/search_system.py
+ result = self.citation_handler.analyze_followup(
+ question, search_results, current_knowledge, nr_of_links=len(self.all_links_of_system)
+ )
+ links = extract_links_from_search_results(search_results)
+ self.all_links_of_system.extend(links)
+ section_links.extend(links)
+ formatted_links = ""
+ if links:
+ formatted_links=format_links(links=links)
+
+ logger.debug(f"Generated questions: {formatted_links}")
+ if result is not None:
+ results_with_links = str(result["content"])
+ findings.append(
+ {
+ "phase": f"Follow-up {iteration}.{questions.index(question) + 1}",
+ "content": results_with_links,
+ "question": question,
+ "search_results": search_results,
+ "documents": result["documents"],
+ }
++=======
+
+ try:
+ result = self.citation_handler.analyze_followup(
+ question, search_results, current_knowledge, nr_of_links=len(self.all_links_of_system)
++>>>>>>> main:search_system.py
)
+ links = extract_links_from_search_results(search_results)
+ self.all_links_of_system.extend(links)
+ section_links.extend(links)
+ formatted_links = ""
+ if links:
+ formatted_links=format_links(links=links)
+ if result is not None:
+ results_with_links = str(result["content"])
+ findings.append(
+ {
+ "phase": f"Follow-up {iteration}.{questions.index(question) + 1}",
+ "content": results_with_links,
+ "question": question,
+ "search_results": search_results,
+ "documents": result["documents"],
+ }
+ )
++<<<<<<< HEAD:src/local_deep_research/search_system.py
+ if settings.general.knowledge_accumulation != KnowledgeAccumulationApproach.NO_KNOWLEDGE:
+ current_knowledge = current_knowledge + "\n\n\n New: \n" + results_with_links
+
+ print(current_knowledge)
+ if settings.general.knowledge_accumulation == KnowledgeAccumulationApproach.QUESTION:
+ self._update_progress(f"Compress Knowledge for: {question}",
+ int(question_progress_base + 0),
+ {"phase": "analysis"})
+ current_knowledge = self._compress_knowledge(current_knowledge , query, section_links)
+
+ self._update_progress(f"Analysis complete for question: {question}",
+ int(question_progress_base + 10),
+ {"phase": "analysis_complete"})
++=======
+ if config.KNOWLEDGE_ACCUMULATION != KnowledgeAccumulationApproach.NO_KNOWLEDGE:
+ current_knowledge = current_knowledge + "\n\n\n New: \n" + results_with_links
+
+ print(current_knowledge)
+ if config.KNOWLEDGE_ACCUMULATION == KnowledgeAccumulationApproach.QUESTION:
+ self._update_progress(f"Compress Knowledge for: {question}",
+ int(question_progress_base + 0),
+ {"phase": "analysis"})
+ current_knowledge = self._compress_knowledge(current_knowledge , query, section_links)
+
+ self._update_progress(f"Analysis complete for question: {question}",
+ int(question_progress_base + 10),
+ {"phase": "analysis_complete"})
+ except Exception as e:
+ error_msg = f"Error analyzing results: {str(e)}"
+ print(f"ANALYSIS ERROR: {error_msg}")
+ self._update_progress(error_msg,
+ int(question_progress_base + 10),
+ {"phase": "analysis_error", "error": str(e)})
++>>>>>>> main:search_system.py
iteration += 1
self._update_progress(f"Compressing knowledge after iteration {iteration}",
int((iteration / total_iterations) * 100 - 5),
{"phase": "knowledge_compression"})
++<<<<<<< HEAD:src/local_deep_research/search_system.py
+ if settings.general.knowledge_accumulation == KnowledgeAccumulationApproach.ITERATION:
+ current_knowledge = self._compress_knowledge(current_knowledge , query, section_links)
++=======
+ if config.KNOWLEDGE_ACCUMULATION == KnowledgeAccumulationApproach.ITERATION:
+ try:
+ current_knowledge = self._compress_knowledge(current_knowledge , query, section_links)
+ except Exception as e:
+ error_msg = f"Error compressing knowledge: {str(e)}"
+ print(f"COMPRESSION ERROR: {error_msg}")
+ self._update_progress(error_msg,
+ int((iteration / total_iterations) * 100 - 3),
+ {"phase": "compression_error", "error": str(e)})
++>>>>>>> main:search_system.py
self._update_progress(f"Iteration {iteration} complete",
diff --cc src/local_deep_research/web/app.py
index 50c5f74171,61f911145e..530dc1b337
--- a/src/local_deep_research/web/app.py
+++ b/src/local_deep_research/web/app.py
@@@ -1146,51 -1071,64 +1358,76 @@@ def convert_debug_to_markdown(raw_text
Returns:
Clean markdown formatted text
"""
- # If there's a "DETAILED FINDINGS:" section, extract everything after it
- if "DETAILED FINDINGS:" in raw_text:
- detailed_index = raw_text.index("DETAILED FINDINGS:")
- content = raw_text[detailed_index + len("DETAILED FINDINGS:"):].strip()
- else:
- content = raw_text
-
- # Remove divider lines with === symbols
- content = "\n".join([line for line in content.split("\n")
- if not line.strip().startswith("===") and not line.strip() == "="*80])
-
- # If COMPLETE RESEARCH OUTPUT exists, remove that section
- if "COMPLETE RESEARCH OUTPUT" in content:
- content = content.split("COMPLETE RESEARCH OUTPUT")[0].strip()
-
- # Remove SEARCH QUESTIONS BY ITERATION section
- if "SEARCH QUESTIONS BY ITERATION:" in content:
- search_index = content.index("SEARCH QUESTIONS BY ITERATION:")
- next_major_section = -1
- for marker in ["DETAILED FINDINGS:", "COMPLETE RESEARCH:"]:
- if marker in content[search_index:]:
- marker_pos = content.index(marker, search_index)
- if next_major_section == -1 or marker_pos < next_major_section:
- next_major_section = marker_pos
+ try:
+ print(f"Starting markdown conversion for query: {query}")
+ print(f"Raw text type: {type(raw_text)}")
- if next_major_section != -1:
- content = content[:search_index] + content[next_major_section:]
+ # Handle None or empty input
+ if not raw_text:
+ print("WARNING: raw_text is empty or None")
+ return f"No detailed findings available for '{query}'."
+
+ # If there's a "DETAILED FINDINGS:" section, extract everything after it
+ if "DETAILED FINDINGS:" in raw_text:
+ print("Found DETAILED FINDINGS section")
+ detailed_index = raw_text.index("DETAILED FINDINGS:")
+ content = raw_text[detailed_index + len("DETAILED FINDINGS:"):].strip()
else:
- # If no later section, just remove everything from SEARCH QUESTIONS onwards
- content = content[:search_index].strip()
-
- return content.strip()
+ print("No DETAILED FINDINGS section found, using full text")
+ content = raw_text
+
+ # Remove divider lines with === symbols
+ lines_before = len(content.split("\n"))
+ content = "\n".join([line for line in content.split("\n")
+ if not line.strip().startswith("===") and not line.strip() == "="*80])
+ lines_after = len(content.split("\n"))
+ print(f"Removed {lines_before - lines_after} divider lines")
+
+ # If COMPLETE RESEARCH OUTPUT exists, remove that section
+ if "COMPLETE RESEARCH OUTPUT" in content:
+ print("Found and removing COMPLETE RESEARCH OUTPUT section")
+ content = content.split("COMPLETE RESEARCH OUTPUT")[0].strip()
+
+ # Remove SEARCH QUESTIONS BY ITERATION section
+ if "SEARCH QUESTIONS BY ITERATION:" in content:
+ print("Found SEARCH QUESTIONS BY ITERATION section")
+ search_index = content.index("SEARCH QUESTIONS BY ITERATION:")
+ next_major_section = -1
+ for marker in ["DETAILED FINDINGS:", "COMPLETE RESEARCH:"]:
+ if marker in content[search_index:]:
+ marker_pos = content.index(marker, search_index)
+ if next_major_section == -1 or marker_pos < next_major_section:
+ next_major_section = marker_pos
+
+ if next_major_section != -1:
+ print(f"Removing section from index {search_index} to {next_major_section}")
+ content = content[:search_index] + content[next_major_section:]
+ else:
+ # If no later section, just remove everything from SEARCH QUESTIONS onwards
+ print(f"Removing everything after index {search_index}")
+ content = content[:search_index].strip()
+
+ print(f"Final markdown length: {len(content.strip())}")
+ return content.strip()
+ except Exception as e:
+ print(f"Error in convert_debug_to_markdown: {str(e)}")
+ print(traceback.format_exc())
+ # Return a basic message with the original query as fallback
+ return f"# Research on {query}\n\nThere was an error formatting the research results."
+
-if __name__ == '__main__':
+def main():
+ """
+ Entry point for the web application when run as a command.
+ This function is needed for the package's entry point to work properly.
+ """
+ # Import settings here to avoid circular imports
+ from local_deep_research.config import settings
+
+ # Get web server settings with defaults
+ port = settings.web.port
+ host = settings.web.host
+ debug = settings.web.debug
+
# Check for OpenAI availability but don't import it unless necessary
try:
import os
@@@ -1209,6 -1147,5 +1446,7 @@@
except Exception as e:
print(f"Error checking OpenAI availability: {e}")
- # Run with threading (more stable than eventlet with complex dependencies)
- socketio.run(app, debug=True, host='0.0.0.0', port=5000, allow_unsafe_werkzeug=True)
+ socketio.run(app, debug=debug, host=host, port=port, allow_unsafe_werkzeug=True)
++
+if __name__ == '__main__':
+ main()
diff --cc src/local_deep_research/web/static/css/styles.css
index 500dceee67,77a4acbbf0..51216ba4ff
--- a/src/local_deep_research/web/static/css/styles.css
+++ b/src/local_deep_research/web/static/css/styles.css
@@@ -982,27 -984,25 +984,51 @@@ textarea:focus, input[type="text"]:focu
margin-top: 1rem;
}
++<<<<<<< HEAD:src/local_deep_research/web/static/css/styles.css
+.file-path {
+ background-color: #1a1a1a;
+ padding: 10px;
+ border-radius: 4px;
+ font-family: monospace;
+ margin: 15px 0;
+ word-break: break-all;
+ border: 1px solid #333;
+}
+
+.config-example {
+ background-color: #0a0a0a;
+ padding: 15px;
+ border-radius: 4px;
+ font-family: monospace;
+ margin: 15px 0;
+ overflow-x: auto;
+ border: 1px solid #333;
+ color: #e6e6e6;
+}
+
+.mt-4 {
+ margin-top: 20px;
++=======
+ #try-again-btn {
+ margin-top: 15px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ padding: 8px 16px;
+ background-color: #3498db;
+ color: white;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ transition: background-color 0.2s;
+ }
+
+ #try-again-btn:hover {
+ background-color: #2980b9;
+ }
+
+ #try-again-btn i {
+ margin-right: 5px;
++>>>>>>> main:static/css/styles.css
}
diff --cc src/local_deep_research/web_search_engines/engines/search_engine_searxng.py
index 0000000000,7104a2b8a1..7104a2b8a1
mode 000000,100644..100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py