~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: resolve programmatic API bugs and add CI tests (#1085)
LearningCircuit3d917453c88a
diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.ymlindex 3be048e527..b1485b32f6 100644--- a/.github/workflows/api-tests.yml+++ b/.github/workflows/api-tests.yml@@ -6,7 +6,9 @@ on:- 'src/local_deep_research/api/**'- 'src/local_deep_research/web/routes/**'- 'tests/api_tests/**'+ - 'tests/programmatic_access/**'- 'examples/api_usage/http/**'+ - 'examples/api_usage/programmatic/**'pull_request:types: [opened, synchronize, reopened]workflow_dispatch:@@ -98,6 +100,11 @@ jobs:export LDR_USE_FALLBACK_LLM=truepdm run pytest tests/api_tests/ -v --cov=src/local_deep_research/api --cov-report=term+ - name: Run Programmatic API tests+ run: |+ export LDR_USE_FALLBACK_LLM=true+ pdm run pytest tests/programmatic_access/ -v --cov=src/local_deep_research/api --cov-append --cov-report=term+- name: Stop server after unit testsif: always()run: |diff --git a/examples/api_usage/programmatic/advanced_features_example.py b/examples/api_usage/programmatic/advanced_features_example.pyindex 123a408b0e..ae2106e6ab 100644--- a/examples/api_usage/programmatic/advanced_features_example.py+++ b/examples/api_usage/programmatic/advanced_features_example.py@@ -47,6 +47,7 @@ This demonstrates the generate_report() function which:"programmatic_mode": True,"search.tool": "wikipedia","llm.temperature": 0.5, # Lower for more focused output+ "api.allow_file_output": True, # Allow generate_report to save files})diff --git a/examples/api_usage/programmatic/simple_programmatic_example.py b/examples/api_usage/programmatic/simple_programmatic_example.pyindex b2723658a9..f4b3191b68 100755--- a/examples/api_usage/programmatic/simple_programmatic_example.py+++ b/examples/api_usage/programmatic/simple_programmatic_example.py@@ -19,6 +19,7 @@ from local_deep_research.api.settings_utils import (settings_snapshot = create_settings_snapshot(overrides={"search.tool": "wikipedia", # Use Wikipedia for this example+ "api.allow_file_output": True, # Allow generate_report to save files})diff --git a/src/local_deep_research/api/research_functions.py b/src/local_deep_research/api/research_functions.pyindex e8bfc8bd93..b6d048b791 100644--- a/src/local_deep_research/api/research_functions.py+++ b/src/local_deep_research/api/research_functions.py@@ -418,6 +418,7 @@ def generate_report(report["content"],"api.allow_file_output",context="API research report",+ settings_snapshot=kwargs.get("settings_snapshot"),)logger.info(f"Report saved to {output_file}")report["file_path"] = output_file@@ -631,6 +632,7 @@ def analyze_documents(content,"api.allow_file_output",context="API document analysis",+ settings_snapshot=None, # analyze_documents doesn't support programmatic mode yet)analysis_result["file_path"] = output_filediff --git a/src/local_deep_research/api/settings_utils.py b/src/local_deep_research/api/settings_utils.pyindex 13c3abbb60..ab699fb9d1 100644--- a/src/local_deep_research/api/settings_utils.py+++ b/src/local_deep_research/api/settings_utils.py@@ -216,7 +216,16 @@ def create_settings_snapshot(settings[key] = valueelse:# Create a simple setting entry for unknown keys- settings[key] = {"value": value}+ # Infer ui_element from value type+ ui_element = "text" # default+ if isinstance(value, bool):+ ui_element = "checkbox"+ elif isinstance(value, (int, float)):+ ui_element = "number"+ elif isinstance(value, dict):+ ui_element = "json"++ settings[key] = {"value": value, "ui_element": ui_element}# Handle common kwargs shortcutsif "provider" in kwargs:diff --git a/src/local_deep_research/config/thread_settings.py b/src/local_deep_research/config/thread_settings.pyindex abb5580fab..5be5dfeb51 100644--- a/src/local_deep_research/config/thread_settings.py+++ b/src/local_deep_research/config/thread_settings.py@@ -59,14 +59,18 @@ def get_setting_from_snapshot(if settings_snapshot and key in settings_snapshot:value = settings_snapshot[key]value = get_typed_setting_value(- key, value["value"], value["ui_element"]+ key,+ value["value"],+ value.get("ui_element", "text"), # Default to "text" if missing)# Search for child keys.elif settings_snapshot:for k, v in settings_snapshot.items():if k.startswith(f"{key}."):k = k.removeprefix(f"{key}.")- v = get_typed_setting_value(key, v["value"], v["ui_element"])+ v = get_typed_setting_value(+ key, v["value"], v.get("ui_element", "text")+ ) # Default to "text" if missingif value is None:value = {k: v}else:diff --git a/src/local_deep_research/llm/providers/implementations/ollama.py b/src/local_deep_research/llm/providers/implementations/ollama.pyindex 62278a516f..9efa3d3253 100644--- a/src/local_deep_research/llm/providers/implementations/ollama.py+++ b/src/local_deep_research/llm/providers/implementations/ollama.py@@ -58,7 +58,7 @@ class OllamaProvider:if api_key is None and settings_snapshot is not None:api_key = get_setting_from_snapshot(cls.api_key_setting,- None,+ "", # Empty string instead of None to avoid NoSettingsContextErrorsettings_snapshot=settings_snapshot,)diff --git a/src/local_deep_research/security/file_write_verifier.py b/src/local_deep_research/security/file_write_verifier.pyindex 6c12cf237b..88721a22f8 100644--- a/src/local_deep_research/security/file_write_verifier.py+++ b/src/local_deep_research/security/file_write_verifier.py@@ -25,6 +25,7 @@ def write_file_verified(context: str = "",mode: str = "w",encoding: str = "utf-8",+ settings_snapshot: dict = None,) -> None:"""Write content to a file only if security settings allow it.@@ -36,6 +37,7 @@ def write_file_verified(context: Description of what's being written (for error messages)mode: File open mode (default: "w")encoding: File encoding (default: "utf-8")+ settings_snapshot: Optional settings snapshot for programmatic modeRaises:FileWriteSecurityError: If the security setting doesn't match required value@@ -51,7 +53,9 @@ def write_file_verified(from ..config.search_config import get_setting_from_snapshottry:- actual_value = get_setting_from_snapshot(setting_name)+ actual_value = get_setting_from_snapshot(+ setting_name, settings_snapshot=settings_snapshot+ )except Exception:# Setting doesn't exist - default denyactual_value = None@@ -78,6 +82,7 @@ def write_json_verified(setting_name: str,required_value: Any = True,context: str = "",+ settings_snapshot: dict = None,**json_kwargs,) -> None:"""Write JSON data to a file only if security settings allow it.@@ -88,6 +93,7 @@ def write_json_verified(setting_name: Configuration setting name to checkrequired_value: Required value for the setting (default: True)context: Description of what's being written (for error messages)+ settings_snapshot: Optional settings snapshot for programmatic mode**json_kwargs: Additional keyword arguments to pass to json.dumps()(e.g., indent=2, ensure_ascii=False, sort_keys=True, default=custom_serializer)@@ -117,4 +123,5 @@ def write_json_verified(context,mode="w",encoding="utf-8",+ settings_snapshot=settings_snapshot,)