You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.0 KiB
Python

# backend/tests/test_rag_qa.py
def test_ask_stroller_grounded(client):
r = client.post(
"/api/research/ask",
json={"q": "유모차, 신생아 때부터 쓰려면 뭘 봐야 하지?", "collection_id": "stroller"},
).json()
assert r["grounded"] is True
parts = {ref["part"] for ref in r["refs"]}
assert "‘인증·벨트’ 단락" in parts and "휴대성 비교 표" in parts
assert "풀플랫" in r["a"] and "KC 인증" in r["a"]
def test_ask_no_grounding(client):
r = client.post("/api/research/ask", json={"q": "양자컴퓨터 큐비트 오류율 최신 동향은?"}).json()
assert r["grounded"] is False and r["refs"] == []
def test_rag_query_heuristic_returns_chunks(client, session):
# heuristic 임베딩 폴백에서도 관련 청크가 코사인>0 으로 검색됨(결정적)
from app.rag.pipeline import query as rag_query
s, _ = session
hits = rag_query(s, "반도체 메모리 대역폭", k=4, collection_id="chip")
assert hits and hits[0]["score"] > 0