~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: Move LLM providers to implementations subdirectory
LearningCircuit888a80c88168
diff --git a/src/local_deep_research/llm/providers/auto_discovery.py b/src/local_deep_research/llm/providers/auto_discovery.pyindex 30c11fa0f8..33ab38008e 100644--- a/src/local_deep_research/llm/providers/auto_discovery.py+++ b/src/local_deep_research/llm/providers/auto_discovery.py@@ -29,9 +29,14 @@ class ProviderInfo:self.gdpr_compliant = getattr(provider_class, "gdpr_compliant", False)self.data_location = getattr(provider_class, "data_location", "Unknown")self.is_cloud = getattr(provider_class, "is_cloud", True)- self.requires_auth_for_models = (- provider_class.requires_auth_for_models()- )+ # Handle providers that may not have requires_auth_for_models method+ if hasattr(provider_class, "requires_auth_for_models"):+ self.requires_auth_for_models = (+ provider_class.requires_auth_for_models()+ )+ else:+ # Default to True for providers without the method+ self.requires_auth_for_models = True# Generate display name from attributesself.display_name = self._generate_display_name()@@ -111,31 +116,45 @@ class ProviderDiscovery:return self._providersself._providers.clear()- providers_dir = Path(__file__).parent-- # Scan all Python files in the providers directory- for file_path in providers_dir.glob("*.py"):- # Skip special files and base classes- if file_path.name.startswith("_") or file_path.name in [- "auto_discovery.py",- "openai_base.py", # Base class, not a provider- ]:+ # Scan the implementations subdirectory for providers+ implementations_dir = Path(__file__).parent / "implementations"++ if not implementations_dir.exists():+ logger.warning(+ f"Implementations directory not found: {implementations_dir}"+ )+ return self._providers++ # Scan all Python files in the implementations directory+ logger.info(f"Scanning directory: {implementations_dir}")+ for file_path in implementations_dir.glob("*.py"):+ # Skip special files (like __init__.py)+ if file_path.name.startswith("_"):continuemodule_name = file_path.stem+ logger.debug(f"Processing module: {module_name} from {file_path}")try:- # Import the module+ # Import the module from implementations subdirectorymodule = importlib.import_module(- f".{module_name}",+ f".implementations.{module_name}",package="local_deep_research.llm.providers",)- # Find all Provider classes that inherit from OpenAICompatibleProvider+ # Find all Provider classes (both OpenAICompatibleProvider and standalone)+ logger.debug(+ f"Inspecting module {module_name} for Provider classes"+ )for name, obj in inspect.getmembers(module, inspect.isclass):+ if inspect.isclass(obj):+ logger.debug(+ f" Found class: {name}, bases: {obj.__bases__}"+ )+ # Check if it's a Provider class (ends with "Provider" and has provider_name)if (- issubclass(obj, OpenAICompatibleProvider)+ name.endswith("Provider")+ and hasattr(obj, "provider_name")and obj is not OpenAICompatibleProvider- and name.endswith("Provider")):# Found a provider classprovider_info = ProviderInfo(obj)diff --git a/src/local_deep_research/llm/providers/anthropic.py b/src/local_deep_research/llm/providers/implementations/anthropic.pysimilarity index 98%rename from src/local_deep_research/llm/providers/anthropic.pyrename to src/local_deep_research/llm/providers/implementations/anthropic.pyindex 9bf30bbb77..2fcb793b21 100644--- a/src/local_deep_research/llm/providers/anthropic.py+++ b/src/local_deep_research/llm/providers/implementations/anthropic.py@@ -3,11 +3,11 @@from langchain_anthropic import ChatAnthropicfrom loguru import logger-from ...config.thread_settings import (+from ....config.thread_settings import (get_setting_from_snapshot as _get_setting_from_snapshot,NoSettingsContextError,)-from ..llm_registry import register_llm+from ...llm_registry import register_llmdef get_setting_from_snapshot(diff --git a/src/local_deep_research/llm/providers/custom_openai_endpoint.py b/src/local_deep_research/llm/providers/implementations/custom_openai_endpoint.pysimilarity index 96%rename from src/local_deep_research/llm/providers/custom_openai_endpoint.pyrename to src/local_deep_research/llm/providers/implementations/custom_openai_endpoint.pyindex 343c36d3a8..0ec05d58cc 100644--- a/src/local_deep_research/llm/providers/custom_openai_endpoint.py+++ b/src/local_deep_research/llm/providers/implementations/custom_openai_endpoint.py@@ -2,12 +2,12 @@from loguru import logger-from ...config.thread_settings import (+from ....config.thread_settings import (get_setting_from_snapshot as _get_setting_from_snapshot,)-from ...utilities.url_utils import normalize_url-from ..llm_registry import register_llm-from .openai_base import OpenAICompatibleProvider+from ....utilities.url_utils import normalize_url+from ...llm_registry import register_llm+from ..openai_base import OpenAICompatibleProviderdef get_setting_from_snapshot(diff --git a/src/local_deep_research/llm/providers/google.py b/src/local_deep_research/llm/providers/implementations/google.pysimilarity index 97%rename from src/local_deep_research/llm/providers/google.pyrename to src/local_deep_research/llm/providers/implementations/google.pyindex 450a4c3970..3fd9d00653 100644--- a/src/local_deep_research/llm/providers/google.py+++ b/src/local_deep_research/llm/providers/implementations/google.py@@ -2,8 +2,8 @@from loguru import logger-from ..llm_registry import register_llm-from .openai_base import OpenAICompatibleProvider+from ...llm_registry import register_llm+from ..openai_base import OpenAICompatibleProviderclass GoogleProvider(OpenAICompatibleProvider):diff --git a/src/local_deep_research/llm/providers/ionos.py b/src/local_deep_research/llm/providers/implementations/ionos.pysimilarity index 95%rename from src/local_deep_research/llm/providers/ionos.pyrename to src/local_deep_research/llm/providers/implementations/ionos.pyindex aaee69d75a..e2a9728662 100644--- a/src/local_deep_research/llm/providers/ionos.py+++ b/src/local_deep_research/llm/providers/implementations/ionos.py@@ -2,8 +2,8 @@from loguru import logger-from ..llm_registry import register_llm-from .openai_base import OpenAICompatibleProvider+from ...llm_registry import register_llm+from ..openai_base import OpenAICompatibleProviderclass IONOSProvider(OpenAICompatibleProvider):diff --git a/src/local_deep_research/llm/providers/lmstudio.py b/src/local_deep_research/llm/providers/implementations/lmstudio.pysimilarity index 93%rename from src/local_deep_research/llm/providers/lmstudio.pyrename to src/local_deep_research/llm/providers/implementations/lmstudio.pyindex fb4f189e1a..1eb25948f9 100644--- a/src/local_deep_research/llm/providers/lmstudio.py+++ b/src/local_deep_research/llm/providers/implementations/lmstudio.py@@ -2,8 +2,8 @@from loguru import logger-from ..llm_registry import register_llm-from .openai_base import OpenAICompatibleProvider+from ...llm_registry import register_llm+from ..openai_base import OpenAICompatibleProviderclass LMStudioProvider(OpenAICompatibleProvider):@@ -28,7 +28,7 @@ class LMStudioProvider(OpenAICompatibleProvider):@classmethoddef create_llm(cls, model_name=None, temperature=0.7, **kwargs):"""Override to handle LM Studio specifics."""- from ...config.thread_settings import get_setting_from_snapshot+ from ....config.thread_settings import get_setting_from_snapshotsettings_snapshot = kwargs.get("settings_snapshot")@@ -53,7 +53,7 @@ class LMStudioProvider(OpenAICompatibleProvider):"""Check if LM Studio is available."""try:import requests- from ...config.thread_settings import get_setting_from_snapshot+ from ....config.thread_settings import get_setting_from_snapshotlmstudio_url = get_setting_from_snapshot("llm.lmstudio.url",diff --git a/src/local_deep_research/llm/providers/ollama.py b/src/local_deep_research/llm/providers/implementations/ollama.pysimilarity index 98%rename from src/local_deep_research/llm/providers/ollama.pyrename to src/local_deep_research/llm/providers/implementations/ollama.pyindex 36f0ae89e5..d64e3abce9 100644--- a/src/local_deep_research/llm/providers/ollama.py+++ b/src/local_deep_research/llm/providers/implementations/ollama.py@@ -4,11 +4,11 @@ import requestsfrom langchain_ollama import ChatOllamafrom loguru import logger-from ...config.thread_settings import (+from ....config.thread_settings import (get_setting_from_snapshot as _get_setting_from_snapshot,)-from ...utilities.url_utils import normalize_url-from ..llm_registry import register_llm+from ....utilities.url_utils import normalize_url+from ...llm_registry import register_llmdef get_setting_from_snapshot(diff --git a/src/local_deep_research/llm/providers/openai.py b/src/local_deep_research/llm/providers/implementations/openai.pysimilarity index 98%rename from src/local_deep_research/llm/providers/openai.pyrename to src/local_deep_research/llm/providers/implementations/openai.pyindex 821c8d135f..7dbd1f0bac 100644--- a/src/local_deep_research/llm/providers/openai.py+++ b/src/local_deep_research/llm/providers/implementations/openai.py@@ -3,11 +3,11 @@from langchain_openai import ChatOpenAIfrom loguru import logger-from ...config.thread_settings import (+from ....config.thread_settings import (get_setting_from_snapshot as _get_setting_from_snapshot,NoSettingsContextError,)-from ..llm_registry import register_llm+from ...llm_registry import register_llmdef get_setting_from_snapshot(diff --git a/src/local_deep_research/llm/providers/openrouter.py b/src/local_deep_research/llm/providers/implementations/openrouter.pysimilarity index 96%rename from src/local_deep_research/llm/providers/openrouter.pyrename to src/local_deep_research/llm/providers/implementations/openrouter.pyindex 967d58f485..8ed71cc973 100644--- a/src/local_deep_research/llm/providers/openrouter.py+++ b/src/local_deep_research/llm/providers/implementations/openrouter.py@@ -2,8 +2,8 @@from loguru import logger-from ..llm_registry import register_llm-from .openai_base import OpenAICompatibleProvider+from ...llm_registry import register_llm+from ..openai_base import OpenAICompatibleProviderclass OpenRouterProvider(OpenAICompatibleProvider):diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.pyindex e9a6d5193b..8409f632a2 100644--- a/src/local_deep_research/web/routes/settings_routes.py+++ b/src/local_deep_research/web/routes/settings_routes.py@@ -1171,7 +1171,7 @@ def api_get_available_models():try:logger.info("Fetching Custom OpenAI Endpoint models")- from ...llm.providers.custom_openai_endpoint import (+ from ...llm.providers.implementations.custom_openai_endpoint import (CustomOpenAIEndpointProvider,)