~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
test(llm): cover canned retriever pipeline offline (#5083)
LearningCircuit37b210190e66
diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.ymlindex a3b4ebd673..845a40b018 100644--- a/.github/workflows/docker-tests.yml+++ b/.github/workflows/docker-tests.yml@@ -62,6 +62,12 @@ jobs:- 'src/local_deep_research/llm/**'- 'src/local_deep_research/config/llm_config.py'- 'src/local_deep_research/api/research_functions.py'+ - 'src/local_deep_research/search_system.py'+ - 'src/local_deep_research/search_system_factory.py'+ - 'src/local_deep_research/advanced_search_system/**'+ - 'src/local_deep_research/web_search_engines/retriever_registry.py'+ - 'src/local_deep_research/web_search_engines/search_engine_factory.py'+ - 'src/local_deep_research/web_search_engines/engines/search_engine_retriever.py'- 'tests/test_llm/**'- 'examples/**'- '.github/workflows/docker-tests.yml'@@ -1056,6 +1062,16 @@ jobs:${{ env.TEST_IMAGE }} \sh -c "python -m pytest tests/test_llm/test_api_llm_integration.py -v -n auto"+ - name: Run mock LLM pipeline test+ run: |+ docker run --rm \+ --network none \+ -v "$PWD":/app \+ -e PYTHONPATH=/app \+ -w /app \+ ${{ env.TEST_IMAGE }} \+ sh -c "timeout 60s python -m pytest tests/test_llm/test_mock_llm_pipeline.py -v"+- name: Run LLM edge case testsrun: |docker run --rm \diff --git a/tests/test_llm/test_mock_llm_pipeline.py b/tests/test_llm/test_mock_llm_pipeline.pynew file mode 100644index 0000000000..6d700d9f33--- /dev/null+++ b/tests/test_llm/test_mock_llm_pipeline.py@@ -0,0 +1,117 @@+from collections.abc import Iterator+from typing import Any, Final, override++import pytest+from langchain_core.callbacks.manager import (+ CallbackManagerForLLMRun,+ CallbackManagerForRetrieverRun,+)+from langchain_core.documents import Document+from langchain_core.language_models import BaseChatModel+from langchain_core.messages import AIMessage, BaseMessage+from langchain_core.outputs import ChatGeneration, ChatResult+from langchain_core.retrievers import BaseRetriever+from pydantic import Field++from local_deep_research.api import quick_summary+from local_deep_research.llm import unregister_llm+from local_deep_research.web_search_engines.retriever_registry import (+ retriever_registry,+)+++LLM_PROVIDER: Final[str] = "offline-pipeline-llm"+RETRIEVER_NAME: Final[str] = "offline-pipeline-retriever"+RETRIEVED_DOCUMENT_MARKER: Final[str] = "CANNED_RETRIEVED_DOCUMENT_MARKER"+FIXED_SYNTHESIS: Final[str] = "Deterministic canned synthesis."+++class CannedRetriever(BaseRetriever):+ @override+ def _get_relevant_documents(+ self,+ query: str,+ *,+ run_manager: CallbackManagerForRetrieverRun | None = None,+ ) -> list[Document]:+ return [+ Document(+ page_content=RETRIEVED_DOCUMENT_MARKER,+ metadata={+ "source": "offline://canned-retriever",+ "title": "Canned Retriever Document",+ },+ )+ ]+++class RecordingChatModel(BaseChatModel):+ received_messages: list[list[BaseMessage]] = Field(default_factory=list)++ @property+ @override+ def _llm_type(self) -> str:+ return "recording-test-chat-model"++ @override+ def _generate(+ self,+ messages: list[BaseMessage],+ stop: list[str] | None = None,+ run_manager: CallbackManagerForLLMRun | None = None,+ **kwargs: Any,+ ) -> ChatResult:+ self.received_messages.append(list(messages))+ return ChatResult(+ generations=[+ ChatGeneration(message=AIMessage(content=FIXED_SYNTHESIS))+ ]+ )++[email protected](autouse=True)+def clear_pipeline_registries() -> Iterator[None]:+ unregister_llm(LLM_PROVIDER)+ retriever_registry.unregister(RETRIEVER_NAME)+ yield+ unregister_llm(LLM_PROVIDER)+ retriever_registry.unregister(RETRIEVER_NAME)+++def offline_settings_snapshot() -> dict[str, dict[str, str | int]]:+ return {+ "llm.provider": {"value": LLM_PROVIDER, "ui_element": "text"},+ "search.tool": {"value": RETRIEVER_NAME, "ui_element": "text"},+ "search.iterations": {"value": 1, "ui_element": "number"},+ "search.questions_per_iteration": {+ "value": 1,+ "ui_element": "number",+ },+ }+++def test_quick_summary_synthesizes_canned_retriever_content_offline(+ offline_settings_snapshot: dict[str, dict[str, str | int]],+) -> None:+ # Given: registered in-process LangChain components and a local-only snapshot.+ chat_model = RecordingChatModel()++ # When: the public API initializes and executes its real quick-summary pipeline.+ result = quick_summary(+ query="Which canned document is available?",+ research_id="offline-pipeline-characterization",+ retrievers={RETRIEVER_NAME: CannedRetriever()},+ llms={LLM_PROVIDER: chat_model},+ provider=LLM_PROVIDER,+ search_tool=RETRIEVER_NAME,+ settings_snapshot=offline_settings_snapshot,+ )++ # Then: the configured model receives retriever content and returns its synthesis.+ assert any(+ RETRIEVED_DOCUMENT_MARKER in str(message.content)+ for messages in chat_model.received_messages+ for message in messages+ )+ assert result["summary"] == FIXED_SYNTHESIS