~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
fix: Fix remaining test failures in programmatic access PR
LearningCircuitda2f16ac6fe2
diff --git a/src/local_deep_research/database/models/auth.py b/src/local_deep_research/database/models/auth.pyindex 4a8b5f1a38..44fc7217bb 100644--- a/src/local_deep_research/database/models/auth.py+++ b/src/local_deep_research/database/models/auth.py@@ -7,7 +7,8 @@ Each user gets their own encrypted database file.from datetime import datetime, UTCfrom functools import partial-from sqlalchemy import Column, DateTime, Integer, String+from sqlalchemy import Column, Integer, String+from sqlalchemy_utc import UtcDateTimefrom ...config.paths import get_user_database_filenamefrom .base import Base@@ -23,8 +24,8 @@ class User(Base):id = Column(Integer, primary_key=True)username = Column(String(80), unique=True, nullable=False, index=True)- created_at = Column(DateTime, default=partial(datetime.now, UTC))- last_login = Column(DateTime)+ created_at = Column(UtcDateTime, default=partial(datetime.now, UTC))+ last_login = Column(UtcDateTime)# Metadata only - no sensitive datadatabase_version = Column(Integer, default=1)diff --git a/src/local_deep_research/database/models/cache.py b/src/local_deep_research/database/models/cache.pyindex bfada3c642..d2a27cc08a 100644--- a/src/local_deep_research/database/models/cache.py+++ b/src/local_deep_research/database/models/cache.py@@ -5,7 +5,8 @@ Cache model for storing expensive operation results.from datetime import datetime, timedelta, UTCfrom functools import partial-from sqlalchemy import JSON, Column, DateTime, Index, Integer, String, Text+from sqlalchemy import JSON, Column, Index, Integer, String, Text+from sqlalchemy_utc import UtcDateTimefrom .base import Base@@ -32,12 +33,12 @@ class Cache(Base):# Expirationttl_seconds = Column(Integer) # Time to live in seconds- expires_at = Column(DateTime, index=True)+ expires_at = Column(UtcDateTime, index=True)# Usage trackinghit_count = Column(Integer, default=0)- created_at = Column(DateTime, default=partial(datetime.now, UTC))- accessed_at = Column(DateTime, default=partial(datetime.now, UTC))+ created_at = Column(UtcDateTime, default=partial(datetime.now, UTC))+ accessed_at = Column(UtcDateTime, default=partial(datetime.now, UTC))# Indexes for performance__table_args__ = (diff --git a/tests/database/test_auth_models.py b/tests/database/test_auth_models.pyindex 829b077e04..79f0aad11e 100644--- a/tests/database/test_auth_models.py+++ b/tests/database/test_auth_models.py@@ -1,6 +1,6 @@"""Tests for authentication-related database models."""-from datetime import datetime+from datetime import datetime, timezoneimport pytestfrom sqlalchemy import create_engine@@ -70,7 +70,7 @@ class TestUserModel:assert isinstance(user.created_at, datetime)# Update last_login- user.last_login = datetime.utcnow()+ user.last_login = datetime.now(timezone.utc)session.commit()# Verify last_login is set@@ -88,7 +88,7 @@ class TestUserModel:assert user.last_login is None# Update last_login- login_time = datetime.utcnow()+ login_time = datetime.now(timezone.utc)user.last_login = login_timesession.commit()diff --git a/tests/database/test_benchmark_models.py b/tests/database/test_benchmark_models.pyindex 1658e3200a..5a37ec55fc 100644--- a/tests/database/test_benchmark_models.py+++ b/tests/database/test_benchmark_models.py@@ -1,6 +1,6 @@"""Tests for benchmark-related database models."""-from datetime import datetime, timedelta+from datetime import datetime, timedelta, timezoneimport pytestfrom sqlalchemy import create_engine@@ -77,7 +77,7 @@ class TestBenchmarkModels:# Progress through statusesrun.status = BenchmarkStatus.IN_PROGRESS- run.start_time = datetime.utcnow()+ run.start_time = datetime.now(timezone.utc)session.commit()assert run.status == BenchmarkStatus.IN_PROGRESS@@ -85,7 +85,7 @@ class TestBenchmarkModels:# Complete the runrun.status = BenchmarkStatus.COMPLETED- run.end_time = datetime.utcnow()+ run.end_time = datetime.now(timezone.utc)run.overall_accuracy = 0.85run.processing_rate = 5.2 # examples per minutesession.commit()@@ -189,7 +189,7 @@ class TestBenchmarkModels:# Test updating usage statsconfig.usage_count += 1- config.last_used = datetime.utcnow()+ config.last_used = datetime.now(timezone.utc)config.best_accuracy = 0.92config.avg_processing_rate = 4.5session.commit()@@ -227,7 +227,8 @@ class TestBenchmarkModels:overall_accuracy=0.88,dataset_accuracies={"simpleqa": 0.90, "browsecomp": 0.85},processing_rate=3.2,- estimated_completion=datetime.utcnow() + timedelta(minutes=20),+ estimated_completion=datetime.now(timezone.utc)+ + timedelta(minutes=20),current_dataset=DatasetType.SIMPLEQA,current_example_id="simpleqa_025",memory_usage=512.5,@@ -241,7 +242,8 @@ class TestBenchmarkModels:overall_accuracy=0.86,dataset_accuracies={"simpleqa": 0.89, "browsecomp": 0.83},processing_rate=3.5,- estimated_completion=datetime.utcnow() + timedelta(minutes=15),+ estimated_completion=datetime.now(timezone.utc)+ + timedelta(minutes=15),current_dataset=DatasetType.BROWSECOMP,current_example_id="browsecomp_010",)diff --git a/tests/database/test_cache_models.py b/tests/database/test_cache_models.pyindex 6e441a8e07..663ed2f88a 100644--- a/tests/database/test_cache_models.py+++ b/tests/database/test_cache_models.py@@ -3,7 +3,7 @@import hashlibimport jsonimport time-from datetime import datetime, timedelta, UTC+from datetime import datetime, timedelta, timezone, UTCimport pytestfrom sqlalchemy import create_engine@@ -304,7 +304,7 @@ class TestCacheModels:def test_cache_cleanup_old_entries(self, session):"""Test cleanup of expired cache entries."""- now = datetime.utcnow()+ now = datetime.now(timezone.utc)# Create caches with different expiration timesfor i in range(10):diff --git a/tests/database/test_encrypted_database_orm.py b/tests/database/test_encrypted_database_orm.pyindex 1a3ae706a2..9af5e3352d 100644--- a/tests/database/test_encrypted_database_orm.py+++ b/tests/database/test_encrypted_database_orm.py@@ -5,7 +5,7 @@ import osimport sysimport tempfileimport uuid-from datetime import datetime+from datetime import datetime, timezonefrom pathlib import Pathimport pytest@@ -160,8 +160,8 @@ class TestEncryptedDatabaseORM:query="quantum computing applications",mode="detailed",status="completed",- created_at=datetime.utcnow().isoformat(),- completed_at=datetime.utcnow().isoformat(),+ created_at=datetime.now(timezone.utc).isoformat(),+ completed_at=datetime.now(timezone.utc).isoformat(),progress=100,research_meta={"model": "gpt-4",@@ -181,7 +181,7 @@ class TestEncryptedDatabaseORM:content_preview="Recent advances in quantum computing...",source_type="article",resource_metadata={"author": "Dr. Smith", "year": 2024},- created_at=datetime.utcnow().isoformat(),+ created_at=datetime.now(timezone.utc).isoformat(),),ResearchResource(research_id=research_id,@@ -190,7 +190,7 @@ class TestEncryptedDatabaseORM:content_preview="IBM's quantum computing initiative...",source_type="web",resource_metadata={"company": "IBM", "relevance": 0.95},- created_at=datetime.utcnow().isoformat(),+ created_at=datetime.now(timezone.utc).isoformat(),),]@@ -285,7 +285,7 @@ class TestEncryptedDatabaseORM:# Update task statustask.status = "completed"- task.completed_at = datetime.utcnow()+ task.completed_at = datetime.now(timezone.utc)session.commit()# Verify relationships@@ -379,7 +379,7 @@ class TestEncryptedDatabaseORM:logs = [ResearchLog(research_id=research.id,- timestamp=datetime.utcnow(),+ timestamp=datetime.now(timezone.utc),level="INFO",message="Starting research process",module="research_service",@@ -388,7 +388,7 @@ class TestEncryptedDatabaseORM:),ResearchLog(research_id=research.id,- timestamp=datetime.utcnow(),+ timestamp=datetime.now(timezone.utc),level="DEBUG",message="Executing search query",module="search_engine",@@ -397,7 +397,7 @@ class TestEncryptedDatabaseORM:),ResearchLog(research_id=research.id,- timestamp=datetime.utcnow(),+ timestamp=datetime.now(timezone.utc),level="ERROR",message="API rate limit exceeded",module="api_client",diff --git a/tests/database/test_metrics_models.py b/tests/database/test_metrics_models.pyindex c34556663a..93a27e0027 100644--- a/tests/database/test_metrics_models.py+++ b/tests/database/test_metrics_models.py@@ -1,6 +1,6 @@"""Tests for metrics tracking database models."""-from datetime import datetime, timedelta+from datetime import datetime, timedelta, timezoneimport pytestfrom sqlalchemy import create_engine@@ -45,7 +45,7 @@ class TestMetricsModels:prompt_cost=0.015,completion_cost=0.0045,total_cost=0.0195,- timestamp=datetime.utcnow(),+ timestamp=datetime.now(timezone.utc),operation_type="synthesis",operation_details={"temperature": 0.7,@@ -78,8 +78,8 @@ class TestMetricsModels:avg_response_time_ms=250.5,error_count=0,success_rate=100.0,- first_used_at=datetime.utcnow(),- last_used_at=datetime.utcnow(),+ first_used_at=datetime.now(timezone.utc),+ last_used_at=datetime.now(timezone.utc),)session.add(model_usage)@@ -105,7 +105,7 @@ class TestMetricsModels:relevance=5,readability=3,feedback="Great research results, but the summary could be clearer.",- created_at=datetime.utcnow(),+ created_at=datetime.now(timezone.utc),)session.add(rating)@@ -131,7 +131,7 @@ class TestMetricsModels:success=1,error_message=None,rate_limited=0,- timestamp=datetime.utcnow(),+ timestamp=datetime.now(timezone.utc),)session.add(search)@@ -284,7 +284,7 @@ class TestMetricsModels:def test_time_based_metrics(self, session):"""Test querying metrics by time ranges."""- now = datetime.utcnow()+ now = datetime.now(timezone.utc)# Create token usage over different time periodsfor days_ago in range(7):diff --git a/tests/database/test_orm_conversions.py b/tests/database/test_orm_conversions.pyindex b96689e823..8772ef9e71 100644--- a/tests/database/test_orm_conversions.py+++ b/tests/database/test_orm_conversions.py@@ -141,7 +141,7 @@ def test_research_resource_orm_operations(test_db):def test_research_log_orm_queries(test_db):"""Test ResearchLog ORM queries."""- from datetime import datetime+ from datetime import datetime, timezone# First create a Research entry (not ResearchHistory)from src.local_deep_research.database.models import (@@ -161,7 +161,7 @@ def test_research_log_orm_queries(test_db):# Add logs with all required fieldslog1 = ResearchLog(research_id=research.id,- timestamp=datetime(2024, 1, 1, 0, 0, 0),+ timestamp=datetime(2024, 1, 1, 0, 0, 0, tzinfo=timezone.utc),message="Starting research",module="research_service",function="start_research",@@ -170,7 +170,7 @@ def test_research_log_orm_queries(test_db):)log2 = ResearchLog(research_id=research.id,- timestamp=datetime(2024, 1, 1, 0, 1, 0),+ timestamp=datetime(2024, 1, 1, 0, 1, 0, tzinfo=timezone.utc),message="Search completed",module="search_engine",function="search",diff --git a/tests/database/test_research_models.py b/tests/database/test_research_models.pyindex 9cff99585a..ded5c2409d 100644--- a/tests/database/test_research_models.py+++ b/tests/database/test_research_models.py@@ -1,7 +1,7 @@"""Tests for research-related database models."""import uuid-from datetime import datetime+from datetime import datetime, timezoneimport pytestfrom sqlalchemy import create_engine@@ -357,7 +357,7 @@ class TestResearchModels:domain="example.com",language="en",fetch_status="fetched",- fetched_at=datetime.utcnow(),+ fetched_at=datetime.now(timezone.utc),)session.add(result)diff --git a/tests/database/test_settings_models.py b/tests/database/test_settings_models.pyindex 95dda1a071..4cf37fd46f 100644--- a/tests/database/test_settings_models.py+++ b/tests/database/test_settings_models.py@@ -1,6 +1,6 @@"""Tests for settings and API key database models."""-from datetime import datetime+from datetime import datetime, timezoneimport pytestfrom sqlalchemy import create_engine@@ -341,7 +341,7 @@ class TestSettingsModels:# Simulate key usageapi_key.usage_count += 1- api_key.last_used = datetime.utcnow()+ api_key.last_used = datetime.now(timezone.utc)session.commit()# Rotate key (deactivate old, add new)diff --git a/tests/test_llm_provider_integration.py b/tests/test_llm_provider_integration.pyindex ed76a50a46..19ba382e08 100644--- a/tests/test_llm_provider_integration.py+++ b/tests/test_llm_provider_integration.py@@ -20,11 +20,20 @@ class TestLLMProviderIntegration:"llm.temperature": 0.7,"llm.openai_endpoint.api_key": "sk-openrouter-test-key","llm.openai_endpoint.url": "https://openrouter.ai/api/v1",+ "llm.openai_endpoint.model": "claude-3-sonnet","llm.supports_max_tokens": True,"llm.max_tokens": 4096,"llm.context_window_unrestricted": True,"llm.openai.api_key": None,+ "llm.openai.api_base": None,+ "llm.openai.organization": None,"llm.anthropic.api_key": None,+ "llm.streaming": False,+ "llm.max_retries": None,+ "llm.request_timeout": None,+ "llm.ollama.url": "http://localhost:11434",+ "llm.lmstudio.url": "http://localhost:1234",+ "llm.llamacpp_model_path": None,"app.lock_settings": False,"rate_limiting.llm_enabled": False,"search.tool": "searxng",@@ -41,6 +50,11 @@ class TestLLMProviderIntegration:"search.enable_think_tags": False,"search.require_all_sources": False,"search.max_backoff_time": 300,+ "search.time_period": "all",+ "search.safe_search": True,+ "search.snippets_only": True,+ "search.search_language": "en",+ "search.max_filtered_results": 10,"search.smart_search.use_query_improvement": True,"search.smart_search.use_document_relevance": True,"search.smart_search.use_answer_extraction": True,diff --git a/tests/test_search_system.py b/tests/test_search_system.pyindex ce62fc1382..a37d26bda6 100644--- a/tests/test_search_system.py+++ b/tests/test_search_system.py@@ -61,7 +61,7 @@ def test_progress_callback_forwarding(monkeypatch, mock_search, mock_llm):lambda **kwargs: mock_llm,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search,)@@ -98,7 +98,7 @@ def test_init_source_based_strategy(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -147,7 +147,7 @@ def test_init_iterdrag_strategy(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -177,7 +177,7 @@ def test_init_parallel_strategy(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -215,7 +215,7 @@ def test_init_rapid_strategy(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -245,7 +245,7 @@ def test_init_invalid_strategy(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -273,7 +273,7 @@ def test_set_progress_callback(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -346,7 +346,7 @@ def test_analyze_topic(monkeypatch):lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.web_search_engines.search_aggregator.get_search",+ "local_deep_research.config.search_config.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)# Mock SourceBasedSearchStrategy which is now the default