mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 13:16:24 +00:00
* feat(knowledge): unify read-only retrieval and source contracts * fix(knowledge): address citation and contract review feedback * fix(knowledge): resolve citations in delegated task reports * docs(frontend): keep agent guidance within CI size budget * docs(backend): preserve merged guidance chain headroom
30 lines
1.5 KiB
Python
30 lines
1.5 KiB
Python
"""Opt-in validation against real LightRAG /query/data evidence; no uploads."""
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from deerflow.community.lightrag.client import LightRAGClient
|
|
from deerflow.community.lightrag.formatting import normalize_retrieval_result
|
|
from deerflow.knowledge import format_result, sources_from_messages
|
|
|
|
|
|
@pytest.mark.live
|
|
@pytest.mark.anyio
|
|
async def test_lightrag_live_evidence_contract() -> None:
|
|
if os.getenv("DEER_FLOW_RUN_LIVE_TESTS") != "1":
|
|
pytest.skip("live knowledge checks are opt-in")
|
|
base_url, query = os.getenv("LIGHTRAG_BASE_URL"), os.getenv("LIGHTRAG_EVIDENCE_QUERY")
|
|
if not base_url or not query:
|
|
pytest.skip("set LIGHTRAG_BASE_URL and LIGHTRAG_EVIDENCE_QUERY for an indexed workspace")
|
|
result = await LightRAGClient(base_url=base_url, api_key=os.getenv("LIGHTRAG_API_KEY")).query_data(query, mode="mix", chunk_top_k=8)
|
|
normalized = normalize_retrieval_result(result)
|
|
assert any(hit.source for hit in normalized.hits), "Live query must retrieve attributable document text"
|
|
text, artifact = format_result(normalized)
|
|
sources = sources_from_messages([{"type": "tool", "content": text, "artifact": artifact}])
|
|
assert sources, "At least one real retrieved source must fit the default budget"
|
|
for source in sources:
|
|
assert any(hit.source and hit.source.title == source.title and source.excerpt.rstrip("…") in hit.content for hit in normalized.hits)
|
|
assert source.provider == "lightrag"
|
|
assert source.page is None # /query/data does not supply page evidence
|