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.

Merge main branch with ORM fixes

LearningCircuit379ca651ac96
diff --cc src/local_deep_research/web/services/research_service.py
index 95bfa14309,b7e37452b4..2202ec6073
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@@ -15,10 -14,9 +14,10 @@@ from ...utilities.log_utils import log_
from ...utilities.search_utilities import extract_links_from_search_results
from ...utilities.db_utils import get_db_session
from ...utilities.threading_utils import thread_context, thread_with_app_context
- from ..database.models import ResearchStrategy
- from ..models.database import calculate_duration, get_db_connection
+ from ..database.models import ResearchStrategy, ResearchHistory
+ from ..models.database import calculate_duration
from .socket_service import SocketIOService
+from ...error_handling.report_generator import ErrorReportGenerator
# Output directory for research results
_PROJECT_ROOT = Path(__file__).parents[4]
@@@ -1013,42 -908,33 +983,37 @@@ def run_research_process
# Get the start time from the database
duration_seconds = None
- cursor.execute(
- "SELECT created_at FROM research_history WHERE id = ?",
- (research_id,),
- )
- result = cursor.fetchone()
-
- # Use the helper function for consistent duration calculation
- if result and result[0]:
- duration_seconds = calculate_duration(result[0])
-
- # Update database with error report path if available
- if 'report_path_to_save' in locals() and report_path_to_save:
- cursor.execute(
- "UPDATE research_history SET status = ?, completed_at = ?, duration_seconds = ?, metadata = ?, report_path = ? WHERE id = ?",
- (
- status,
- completed_at,
- duration_seconds,
- json.dumps(metadata),
- report_path_to_save,
- research_id,
- ),
+ db_session = get_db_session()
+ with db_session:
+ research = (
+ db_session.query(ResearchHistory)
+ .filter_by(id=research_id)
+ .first()
)
- else:
- cursor.execute(
- "UPDATE research_history SET status = ?, completed_at = ?, duration_seconds = ?, metadata = ? WHERE id = ?",
- (
- status,
- completed_at,
- duration_seconds,
- json.dumps(metadata),
- research_id,
- ),
+ assert research is not None, "Research not in database"
+
+ duration_seconds = calculate_duration(research.created_at)
+
+ db_session = get_db_session()
+ with db_session:
+ research = (
+ db_session.query(ResearchHistory)
+ .filter_by(id=research_id)
+ .first()
)
- conn.commit()
- conn.close()
+ assert research is not None, "Research not in database"
+
+ # Update the ResearchHistory object with the new status and completion time
+ research.status = status
+ research.completed_at = completed_at
+ research.duration_seconds = duration_seconds
+ research.metadata = metadata
++
++ # Add error report path if available
++ if 'report_path_to_save' in locals() and report_path_to_save:
++ research.report_path = report_path_to_save
+
+ db_session.commit()
try:
SocketIOService().emit_to_subscribers(