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.

2.3 KB
Raw Blame
"""Start the disposable authenticated API target used only by ZAP CI."""

import json
import os
from pathlib import Path


def fixture_summary(query, **kwargs):
    return {"summary": "CI research fixture", "findings": []}


def fixture_report(query, **kwargs):
    return {"content": "CI research report", "metadata": {}}


def fixture_documents(query, collection_name, **kwargs):
    return {"summary": "CI document fixture", "documents": []}


def main():
    if (
        os.environ.get("GITHUB_ACTIONS") != "true"
        or os.environ.get("LDR_TEST_MODE") != "1"
    ):
        raise SystemExit(
            "This fixture target may only run in test-mode GitHub Actions"
        )
    from init_test_database import main as init_database
    from seed_history_delete import main as seed_history
    from zap_api_hooks import build_spec
    from zap_api_diagnostics import DiagnosticLogger, FixtureDiagnostics

    init_database()
    seed_history()

    import uvicorn
    from local_deep_research.api import research_functions
    from local_deep_research.web.fastapi_app import app
    from local_deep_research.web.routers import api_v1
    from local_deep_research.web.routers import settings as settings_router
    from local_deep_research.settings import manager as settings_manager
    from local_deep_research.web.services import settings_service

    diagnostics = FixtureDiagnostics(Path("zap-api-diagnostics.json"))
    for source, module in (
        ("settings_router", settings_router),
        ("settings_manager", settings_manager),
        ("settings_service", settings_service),
    ):
        module.logger = DiagnosticLogger(module.logger, diagnostics, source)

    # Keep the real routing, authentication, CSRF, validation, settings and
    # encrypted DB paths. Replace only research-provider work so active scan
    # payloads cannot invoke paid LLMs or external search services.
    research_functions.quick_summary = fixture_summary
    research_functions.generate_report = fixture_report
    api_v1.analyze_documents = fixture_documents
    Path("zap-openapi.json").write_text(
        json.dumps(build_spec(app.openapi()), indent=2) + "\n", encoding="utf-8"
    )
    # Mirror the production launcher's WebSocket message cap (web/app.py).
    uvicorn.run(app, host="127.0.0.1", port=5000, ws_max_size=65536)


if __name__ == "__main__":
    main()