~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor: Address AI code review feedback
LearningCircuit0deb113ab424
diff --git a/src/local_deep_research/advanced_search_system/strategies/topic_organization_strategy.py b/src/local_deep_research/advanced_search_system/strategies/topic_organization_strategy.pyindex 31e3fd0a0b..b22c498e11 100644--- a/src/local_deep_research/advanced_search_system/strategies/topic_organization_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/topic_organization_strategy.py@@ -1,3 +1,4 @@+import randomimport uuidfrom typing import Dict, List, Any, Optional@@ -168,8 +169,6 @@ class TopicOrganizationStrategy(BaseSearchStrategy):# Shuffle sources to avoid ordering bias in topic organization# Note: random.shuffle is used here for non-security purposes (preventing ML bias)- import random-sources_to_process = (sources_to_process.copy()) # Create a copy to avoid modifying originaldiff --git a/src/local_deep_research/research_library/routes/library_routes.py b/src/local_deep_research/research_library/routes/library_routes.pyindex 415ab6df0c..862a1fbb98 100644--- a/src/local_deep_research/research_library/routes/library_routes.py+++ b/src/local_deep_research/research_library/routes/library_routes.py@@ -28,7 +28,7 @@ from ...database.models.research import ResearchResourcefrom ...database.models.library import LibraryDocument, LibraryDownloadQueuefrom ..services.download_service import DownloadServicefrom ..services.library_service import LibraryService-from ..utils import open_file_location+from ..utils import open_file_location, handle_api_errorfrom ...security.path_validator import PathValidatorfrom ...utilities.db_utils import get_settings_manager@@ -36,33 +36,6 @@ from ...utilities.db_utils import get_settings_managerlibrary_bp = Blueprint("library", __name__, url_prefix="/library")-def handle_api_error(operation: str, error: Exception, status_code: int = 500):- """- Handle API errors consistently - log internally, return generic message to user.-- This prevents information exposure by logging full error details internally- while returning a generic message to the user.-- Args:- operation: Description of the operation that failed (for logging)- error: The exception that occurred- status_code: HTTP status code to return (default: 500)-- Returns:- Flask JSON response tuple (response, status_code)- """- # Log the full error internally with stack trace- logger.exception(f"Error during {operation}")-- # Return generic message to user (no internal details exposed)- return jsonify(- {- "success": False,- "error": "An internal error occurred. Please try again or contact support.",- }- ), status_code--def is_downloadable_domain(url: str) -> bool:"""Check if URL is from a downloadable academic domain using proper URL parsing."""try:diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.pyindex bac961081a..22ced5fb2e 100644--- a/src/local_deep_research/research_library/routes/rag_routes.py+++ b/src/local_deep_research/research_library/routes/rag_routes.py@@ -18,6 +18,7 @@ from flask import (stream_with_context,)from loguru import logger+import globimport jsonimport uuidfrom pathlib import Path@@ -28,6 +29,7 @@ from ...web.auth.decorators import login_requiredfrom ...utilities.db_utils import get_settings_managerfrom ..services.library_rag_service import LibraryRAGServicefrom ...security.path_validator import PathValidator+from ..utils import handle_api_errorrag_bp = Blueprint("rag", __name__, url_prefix="/library")@@ -94,7 +96,7 @@ def validate_local_index_path(user_path: str) -> Path:# CodeQL: This is intentional - local file indexing on user's own machine.# Users are allowed to index their own filesystem. System directories are blocked below.if Path(user_path).is_absolute():- # lgtm[py/path-injection] - Intentional: Local filesystem indexing feature+ # codeql[py/path-injection] - Intentional: Local filesystem indexing feature with system directory protectionvalidated_path = Path(user_path).resolve() # nosec B108else:# Use PathValidator for relative paths@@ -131,33 +133,6 @@ def validate_local_index_path(user_path: str) -> Path:return validated_path-def handle_api_error(operation: str, error: Exception, status_code: int = 500):- """- Handle API errors consistently - log internally, return generic message to user.-- This prevents information exposure by logging full error details internally- while returning a generic message to the user.-- Args:- operation: Description of the operation that failed (for logging)- error: The exception that occurred- status_code: HTTP status code to return (default: 500)-- Returns:- Flask JSON response tuple (response, status_code)- """- # Log the full error internally with stack trace- logger.exception(f"Error during {operation}")-- # Return generic message to user (no internal details exposed)- return jsonify(- {- "success": False,- "error": "An internal error occurred. Please try again or contact support.",- }- ), status_code--# Page Routes@@ -561,8 +536,6 @@ def get_documents():@login_requireddef index_local_library():"""Index documents from a local folder with Server-Sent Events progress."""- import glob-folder_path = request.args.get("path")file_patterns = request.args.get("patterns", "*.pdf,*.txt,*.md,*.html"diff --git a/src/local_deep_research/research_library/utils/__init__.py b/src/local_deep_research/research_library/utils/__init__.pyindex 12f473a24d..85fcb1dc61 100644--- a/src/local_deep_research/research_library/utils/__init__.py+++ b/src/local_deep_research/research_library/utils/__init__.py@@ -6,6 +6,7 @@ import subprocessimport sysfrom pathlib import Path+from flask import jsonifyfrom loguru import logger@@ -156,3 +157,30 @@ def get_absolute_path_from_settings(relative_path: str) -> Path:return library_rootreturn library_root / relative_path+++def handle_api_error(operation: str, error: Exception, status_code: int = 500):+ """+ Handle API errors consistently - log internally, return generic message to user.++ This prevents information exposure by logging full error details internally+ while returning a generic message to the user.++ Args:+ operation: Description of the operation that failed (for logging)+ error: The exception that occurred+ status_code: HTTP status code to return (default: 500)++ Returns:+ Flask JSON response tuple (response, status_code)+ """+ # Log the full error internally with stack trace+ logger.exception(f"Error during {operation}")++ # Return generic message to user (no internal details exposed)+ return jsonify(+ {+ "success": False,+ "error": "An internal error occurred. Please try again or contact support.",+ }+ ), status_code