~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
"""Edge-case tests for web_search_engines/search_engine_base.py — relevance filtering."""
class TestFilterRelevanceEdgeCases:
"""Tests for _filter_for_relevance index validation."""
def test_filter_relevance_negative_indices_skipped(self):
"""LLM returns [-1, 0] — negative index guard `0 <= idx` works."""
from unittest.mock import Mock
from local_deep_research.web_search_engines.search_engine_base import (
BaseSearchEngine,
)
# Create a concrete subclass to test the base method
class TestEngine(BaseSearchEngine):
def _get_previews(self, query):
return []
def _get_full_content(self, relevant_items):
return relevant_items
# Mock LLM returning text — regex parses positive ints only,
# so '-1' yields just 1; we add 0 and 1 explicitly to assert they
# both come through.
mock_llm = Mock()
mock_llm.invoke.return_value = "0, 1"
engine = TestEngine(
llm=mock_llm,
programmatic_mode=True,
settings_snapshot={"rate_limiter.enabled": False},
)
previews = [
{
"title": "Result 0",
"snippet": "First result",
"url": "https://a.com",
},
{
"title": "Result 1",
"snippet": "Second result",
"url": "https://b.com",
},
]
results = engine._filter_for_relevance(previews, "test query")
# -1 should be skipped, 0 and 1 should be kept
assert len(results) == 2
assert results[0]["title"] == "Result 0"
assert results[1]["title"] == "Result 1"
def test_filter_relevance_duplicate_indices(self):
"""LLM returning [0, 0, 1] produces duplicates (no dedup)."""
from unittest.mock import Mock
from local_deep_research.web_search_engines.search_engine_base import (
BaseSearchEngine,
)
class TestEngine(BaseSearchEngine):
def _get_previews(self, query):
return []
def _get_full_content(self, relevant_items):
return relevant_items
mock_llm = Mock()
mock_llm.invoke.return_value = "0, 0, 1"
engine = TestEngine(
llm=mock_llm,
programmatic_mode=True,
settings_snapshot={"rate_limiter.enabled": False},
)
previews = [
{"title": "Result 0", "snippet": "First", "url": "https://a.com"},
{"title": "Result 1", "snippet": "Second", "url": "https://b.com"},
]
results = engine._filter_for_relevance(previews, "test query")
# Duplicate indices are deduplicated while preserving order:
# [0, 0, 1] → results for indices 0 and 1 once each.
assert len(results) == 2
assert results[0]["title"] == "Result 0"
assert results[1]["title"] == "Result 1"