DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
test(lightrag): exercise stable VLM pipeline
NoxsMediaa99ef5fef229
diff --git a/tests/services/rag/test_lightrag_native_smoke.py b/tests/services/rag/test_lightrag_native_smoke.pyindex 12c315216..9193fcc00 100644--- a/tests/services/rag/test_lightrag_native_smoke.py+++ b/tests/services/rag/test_lightrag_native_smoke.py@@ -3,8 +3,10 @@from __future__ import annotationsimport asyncio-from dataclasses import replace+import base64+import jsonfrom pathlib import Path+from types import SimpleNamespaceimport numpy as npimport pytest@@ -27,7 +29,7 @@ async def _fake_embedding(texts: list[str]) -> np.ndarray:return np.ones((len(texts), 32), dtype=float)-def _configure_real_sdk(monkeypatch, llm=_fake_llm) -> None:+def _configure_real_sdk(monkeypatch, llm=_fake_llm, vision=None) -> None:monkeypatch.setattr(engine, "build_llm_model_func", lambda **_kwargs: llm)monkeypatch.setattr(engine,@@ -44,10 +46,22 @@ def _configure_real_sdk(monkeypatch, llm=_fake_llm) -> None:monkeypatch.setattr(engine, "constructor_kwargs_from_settings", lambda: {"entity_extract_max_gleaning": 0})---async def _process(working_dir: Path, staged: ingress.StagedDocument) -> dict:- rag = engine.build_rag(working_dir, enable_vlm=False)+ if vision is not None:+ monkeypatch.setattr(engine, "build_vision_model_func", lambda **_kwargs: vision)+++async def _process(+ working_dir: Path,+ staged: ingress.StagedDocument,+ *,+ enable_vlm: bool = False,+ indexing_snapshot=None,+) -> dict:+ rag = engine.build_rag(+ working_dir,+ enable_vlm=enable_vlm,+ indexing_snapshot=indexing_snapshot,+ )await engine.initialize(rag)failed = Truetry:@@ -96,7 +110,13 @@ def test_real_stable_raw_bridge_reaches_processed(monkeypatch, tmp_path: Path) -def test_real_stable_sidecar_bridge_reaches_processed(monkeypatch, tmp_path: Path) -> None:- _configure_real_sdk(monkeypatch)+ vision_calls: list[tuple[str, dict]] = []++ async def fake_vision(prompt, **kwargs) -> str:+ vision_calls.append((prompt, kwargs))+ return '{"name":"fixture image","description":"synthetic fixture","type":"Other"}'++ _configure_real_sdk(monkeypatch, vision=fake_vision)working = tmp_path / "version-1"working.mkdir()source = tmp_path / "paper.pdf"@@ -126,11 +146,20 @@ def test_real_stable_sidecar_bridge_reaches_processed(monkeypatch, tmp_path: Patparser_signature="fixture-parser",),)- # The image asset still passes through the real Sidecar writer; disabling- # i only avoids requiring a vision call in this deterministic offline test.- staged = replace(staged, process_options=staged.process_options.replace("i", ""))-- rows = asyncio.run(_process(working, staged))+ snapshot = SimpleNamespace(+ config=SimpleNamespace(binding="offline"),+ owner=object(),+ descriptor={"endpoint": "offline://fixture"},+ fingerprint="fixture-indexing-model",+ )+ rows = asyncio.run(+ _process(+ working,+ staged,+ enable_vlm=True,+ indexing_snapshot=snapshot,+ )+ )assert len(rows) == 1row = next(iter(rows.values()))@@ -138,6 +167,21 @@ def test_real_stable_sidecar_bridge_reaches_processed(monkeypatch, tmp_path: Patassert row.file_path == "paper.pdf"assert storage.has_output(working) is Trueassert list((ingress.pending_root(working) / "__parsed__").glob("paper.pdf"))+ drawings_path = next(+ (ingress.pending_root(working) / "__parsed__").glob("paper.pdf.parsed/*.drawings.json")+ )+ drawings = json.loads(drawings_path.read_text(encoding="utf-8"))["drawings"]+ assert [item["llm_analyze_result"]["status"] for item in drawings.values()] == ["success"]+ assert len(vision_calls) == 1+ prompt, kwargs = vision_calls[0]+ assert prompt.startswith("You are an expert image analyzer.")+ assert kwargs["stream"] is False+ assert kwargs["response_format"] == {"type": "json_object"}+ assert len(kwargs["image_inputs"]) == 1+ image = kwargs["image_inputs"][0]+ assert base64.b64decode(image["base64"]) == b"fixture image"+ assert image["mime_type"] == "image/png"+ assert image["modality"] == "image"def test_real_stable_append_uses_only_new_doc_and_links_existing_entity(