feat(evidence): evaluate retrieval with a small fixture
This commit is contained in:
@@ -132,6 +132,7 @@ class QdrantVectorStore:
|
||||
metadata_filter: dict[str, object] | None = None,
|
||||
query_text: str | None = None,
|
||||
query_language: str | None = None,
|
||||
retrieval_mode: str = "fused",
|
||||
) -> list[VectorHit]:
|
||||
require_positive_limit(limit)
|
||||
self._validate_embedding(embedding, query=True)
|
||||
@@ -185,7 +186,40 @@ class QdrantVectorStore:
|
||||
if not isinstance(values, list) or not all(isinstance(item, str) for item in values):
|
||||
raise VectorStoreError("Invalid vector metadata filter")
|
||||
filter_must.extend({"key": payload_key, "match": {"value": item}} for item in values)
|
||||
if query_text is None:
|
||||
if retrieval_mode not in {"fused", "dense", "bm25"}:
|
||||
raise VectorStoreError("Evidence retrieval mode is invalid")
|
||||
if retrieval_mode == "dense":
|
||||
if allowed_record_kinds != ["evidence"]:
|
||||
raise VectorStoreError("Evidence branch diagnostics are only available for Evidence")
|
||||
response = self._call(
|
||||
"POST",
|
||||
f"/collections/{self._collection}/points/query",
|
||||
{
|
||||
"vector": embedding,
|
||||
"limit": limit,
|
||||
"with_payload": True,
|
||||
"filter": {"must": filter_must},
|
||||
},
|
||||
)
|
||||
elif retrieval_mode == "bm25":
|
||||
if allowed_record_kinds != ["evidence"]:
|
||||
raise VectorStoreError("Evidence branch diagnostics are only available for Evidence")
|
||||
if query_text is None or query_text.strip() == "" or query_language not in _BM25_LANGUAGES:
|
||||
raise VectorStoreError("Evidence BM25 query is invalid")
|
||||
self._ensure_collection(strict=False, require_bm25=True)
|
||||
shared_filter = {"must": filter_must}
|
||||
response = self._call(
|
||||
"POST",
|
||||
f"/collections/{self._collection}/points/query",
|
||||
{
|
||||
"query": self._bm25_document(query_text, query_language),
|
||||
"using": "bm25",
|
||||
"limit": limit,
|
||||
"with_payload": True,
|
||||
"filter": shared_filter,
|
||||
},
|
||||
)
|
||||
elif query_text is None:
|
||||
if allowed_record_kinds == ["evidence"]:
|
||||
raise VectorStoreError("Evidence hybrid query text is required")
|
||||
response = self._call(
|
||||
|
||||
Reference in New Issue
Block a user