7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
105 lines
3.7 KiB
Python
105 lines
3.7 KiB
Python
"""Regression tests: LibraryRAGSearchEngine must read its RAG settings
|
|
from the provided ``settings_snapshot``.
|
|
|
|
The constructor used to pass ``(key, settings_snapshot, default)``
|
|
positionally into ``get_setting_from_snapshot(key, default, username,
|
|
settings_snapshot)``, so the snapshot landed in the ``default`` slot and
|
|
was never consulted: outside a thread settings context each setting
|
|
silently resolved to the snapshot DICT itself.
|
|
"""
|
|
|
|
from local_deep_research.web_search_engines.engines.search_engine_library import (
|
|
LibraryRAGSearchEngine,
|
|
)
|
|
|
|
|
|
def test_snapshot_values_are_honored():
|
|
snap = {
|
|
"_username": "tester",
|
|
"local_search_embedding_model": "custom-model",
|
|
"local_search_embedding_provider": "ollama",
|
|
"local_search_chunk_size": 512,
|
|
"local_search_chunk_overlap": 64,
|
|
}
|
|
eng = LibraryRAGSearchEngine(settings_snapshot=snap)
|
|
assert eng.embedding_model == "custom-model"
|
|
assert eng.embedding_provider == "ollama"
|
|
assert eng.chunk_size == 512
|
|
assert eng.chunk_overlap == 64
|
|
|
|
|
|
def test_defaults_used_when_keys_missing():
|
|
eng = LibraryRAGSearchEngine(settings_snapshot={"_username": "tester"})
|
|
assert eng.embedding_model == "all-MiniLM-L6-v2"
|
|
assert eng.embedding_provider == "sentence_transformers"
|
|
assert eng.chunk_size == 1000
|
|
assert eng.chunk_overlap == 200
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# search.rag.max_results — cap local RAG retrieval (vector search returns many
|
|
# near-duplicate chunks that otherwise flood the agent's context).
|
|
# search.rag.enable_relevance_filter — opt-in LLM relevance filter for RAG.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
def test_rag_max_results_caps_retrieval_when_set():
|
|
"""search.rag.max_results overrides the inherited (web) max_results so
|
|
local RAG search returns fewer chunks."""
|
|
eng = LibraryRAGSearchEngine(
|
|
max_results=50, # global web default
|
|
settings_snapshot={"_username": "tester", "search.rag.max_results": 15},
|
|
)
|
|
assert eng.max_results == 15
|
|
|
|
|
|
def test_rag_max_results_absent_preserves_caller_value():
|
|
"""An absent setting must NOT silently cap a caller's explicit
|
|
max_results; real web/CLI runs carry the shipped default of 20."""
|
|
eng = LibraryRAGSearchEngine(
|
|
max_results=42,
|
|
settings_snapshot={"_username": "tester"},
|
|
)
|
|
assert eng.max_results == 42
|
|
|
|
|
|
def test_rag_relevance_filter_on_by_default():
|
|
eng = LibraryRAGSearchEngine(settings_snapshot={"_username": "tester"})
|
|
assert eng.enable_llm_relevance_filter is True
|
|
|
|
|
|
def test_rag_relevance_filter_can_be_disabled():
|
|
eng = LibraryRAGSearchEngine(
|
|
settings_snapshot={
|
|
"_username": "tester",
|
|
"search.rag.enable_relevance_filter": False,
|
|
},
|
|
)
|
|
assert eng.enable_llm_relevance_filter is False
|
|
|
|
|
|
def test_collection_engine_inherits_rag_cap_and_filter():
|
|
"""CollectionSearchEngine (subclass) gets the cap + filter from the base
|
|
__init__, which runs before its DB-loading collection-settings step."""
|
|
from unittest.mock import patch
|
|
|
|
from local_deep_research.web_search_engines.engines.search_engine_collection import (
|
|
CollectionSearchEngine,
|
|
)
|
|
|
|
with patch.object(
|
|
CollectionSearchEngine, "_load_collection_embedding_settings"
|
|
):
|
|
eng = CollectionSearchEngine(
|
|
collection_id="abc",
|
|
collection_name="My Collection",
|
|
max_results=50,
|
|
settings_snapshot={
|
|
"_username": "tester",
|
|
"search.rag.max_results": 12,
|
|
"search.rag.enable_relevance_filter": False,
|
|
},
|
|
)
|
|
assert eng.max_results == 12
|
|
assert eng.enable_llm_relevance_filter is False
|