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.

refactor(llm): remove dead provider-availability surface from llm_config (#4590)

LearningCircuitcc5689012757
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index 0785f11762..b834b43906 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -1,4 +1,3 @@
-from functools import cache
from typing import Any
from langchain_core.language_models import BaseChatModel
@@ -32,156 +31,6 @@ VALID_PROVIDERS = [
]
-def is_openai_available(settings_snapshot=None):
- """Check if OpenAI is available by delegating to the provider class."""
- try:
- from ..llm.providers.implementations.openai import OpenAIProvider
-
- return OpenAIProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking OpenAI availability", exc_info=True)
- return False
-
-
-def is_anthropic_available(settings_snapshot=None):
- """Check if Anthropic is available by delegating to the provider class."""
- try:
- from ..llm.providers.implementations.anthropic import AnthropicProvider
-
- return AnthropicProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking Anthropic availability", exc_info=True)
- return False
-
-
-def is_openai_endpoint_available(settings_snapshot=None):
- """Check if OpenAI endpoint is available by delegating to the provider class."""
- try:
- from ..llm.providers.implementations.custom_openai_endpoint import (
- CustomOpenAIEndpointProvider,
- )
-
- return CustomOpenAIEndpointProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug(
- "Error checking OpenAI endpoint availability", exc_info=True
- )
- return False
-
-
-def is_ollama_available(settings_snapshot=None):
- """Check if Ollama is running by delegating to the provider class."""
- try:
- from ..llm.providers.implementations.ollama import OllamaProvider
-
- return OllamaProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking Ollama availability", exc_info=True)
- return False
-
-
-def is_lmstudio_available(settings_snapshot=None):
- """Check if LM Studio is available by delegating to the provider class."""
- try:
- from ..llm.providers.implementations.lmstudio import LMStudioProvider
-
- return LMStudioProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking LM Studio availability", exc_info=True)
- return False
-
-
-def is_llamacpp_available(settings_snapshot=None):
- """Check if llama.cpp's HTTP server is reachable.
-
- Talks to `llama-server`'s OpenAI-compatible endpoint (no in-process
- `llama-cpp-python` binding required).
- """
- try:
- from ..llm.providers.implementations.llamacpp import LlamaCppProvider
-
- return LlamaCppProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking llama.cpp availability", exc_info=True)
- return False
-
-
-def is_google_available(settings_snapshot=None):
- """Check if Google/Gemini is available"""
- try:
- from ..llm.providers.implementations.google import GoogleProvider
-
- return GoogleProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking Google availability", exc_info=True)
- return False
-
-
-def is_openrouter_available(settings_snapshot=None):
- """Check if OpenRouter is available"""
- try:
- from ..llm.providers.implementations.openrouter import (
- OpenRouterProvider,
- )
-
- return OpenRouterProvider.is_available(settings_snapshot)
- except ImportError:
- return False
- except Exception:
- logger.debug("Error checking OpenRouter availability", exc_info=True)
- return False
-
-
-@cache
-def get_available_providers(settings_snapshot=None):
- """Return available model providers"""
- providers = {}
-
- if is_ollama_available(settings_snapshot):
- providers["ollama"] = "Ollama (local models)"
-
- if is_openai_available(settings_snapshot):
- providers["openai"] = "OpenAI API"
-
- if is_anthropic_available(settings_snapshot):
- providers["anthropic"] = "Anthropic API"
-
- if is_google_available(settings_snapshot):
- providers["google"] = "Google Gemini API"
-
- if is_openrouter_available(settings_snapshot):
- providers["openrouter"] = "OpenRouter API"
-
- if is_openai_endpoint_available(settings_snapshot):
- providers["openai_endpoint"] = "OpenAI-Compatible Endpoint"
-
- if is_lmstudio_available(settings_snapshot):
- providers["lmstudio"] = "LM Studio (local models)"
-
- if is_llamacpp_available(settings_snapshot):
- providers["llamacpp"] = "LlamaCpp (local models)"
-
- # Default fallback
- if not providers:
- providers["none"] = "No model providers available"
-
- return providers
-
-
def get_selected_llm_provider(settings_snapshot=None):
return normalize_provider(
get_setting_from_snapshot(
diff --git a/src/local_deep_research/web/services/settings_service.py b/src/local_deep_research/web/services/settings_service.py
index 24d892dcec..723eae3508 100644
--- a/src/local_deep_research/web/services/settings_service.py
+++ b/src/local_deep_research/web/services/settings_service.py
@@ -73,7 +73,10 @@ def invalidate_settings_caches(username=None):
username: If provided, invalidates only that user's scheduler cache.
If None, invalidates all users' scheduler caches.
"""
- # 1. News scheduler per-user settings cache (TTLCache, 5-min TTL)
+ # News scheduler per-user settings cache (TTLCache, 5-min TTL).
+ # NOTE: the LLM provider dropdown is served by the auto-discovery path
+ # (llm/providers/auto_discovery.get_discovered_provider_options), which
+ # rebuilds per call and has no cache to invalidate here.
try:
from ...scheduler.background import get_background_job_scheduler
@@ -85,14 +88,6 @@ def invalidate_settings_caches(username=None):
except Exception:
logger.debug("Could not invalidate scheduler cache", exc_info=True)
- # 2. LLM provider cache (functools.cache, no TTL)
- try:
- from ...config.llm_config import get_available_providers
-
- get_available_providers.cache_clear()
- except Exception:
- logger.debug("Could not clear provider cache", exc_info=True)
-
def validate_setting(
setting: Setting, value: Any
diff --git a/tests/config/test_llm_config.py b/tests/config/test_llm_config.py
index 3d3eaf12b5..9449a490a8 100644
--- a/tests/config/test_llm_config.py
+++ b/tests/config/test_llm_config.py
@@ -5,15 +5,6 @@ from unittest.mock import MagicMock, patch
from local_deep_research.config.llm_config import (
VALID_PROVIDERS,
- is_openai_available,
- is_anthropic_available,
- is_openai_endpoint_available,
- is_ollama_available,
- is_lmstudio_available,
- is_llamacpp_available,
- is_google_available,
- is_openrouter_available,
- get_available_providers,
get_selected_llm_provider,
wrap_llm_without_think_tags,
get_llm,
@@ -44,250 +35,6 @@ class TestValidProviders:
assert isinstance(VALID_PROVIDERS, list)
-class TestIsOpenaiAvailable:
- """Tests for is_openai_available function (delegates to OpenAIProvider)."""
-
- def test_returns_true_when_api_key_set(self):
- """Should return True when API key is configured."""
- with patch(
- "local_deep_research.llm.providers.implementations.openai.OpenAIProvider.is_available",
- return_value=True,
- ):
- assert is_openai_available() is True
-
- def test_returns_false_when_no_api_key(self):
- """Should return False when no API key."""
- with patch(
- "local_deep_research.llm.providers.implementations.openai.OpenAIProvider.is_available",
- return_value=False,
- ):
- assert is_openai_available() is False
-
- def test_returns_false_on_exception(self):
- """Should return False on exception."""
- with patch(
- "local_deep_research.llm.providers.implementations.openai.OpenAIProvider.is_available",
- side_effect=Exception("error"),
- ):
- assert is_openai_available() is False
-
-
-class TestIsAnthropicAvailable:
- """Tests for is_anthropic_available function (delegates to AnthropicProvider)."""
-
- def test_returns_true_when_api_key_set(self):
- """Should return True when API key is configured."""
- with patch(
- "local_deep_research.llm.providers.implementations.anthropic.AnthropicProvider.is_available",
- return_value=True,
- ):
- assert is_anthropic_available() is True
-
- def test_returns_false_when_no_api_key(self):
- """Should return False when no API key."""
- with patch(
- "local_deep_research.llm.providers.implementations.anthropic.AnthropicProvider.is_available",
- return_value=False,
- ):
- assert is_anthropic_available() is False
-
-
-class TestIsOpenaiEndpointAvailable:
- """Tests for is_openai_endpoint_available function (delegates to CustomOpenAIEndpointProvider)."""
-
- def test_returns_true_when_api_key_set(self):
- """Should return True when API key is configured."""
- with patch(
- "local_deep_research.llm.providers.implementations.custom_openai_endpoint.CustomOpenAIEndpointProvider.is_available",
- return_value=True,
- ):
- assert is_openai_endpoint_available() is True
-
- def test_returns_false_when_no_api_key(self):
- """Should return False when no API key."""
- with patch(
- "local_deep_research.llm.providers.implementations.custom_openai_endpoint.CustomOpenAIEndpointProvider.is_available",
- return_value=False,
- ):
- assert is_openai_endpoint_available() is False
-
-
-class TestIsOllamaAvailable:
- """Tests for is_ollama_available function (delegates to OllamaProvider)."""
-
- def test_returns_true_when_ollama_responds(self):
- """Should return True when OllamaProvider reports available."""
- with patch(
- "local_deep_research.llm.providers.implementations.ollama.OllamaProvider.is_available",
- return_value=True,
- ):
- assert is_ollama_available() is True
-
- def test_returns_false_when_ollama_not_running(self):
- """Should return False when OllamaProvider reports unavailable."""
- with patch(
- "local_deep_research.llm.providers.implementations.ollama.OllamaProvider.is_available",
- return_value=False,
- ):
- assert is_ollama_available() is False
-
- def test_returns_false_on_exception(self):
- """Should return False on exception."""
- with patch(
- "local_deep_research.llm.providers.implementations.ollama.OllamaProvider.is_available",
- side_effect=Exception("error"),
- ):
- assert is_ollama_available() is False
-
-
-class TestIsLmstudioAvailable:
- """Tests for is_lmstudio_available function (delegates to LMStudioProvider)."""
-
- def test_returns_true_when_lmstudio_responds(self):
- """Should return True when LMStudioProvider reports available."""
- with patch(
- "local_deep_research.llm.providers.implementations.lmstudio.LMStudioProvider.is_available",
- return_value=True,
- ):
- assert is_lmstudio_available() is True
-
- def test_returns_false_when_not_running(self):
- """Should return False when LMStudioProvider reports unavailable."""
- with patch(
- "local_deep_research.llm.providers.implementations.lmstudio.LMStudioProvider.is_available",
- return_value=False,
- ):
- assert is_lmstudio_available() is False
-
-
-class TestIsLlamacppAvailable:
- """Tests for is_llamacpp_available function (delegates to LlamaCppProvider)."""
-
- def test_returns_true_when_llama_server_responds(self):
- """Should return True when LlamaCppProvider reports available."""
- with patch(
- "local_deep_research.llm.providers.implementations.llamacpp.LlamaCppProvider.is_available",
- return_value=True,
- ):
- assert is_llamacpp_available() is True
-
- def test_returns_false_when_not_running(self):
- """Should return False when LlamaCppProvider reports unavailable."""
- with patch(
- "local_deep_research.llm.providers.implementations.llamacpp.LlamaCppProvider.is_available",
- return_value=False,
- ):
- assert is_llamacpp_available() is False
-
-
-class TestIsGoogleAvailable:
- """Tests for is_google_available function."""
-
- def test_delegates_to_provider(self):
- """Should delegate to GoogleProvider.is_available."""
- with patch(
- "local_deep_research.config.llm_config.is_google_available"
- ) as mock:
- mock.return_value = True
- # Can't easily test delegation without importing the actual provider
- # Just verify the function exists and can be called
- _result = is_google_available() # noqa: F841
- # Result depends on actual provider availability
-
-
-class TestIsOpenrouterAvailable:
- """Tests for is_openrouter_available function."""
-
- def test_delegates_to_provider(self):
- """Should delegate to OpenRouterProvider.is_available."""
- # Similar to is_google_available
- result = is_openrouter_available()
- assert isinstance(result, bool)
-
-
-class TestGetAvailableProviders:
- """Tests for get_available_providers function."""
-
- def test_returns_dict(self):
- """Should return a dictionary."""
- # Clear cache first
- get_available_providers.cache_clear()
- with patch(
- "local_deep_research.config.llm_config.is_ollama_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_openai_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_anthropic_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_google_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_openrouter_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_openai_endpoint_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_lmstudio_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_llamacpp_available",
- return_value=False,
- ):
- result = get_available_providers()
- assert isinstance(result, dict)
- # Should have "none" when no providers available
- assert "none" in result
-
- def test_includes_ollama_when_available(self):
- """Should include ollama when available."""
- get_available_providers.cache_clear()
- with patch(
- "local_deep_research.config.llm_config.is_ollama_available",
- return_value=True,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_openai_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_anthropic_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_google_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_openrouter_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_openai_endpoint_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_lmstudio_available",
- return_value=False,
- ):
- with patch(
- "local_deep_research.config.llm_config.is_llamacpp_available",
- return_value=False,
- ):
- result = get_available_providers()
- assert "ollama" in result
-
-
class TestGetSelectedLlmProvider:
"""Tests for get_selected_llm_provider function."""
@@ -661,3 +408,74 @@ class TestWrapperStringResponse:
wrapper = wrap_llm_without_think_tags(mock_llm)
with pytest.raises(RuntimeError, match="LLM error"):
wrapper.invoke("test")
+
+
+class TestImportTimeAutoDiscovery:
+ """Guard the import-time provider auto-discovery contract.
+
+ ``llm_config`` imports ``discover_providers`` (``# noqa: F401``) purely
+ for its import-time side effect: registering every built-in provider.
+ Since get_llm() has no fallback construction path, removing that import
+ would leave the registry empty and break every dispatch. This runs in a
+ fresh interpreter so the assertion genuinely exercises import-time
+ registration rather than registrations left over from earlier tests.
+ """
+
+ def test_importing_llm_config_registers_builtin_providers(self):
+ import subprocess
+ import sys
+
+ code = (
+ "from local_deep_research.config import llm_config # noqa: F401\n"
+ "from local_deep_research.llm import is_llm_registered\n"
+ "assert is_llm_registered('openai'), 'openai not registered'\n"
+ "assert is_llm_registered('anthropic'), 'anthropic not registered'\n"
+ "print('OK')\n"
+ )
+ result = subprocess.run(
+ [sys.executable, "-c", code],
+ capture_output=True,
+ text=True,
+ )
+ assert result.returncode == 0, (
+ f"import-time registration failed:\n"
+ f"stdout={result.stdout}\nstderr={result.stderr}"
+ )
+ assert "OK" in result.stdout
+
+
+class TestDiscoveredProviderOptions:
+ """The live UI provider-dropdown path (replaces the removed
+ get_available_providers()): get_discovered_provider_options() enumerates
+ all discovered provider classes; get_available_discovered_provider_options()
+ filters that set by ProviderClass.is_available(settings_snapshot)."""
+
+ def test_discovered_options_shape_and_core_providers(self):
+ from local_deep_research.llm.providers import (
+ get_discovered_provider_options,
+ )
+
+ options = get_discovered_provider_options()
+ assert isinstance(options, list) and options
+ for opt in options:
+ assert "value" in opt and "label" in opt
+ values = {opt["value"].lower() for opt in options}
+ # Core built-in providers must always be discovered.
+ for provider in ("openai", "anthropic", "ollama"):
+ assert provider in values
+
+ def test_available_options_is_filtered_subset(self):
+ from local_deep_research.llm.providers import (
+ get_discovered_provider_options,
+ get_available_discovered_provider_options,
+ )
+
+ all_values = {
+ o["value"].lower() for o in get_discovered_provider_options()
+ }
+ # With no settings snapshot, no API keys / reachable local servers
+ # are configured, so the filtered set is a (here empty) subset.
+ available = get_available_discovered_provider_options(None)
+ assert isinstance(available, list)
+ available_values = {o["value"].lower() for o in available}
+ assert available_values <= all_values
diff --git a/tests/config/test_llm_config_behavior.py b/tests/config/test_llm_config_behavior.py
index 7c93d4dca8..766379c672 100644
--- a/tests/config/test_llm_config_behavior.py
+++ b/tests/config/test_llm_config_behavior.py
@@ -16,56 +16,69 @@ class TestApiKeyAvailabilityChecks:
"""
def test_openai_available_with_api_key(self):
- from local_deep_research.config.llm_config import is_openai_available
+ from local_deep_research.llm.providers.implementations.openai import (
+ OpenAIProvider,
+ )
- result = is_openai_available(
+ result = OpenAIProvider.is_available(
settings_snapshot={"llm.openai.api_key": "sk-test"}
)
assert result is True
def test_openai_unavailable_without_api_key(self):
- from local_deep_research.config.llm_config import is_openai_available
+ from local_deep_research.llm.providers.implementations.openai import (
+ OpenAIProvider,
+ )
- assert is_openai_available(settings_snapshot={}) is False
+ assert OpenAIProvider.is_available(settings_snapshot={}) is False
def test_openai_unavailable_with_empty_api_key(self):
"""Empty string API key is falsy — treated as missing."""
- from local_deep_research.config.llm_config import is_openai_available
+ from local_deep_research.llm.providers.implementations.openai import (
+ OpenAIProvider,
+ )
- result = is_openai_available(
+ result = OpenAIProvider.is_available(
settings_snapshot={"llm.openai.api_key": ""}
)
assert result is False
def test_anthropic_available_with_api_key(self):
- from local_deep_research.config.llm_config import is_anthropic_available
+ from local_deep_research.llm.providers.implementations.anthropic import (
+ AnthropicProvider,
+ )
- result = is_anthropic_available(
+ result = AnthropicProvider.is_available(
settings_snapshot={"llm.anthropic.api_key": "sk-ant-test"}
)
assert result is True
def test_anthropic_unavailable_without_api_key(self):
- from local_deep_research.config.llm_config import is_anthropic_available
+ from local_deep_research.llm.providers.implementations.anthropic import (
+ AnthropicProvider,
+ )
- assert is_anthropic_available(settings_snapshot={}) is False
+ assert AnthropicProvider.is_available(settings_snapshot={}) is False
def test_openai_endpoint_available_with_api_key(self):
- from local_deep_research.config.llm_config import (
- is_openai_endpoint_available,
+ from local_deep_research.llm.providers.implementations.custom_openai_endpoint import (
+ CustomOpenAIEndpointProvider,
)
- result = is_openai_endpoint_available(
+ result = CustomOpenAIEndpointProvider.is_available(
settings_snapshot={"llm.openai_endpoint.api_key": "key123"}
)
assert result is True
def test_openai_endpoint_unavailable_without_api_key(self):
- from local_deep_research.config.llm_config import (
- is_openai_endpoint_available,
+ from local_deep_research.llm.providers.implementations.custom_openai_endpoint import (
+ CustomOpenAIEndpointProvider,
)
- assert is_openai_endpoint_available(settings_snapshot={}) is False
+ assert (
+ CustomOpenAIEndpointProvider.is_available(settings_snapshot={})
+ is False
+ )
class TestProviderValidation:
diff --git a/tests/config/test_llm_config_coverage.py b/tests/config/test_llm_config_coverage.py
index 400a14476e..dac4095440 100644
--- a/tests/config/test_llm_config_coverage.py
+++ b/tests/config/test_llm_config_coverage.py
@@ -3,14 +3,11 @@ Comprehensive tests for provider availability functions and related helpers
in local_deep_research/config/llm_config.py.
Focuses on gaps not covered by existing test files:
-- is_*_available() import-error and exception branches
-- get_available_providers() multi-provider and cache behaviour
- wrap_llm_without_think_tags() context_limit injection, token counter, string responses
- _get_context_window_for_provider() edge cases
- get_selected_llm_provider() with snapshot parameter
"""
-import sys
from unittest.mock import MagicMock, patch
import pytest
@@ -22,558 +19,6 @@ import pytest
MODULE = "local_deep_research.config.llm_config"
-def _patch_all_availability(**overrides):
- """Return a context manager that patches every is_*_available to False
- unless overridden. Usage: _patch_all_availability(ollama=True, openai=True)
- """
- defaults = {
- "ollama": False,
- "openai": False,
- "anthropic": False,
- "google": False,
- "openrouter": False,
- "openai_endpoint": False,
- "lmstudio": False,
- "llamacpp": False,
- }
- defaults.update(overrides)
-
- from contextlib import ExitStack
-
- stack = ExitStack()
- for name, val in defaults.items():
- fn_name = f"is_{name}_available"
- stack.enter_context(patch(f"{MODULE}.{fn_name}", return_value=val))
- return stack
-
-
-# ===================================================================
-# is_openai_available
-# ===================================================================
-
-
-class TestIsOpenAIAvailable:
- """Edge-case coverage for is_openai_available()."""
-
- def test_import_error_returns_false(self):
- """When OpenAIProvider cannot be imported, returns False."""
- with patch.dict(
- sys.modules,
- {"local_deep_research.llm.providers.implementations.openai": None},
- ):
- # Force re-import by calling the function which does a local import
- from local_deep_research.config.llm_config import (
- is_openai_available,
- )
-
- result = is_openai_available()
- assert result is False
-
- def test_passes_settings_snapshot_through(self):
- """settings_snapshot is forwarded to OpenAIProvider.is_available."""
- snap = {"llm.openai.api_key": "sk-test"}
- with patch(
- "local_deep_research.llm.providers.implementations.openai.OpenAIProvider.is_available",
- return_value=True,
- ) as mock_avail:
- from local_deep_research.config.llm_config import (
- is_openai_available,
- )
-
- is_openai_available(settings_snapshot=snap)
- mock_avail.assert_called_once_with(snap)
-
-
-# ===================================================================
-# is_anthropic_available
-# ===================================================================
-
-
-class TestIsAnthropicAvailable:
- """Edge-case coverage for is_anthropic_available()."""
-
- def test_import_error_returns_false(self):
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.anthropic": None
- },
- ):
- from local_deep_research.config.llm_config import (
- is_anthropic_available,
- )
-
- result = is_anthropic_available()
- assert result is False
-
- def test_passes_settings_snapshot_through(self):
- snap = {"llm.anthropic.api_key": "sk-ant-x"}
- with patch(
- "local_deep_research.llm.providers.implementations.anthropic.AnthropicProvider.is_available",
- return_value=True,
- ) as mock_avail:
- from local_deep_research.config.llm_config import (
- is_anthropic_available,
- )
-
- is_anthropic_available(settings_snapshot=snap)
- mock_avail.assert_called_once_with(snap)
-
-
-# ===================================================================
-# is_ollama_available
-# ===================================================================
-
-
-class TestIsOllamaAvailable:
- """Edge-case coverage for is_ollama_available()."""
-
- def test_import_error_returns_false(self):
- with patch.dict(
- sys.modules,
- {"local_deep_research.llm.providers.implementations.ollama": None},
- ):
- from local_deep_research.config.llm_config import (
- is_ollama_available,
- )
-
- result = is_ollama_available()
- assert result is False
-
- def test_passes_settings_snapshot_through(self):
- snap = {"llm.ollama.url": "http://localhost:11434"}
- with patch(
- "local_deep_research.llm.providers.implementations.ollama.OllamaProvider.is_available",
- return_value=True,
- ) as mock_avail:
- from local_deep_research.config.llm_config import (
- is_ollama_available,
- )
-
- is_ollama_available(settings_snapshot=snap)
- mock_avail.assert_called_once_with(snap)
-
-
-# ===================================================================
-# is_openai_endpoint_available
-# ===================================================================
-
-
-class TestIsOpenAIEndpointAvailable:
- """Edge-case coverage for is_openai_endpoint_available()."""
-
- def test_import_error_returns_false(self):
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.custom_openai_endpoint": None
- },
- ):
- from local_deep_research.config.llm_config import (
- is_openai_endpoint_available,
- )
-
- result = is_openai_endpoint_available()
- assert result is False
-
- def test_exception_returns_false(self):
- with patch(
- "local_deep_research.llm.providers.implementations.custom_openai_endpoint.CustomOpenAIEndpointProvider.is_available",
- side_effect=RuntimeError("boom"),
- ):
- from local_deep_research.config.llm_config import (
- is_openai_endpoint_available,
- )
-
- assert is_openai_endpoint_available() is False
-
-
-# ===================================================================
-# is_lmstudio_available
-# ===================================================================
-
-
-class TestIsLMStudioAvailable:
- """Edge-case coverage for is_lmstudio_available()."""
-
- def test_import_error_returns_false(self):
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.lmstudio": None
- },
- ):
- from local_deep_research.config.llm_config import (
- is_lmstudio_available,
- )
-
- result = is_lmstudio_available()
- assert result is False
-
- def test_exception_returns_false(self):
- with patch(
- "local_deep_research.llm.providers.implementations.lmstudio.LMStudioProvider.is_available",
- side_effect=RuntimeError("boom"),
- ):
- from local_deep_research.config.llm_config import (
- is_lmstudio_available,
- )
-
- assert is_lmstudio_available() is False
-
-
-# ===================================================================
-# is_llamacpp_available
-# ===================================================================
-
-
-class TestIsLlamaCppAvailable:
- """Edge-case coverage for is_llamacpp_available() — now HTTP-based."""
-
- LLAMACPP_PROVIDER = "local_deep_research.llm.providers.implementations.llamacpp.LlamaCppProvider"
-
- def test_returns_true_when_provider_available(self):
- """Returns True when LlamaCppProvider.is_available() returns True."""
- with patch(f"{self.LLAMACPP_PROVIDER}.is_available", return_value=True):
- from local_deep_research.config.llm_config import (
- is_llamacpp_available,
- )
-
- assert is_llamacpp_available() is True
-
- def test_returns_false_when_provider_unavailable(self):
- """Returns False when llama-server isn't reachable."""
- with patch(
- f"{self.LLAMACPP_PROVIDER}.is_available", return_value=False
- ):
- from local_deep_research.config.llm_config import (
- is_llamacpp_available,
- )
-
- assert is_llamacpp_available() is False
-
- def test_generic_exception_returns_false(self):
- """Unexpected exception in is_llamacpp_available returns False."""
- with patch(
- f"{self.LLAMACPP_PROVIDER}.is_available",
- side_effect=RuntimeError("unexpected"),
- ):
- from local_deep_research.config.llm_config import (
- is_llamacpp_available,
- )
-
- assert is_llamacpp_available() is False
-
-
-# ===================================================================
-# is_google_available
-# ===================================================================
-
-
-class TestIsGoogleAvailable:
- """Edge-case coverage for is_google_available()."""
-
- def test_import_error_returns_false(self):
- with patch.dict(
- sys.modules,
- {"local_deep_research.llm.providers.implementations.google": None},
- ):
- from local_deep_research.config.llm_config import (
- is_google_available,
- )
-
- assert is_google_available() is False
-
- def test_exception_returns_false(self):
- """When GoogleProvider.is_available raises, returns False."""
- mock_module = MagicMock()
- mock_module.GoogleProvider.is_available.side_effect = RuntimeError(
- "boom"
- )
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.google": mock_module
- },
- ):
- from local_deep_research.config.llm_config import (
- is_google_available,
- )
-
- assert is_google_available() is False
-
- def test_returns_true_when_provider_reports_available(self):
- mock_module = MagicMock()
- mock_module.GoogleProvider.is_available.return_value = True
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.google": mock_module
- },
- ):
- from local_deep_research.config.llm_config import (
- is_google_available,
- )
-
- assert is_google_available() is True
-
- def test_returns_false_when_provider_reports_unavailable(self):
- mock_module = MagicMock()
- mock_module.GoogleProvider.is_available.return_value = False
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.google": mock_module
- },
- ):
- from local_deep_research.config.llm_config import (
- is_google_available,
- )
-
- assert is_google_available() is False
-
-
-# ===================================================================
-# is_openrouter_available
-# ===================================================================
-
-
-class TestIsOpenRouterAvailable:
- """Edge-case coverage for is_openrouter_available()."""
-
- def test_import_error_returns_false(self):
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.openrouter": None
- },
- ):
- from local_deep_research.config.llm_config import (
- is_openrouter_available,
- )
-
- assert is_openrouter_available() is False
-
- def test_exception_returns_false(self):
- mock_module = MagicMock()
- mock_module.OpenRouterProvider.is_available.side_effect = RuntimeError(
- "boom"
- )
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.openrouter": mock_module
- },
- ):
- from local_deep_research.config.llm_config import (
- is_openrouter_available,
- )
-
- assert is_openrouter_available() is False
-
- def test_returns_true_when_provider_reports_available(self):
- mock_module = MagicMock()
- mock_module.OpenRouterProvider.is_available.return_value = True
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.openrouter": mock_module
- },
- ):
- from local_deep_research.config.llm_config import (
- is_openrouter_available,
- )
-
- assert is_openrouter_available() is True
-
- def test_returns_false_when_provider_reports_unavailable(self):
- mock_module = MagicMock()
- mock_module.OpenRouterProvider.is_available.return_value = False
- with patch.dict(
- sys.modules,
- {
- "local_deep_research.llm.providers.implementations.openrouter": mock_module
- },
- ):
- from local_deep_research.config.llm_config import (
- is_openrouter_available,
- )
-
- assert is_openrouter_available() is False
-
-
-# ===================================================================
-# ===================================================================
-# get_available_providers (cached function)
-# ===================================================================
-
-
-class TestGetAvailableProviders:
- """Tests for get_available_providers() with multiple providers and cache."""
-
- def setup_method(self):
- """Clear the LRU cache before each test."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- get_available_providers.cache_clear()
-
- def test_no_providers_returns_none_key(self):
- """When nothing is available, dict contains only 'none'."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability():
- result = get_available_providers()
- assert result == {"none": "No model providers available"}
-
- def test_only_ollama_available(self):
- """Only ollama available."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(ollama=True):
- result = get_available_providers()
- assert "ollama" in result
- assert result["ollama"] == "Ollama (local models)"
- assert "none" not in result
-
- def test_only_openai_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(openai=True):
- result = get_available_providers()
- assert "openai" in result
- assert result["openai"] == "OpenAI API"
- assert "none" not in result
-
- def test_only_anthropic_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(anthropic=True):
- result = get_available_providers()
- assert "anthropic" in result
- assert result["anthropic"] == "Anthropic API"
-
- def test_only_google_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(google=True):
- result = get_available_providers()
- assert "google" in result
- assert result["google"] == "Google Gemini API"
-
- def test_only_openrouter_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(openrouter=True):
- result = get_available_providers()
- assert "openrouter" in result
- assert result["openrouter"] == "OpenRouter API"
-
- def test_only_openai_endpoint_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(openai_endpoint=True):
- result = get_available_providers()
- assert "openai_endpoint" in result
- assert result["openai_endpoint"] == "OpenAI-Compatible Endpoint"
-
- def test_only_lmstudio_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(lmstudio=True):
- result = get_available_providers()
- assert "lmstudio" in result
- assert result["lmstudio"] == "LM Studio (local models)"
-
- def test_only_llamacpp_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(llamacpp=True):
- result = get_available_providers()
- assert "llamacpp" in result
- assert result["llamacpp"] == "LlamaCpp (local models)"
-
- def test_multiple_providers_available(self):
- """Multiple providers yields dict with all of them, no 'none'."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(ollama=True, openai=True, anthropic=True):
- result = get_available_providers()
- assert "ollama" in result
- assert "openai" in result
- assert "anthropic" in result
- assert "none" not in result
-
- def test_all_providers_available(self):
- """All providers enabled results in all keys present."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(
- ollama=True,
- openai=True,
- anthropic=True,
- google=True,
- openrouter=True,
- openai_endpoint=True,
- lmstudio=True,
- llamacpp=True,
- ):
- result = get_available_providers()
- assert len(result) == 8
- assert "none" not in result
-
- def test_cache_returns_same_object(self):
- """Calling twice without cache_clear returns the cached dict."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(openai=True):
- first = get_available_providers()
- second = get_available_providers()
- assert first is second
-
- def test_cache_clear_resets(self):
- """After cache_clear, function re-evaluates availability."""
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- with _patch_all_availability(openai=True):
- first = get_available_providers()
- assert "openai" in first
-
- get_available_providers.cache_clear()
-
- with _patch_all_availability(anthropic=True):
- second = get_available_providers()
- assert "anthropic" in second
- assert "openai" not in second
-
-
# ===================================================================
# get_selected_llm_provider
# ===================================================================
diff --git a/tests/config/test_llm_config_extra_coverage.py b/tests/config/test_llm_config_extra_coverage.py
index 6e67befd0b..289990b751 100644
--- a/tests/config/test_llm_config_extra_coverage.py
+++ b/tests/config/test_llm_config_extra_coverage.py
@@ -1,176 +1,16 @@
-"""Extra coverage tests for config/llm_config.py — provider availability and context window.
+"""Extra coverage tests for config/llm_config.py — context window and provider selection.
Targets uncovered branches:
-- is_*_available() Exception (non-ImportError) paths
-- is_llamacpp_available() path configurations
- _get_context_window_for_provider() all branches
-- get_available_providers() with various provider combinations
- get_selected_llm_provider()
"""
-from unittest.mock import MagicMock, patch
+from unittest.mock import patch
MODULE = "local_deep_research.config.llm_config"
-# ===========================================================================
-# is_*_available — Exception (non-ImportError) paths
-# ===========================================================================
-
-
-class TestProviderAvailabilityExceptionPaths:
- """Each is_*_available catches both ImportError and Exception.
- Test the Exception branch (provider imported but is_available raises)."""
-
- def test_openai_exception_returns_false(self):
- from local_deep_research.config.llm_config import is_openai_available
-
- with patch(
- f"{MODULE}.OpenAIProvider",
- create=True,
- ):
- # Patch the import to succeed but is_available to raise
- mock_provider = MagicMock()
- mock_provider.is_available.side_effect = RuntimeError("API error")
-
- with patch.dict(
- "sys.modules",
- {
- "local_deep_research.llm.providers.implementations.openai": MagicMock(
- OpenAIProvider=mock_provider
- )
- },
- ):
- result = is_openai_available()
-
- assert result is False
-
- def test_anthropic_exception_returns_false(self):
- from local_deep_research.config.llm_config import is_anthropic_available
-
- mock_mod = MagicMock()
- mock_mod.AnthropicProvider.is_available.side_effect = RuntimeError(
- "err"
- )
-
- with patch.dict(
- "sys.modules",
- {
- "local_deep_research.llm.providers.implementations.anthropic": mock_mod
- },
- ):
- assert is_anthropic_available() is False
-
- def test_ollama_exception_returns_false(self):
- from local_deep_research.config.llm_config import is_ollama_available
-
- mock_mod = MagicMock()
- mock_mod.OllamaProvider.is_available.side_effect = ConnectionError(
- "refused"
- )
-
- with patch.dict(
- "sys.modules",
- {
- "local_deep_research.llm.providers.implementations.ollama": mock_mod
- },
- ):
- assert is_ollama_available() is False
-
- def test_openai_endpoint_exception_returns_false(self):
- from local_deep_research.config.llm_config import (
- is_openai_endpoint_available,
- )
-
- mock_mod = MagicMock()
- mock_mod.CustomOpenAIEndpointProvider.is_available.side_effect = (
- ValueError("bad config")
- )
-
- with patch.dict(
- "sys.modules",
- {
- "local_deep_research.llm.providers.implementations.custom_openai_endpoint": mock_mod
- },
- ):
- assert is_openai_endpoint_available() is False
-
- def test_lmstudio_exception_returns_false(self):
- from local_deep_research.config.llm_config import is_lmstudio_available
-
- mock_mod = MagicMock()
- mock_mod.LMStudioProvider.is_available.side_effect = TimeoutError()
-
- with patch.dict(
- "sys.modules",
- {
- "local_deep_research.llm.providers.implementations.lmstudio": mock_mod
- },
- ):
- assert is_lmstudio_available() is False
-
- def test_google_exception_returns_false(self):
- from local_deep_research.config.llm_config import is_google_available
-
- mock_mod = MagicMock()
- mock_mod.GoogleProvider.is_available.side_effect = RuntimeError("auth")
-
- with patch.dict(
- "sys.modules",
- {"local_deep_research.llm.providers.google": mock_mod},
- ):
- assert is_google_available() is False
-
- def test_openrouter_exception_returns_false(self):
- from local_deep_research.config.llm_config import (
- is_openrouter_available,
- )
-
- mock_mod = MagicMock()
- mock_mod.OpenRouterProvider.is_available.side_effect = RuntimeError()
-
- with patch.dict(
- "sys.modules",
- {"local_deep_research.llm.providers.openrouter": mock_mod},
- ):
- assert is_openrouter_available() is False
-
-
-# ===========================================================================
-# is_llamacpp_available
-# ===========================================================================
-
-
-class TestIsLlamacppAvailable:
- """is_llamacpp_available now probes llama-server's HTTP endpoint."""
-
- LLAMACPP_PROVIDER = "local_deep_research.llm.providers.implementations.llamacpp.LlamaCppProvider"
-
- def test_returns_true_when_provider_available(self):
- from local_deep_research.config.llm_config import is_llamacpp_available
-
- with patch(f"{self.LLAMACPP_PROVIDER}.is_available", return_value=True):
- assert is_llamacpp_available(settings_snapshot={}) is True
-
- def test_returns_false_when_provider_unavailable(self):
- from local_deep_research.config.llm_config import is_llamacpp_available
-
- with patch(
- f"{self.LLAMACPP_PROVIDER}.is_available", return_value=False
- ):
- assert is_llamacpp_available(settings_snapshot={}) is False
-
- def test_returns_false_on_unexpected_exception(self):
- from local_deep_research.config.llm_config import is_llamacpp_available
-
- with patch(
- f"{self.LLAMACPP_PROVIDER}.is_available",
- side_effect=RuntimeError("boom"),
- ):
- assert is_llamacpp_available(settings_snapshot={}) is False
-
-
# ===========================================================================
# _get_context_window_for_provider
# ===========================================================================
@@ -272,81 +112,6 @@ class TestGetContextWindowForProvider:
assert result == 16384
-# ===========================================================================
-# get_available_providers
-# ===========================================================================
-
-
-class TestGetAvailableProviders:
- def test_no_providers_returns_none_entry(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- get_available_providers.cache_clear()
-
- with (
- patch(f"{MODULE}.is_ollama_available", return_value=False),
- patch(f"{MODULE}.is_openai_available", return_value=False),
- patch(f"{MODULE}.is_anthropic_available", return_value=False),
- patch(f"{MODULE}.is_google_available", return_value=False),
- patch(f"{MODULE}.is_openrouter_available", return_value=False),
- patch(f"{MODULE}.is_openai_endpoint_available", return_value=False),
- patch(f"{MODULE}.is_lmstudio_available", return_value=False),
- patch(f"{MODULE}.is_llamacpp_available", return_value=False),
- ):
- result = get_available_providers()
-
- assert "none" in result
- get_available_providers.cache_clear()
-
- def test_multiple_providers_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- get_available_providers.cache_clear()
-
- with (
- patch(f"{MODULE}.is_ollama_available", return_value=True),
- patch(f"{MODULE}.is_openai_available", return_value=True),
- patch(f"{MODULE}.is_anthropic_available", return_value=False),
- patch(f"{MODULE}.is_google_available", return_value=False),
- patch(f"{MODULE}.is_openrouter_available", return_value=False),
- patch(f"{MODULE}.is_openai_endpoint_available", return_value=False),
- patch(f"{MODULE}.is_lmstudio_available", return_value=False),
- patch(f"{MODULE}.is_llamacpp_available", return_value=False),
- ):
- result = get_available_providers()
-
- assert "ollama" in result
- assert "openai" in result
- assert "none" not in result
- get_available_providers.cache_clear()
-
- def test_all_providers_available(self):
- from local_deep_research.config.llm_config import (
- get_available_providers,
- )
-
- get_available_providers.cache_clear()
-
- with (
- patch(f"{MODULE}.is_ollama_available", return_value=True),
- patch(f"{MODULE}.is_openai_available", return_value=True),
- patch(f"{MODULE}.is_anthropic_available", return_value=True),
- patch(f"{MODULE}.is_google_available", return_value=True),
- patch(f"{MODULE}.is_openrouter_available", return_value=True),
- patch(f"{MODULE}.is_openai_endpoint_available", return_value=True),
- patch(f"{MODULE}.is_lmstudio_available", return_value=True),
- patch(f"{MODULE}.is_llamacpp_available", return_value=True),
- ):
- result = get_available_providers()
-
- assert len(result) == 8
- get_available_providers.cache_clear()
-
-
# ===========================================================================
# get_selected_llm_provider
# ===========================================================================
diff --git a/tests/conftest.py b/tests/conftest.py
index dc37f7e6ca..af14f77052 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -607,10 +607,6 @@ def mock_llm_config(monkeypatch):
"llamacpp",
"none",
]
- mock_module.AVAILABLE_PROVIDERS = {"ollama": "Ollama (local models)"}
- mock_module.get_available_providers = lambda: (
- mock_module.AVAILABLE_PROVIDERS
- )
# Patch the module
monkeypatch.setitem(
diff --git a/tests/mock_modules.py b/tests/mock_modules.py
index fe45ad492d..d11c729bc4 100644
--- a/tests/mock_modules.py
+++ b/tests/mock_modules.py
@@ -60,17 +60,8 @@ def create_mock_llm_config(monkeypatch):
mock.invoke.return_value = Mock(content="Mocked LLM response")
return mock
- def get_available_providers():
- return {
- "ollama": "Ollama (local models)",
- "openai": "OpenAI API",
- "anthropic": "Anthropic Claude",
- "none": "No LLM (testing)",
- }
-
attributes = {
"get_llm": get_llm,
- "get_available_providers": get_available_providers,
"VALID_PROVIDERS": [
"ollama",
"openai",
@@ -80,7 +71,6 @@ def create_mock_llm_config(monkeypatch):
"llamacpp",
"none",
],
- "AVAILABLE_PROVIDERS": get_available_providers(),
"DEFAULT_PROVIDER": "ollama",
"DEFAULT_MODEL": "gemma3:12b",
"DEFAULT_TEMPERATURE": 0.7,
diff --git a/tests/test_api_key_configuration.py b/tests/test_api_key_configuration.py
index abd43a5691..3d536aee0f 100644
--- a/tests/test_api_key_configuration.py
+++ b/tests/test_api_key_configuration.py
@@ -10,9 +10,15 @@ from langchain_core.language_models import BaseChatModel
from local_deep_research.config.llm_config import (
get_llm,
- is_openai_available,
- is_anthropic_available,
- is_openai_endpoint_available,
+)
+from local_deep_research.llm.providers.implementations.openai import (
+ OpenAIProvider,
+)
+from local_deep_research.llm.providers.implementations.anthropic import (
+ AnthropicProvider,
+)
+from local_deep_research.llm.providers.implementations.custom_openai_endpoint import (
+ CustomOpenAIEndpointProvider,
)
from local_deep_research.settings import SettingsManager
@@ -354,14 +360,17 @@ class TestAPIKeyConfiguration:
"llm.openai.api_key": {"value": "test-openai-key", "type": "str"}
}
assert (
- is_openai_available(settings_snapshot=settings_with_openai) is True
+ OpenAIProvider.is_available(settings_snapshot=settings_with_openai)
+ is True
)
settings_without_openai = {
"llm.openai.api_key": {"value": None, "type": "str"}
}
assert (
- is_openai_available(settings_snapshot=settings_without_openai)
+ OpenAIProvider.is_available(
+ settings_snapshot=settings_without_openai
+ )
is False
)
@@ -373,7 +382,9 @@ class TestAPIKeyConfiguration:
}
}
assert (
- is_anthropic_available(settings_snapshot=settings_with_anthropic)
+ AnthropicProvider.is_available(
+ settings_snapshot=settings_with_anthropic
+ )
is True
)
@@ -381,7 +392,9 @@ class TestAPIKeyConfiguration:
"llm.anthropic.api_key": {"value": None, "type": "str"}
}
assert (
- is_anthropic_available(settings_snapshot=settings_without_anthropic)
+ AnthropicProvider.is_available(
+ settings_snapshot=settings_without_anthropic
+ )
is False
)
@@ -393,7 +406,7 @@ class TestAPIKeyConfiguration:
}
}
assert (
- is_openai_endpoint_available(
+ CustomOpenAIEndpointProvider.is_available(
settings_snapshot=settings_with_endpoint
)
is True
@@ -403,7 +416,7 @@ class TestAPIKeyConfiguration:
"llm.openai_endpoint.api_key": {"value": None, "type": "str"}
}
assert (
- is_openai_endpoint_available(
+ CustomOpenAIEndpointProvider.is_available(
settings_snapshot=settings_without_endpoint
)
is False
diff --git a/tests/test_context_overflow_detection.py b/tests/test_context_overflow_detection.py
index 1ff272aa99..98adbad769 100644
--- a/tests/test_context_overflow_detection.py
+++ b/tests/test_context_overflow_detection.py
@@ -510,11 +510,11 @@ class TestContextOverflowIntegration:
def test_ollama_context_overflow_real(self):
"""Test with real Ollama instance if available."""
from langchain_ollama import ChatOllama
- from local_deep_research.config.llm_config import (
- is_ollama_available,
+ from local_deep_research.llm.providers.implementations.ollama import (
+ OllamaProvider,
)
- if not is_ollama_available():
+ if not OllamaProvider.is_available():
pytest.skip("Ollama not available")
# Create LLM with small context window
diff --git a/tests/test_llm_provider_integration.py b/tests/test_llm_provider_integration.py
index 67242e7a50..62bca605e8 100644
--- a/tests/test_llm_provider_integration.py
+++ b/tests/test_llm_provider_integration.py
@@ -298,8 +298,8 @@ class TestLLMProviderIntegration:
def test_api_key_validation_before_research(self, mock_session):
"""Test that API key presence is validated before starting research."""
- from local_deep_research.config.llm_config import (
- is_openai_endpoint_available,
+ from local_deep_research.llm.providers.implementations.custom_openai_endpoint import (
+ CustomOpenAIEndpointProvider,
)
with patch.object(
@@ -320,7 +320,7 @@ class TestLLMProviderIntegration:
}
}
assert (
- is_openai_endpoint_available(
+ CustomOpenAIEndpointProvider.is_available(
settings_snapshot=settings_with_key
)
is True
@@ -332,7 +332,7 @@ class TestLLMProviderIntegration:
"llm.openai_endpoint.api_key": {"value": None, "type": "str"}
}
assert (
- is_openai_endpoint_available(
+ CustomOpenAIEndpointProvider.is_available(
settings_snapshot=settings_without_key
)
is False