feat(evidence): evaluate retrieval with a small fixture
This commit is contained in:
@@ -7,7 +7,7 @@ import json
|
||||
import logging
|
||||
import re
|
||||
import uuid
|
||||
from collections.abc import Mapping, Sequence
|
||||
from collections.abc import Callable, Mapping, Sequence
|
||||
from dataclasses import asdict, dataclass, field
|
||||
from datetime import UTC
|
||||
from pathlib import Path
|
||||
@@ -127,6 +127,7 @@ class CorpusPipeline:
|
||||
vector_store: VectorStore, embedding_model: str, embedding_dimensions: int,
|
||||
chunk_policy: ChunkPolicy, pipeline_version: str, retain_published_generations: int = 3,
|
||||
workspace_id: str | None = None, sparse_language: str = "italian",
|
||||
candidate_evaluator: Callable[[CorpusManifest], object] | None = None,
|
||||
) -> None:
|
||||
self.store = store
|
||||
self.sources = sources
|
||||
@@ -143,6 +144,14 @@ class CorpusPipeline:
|
||||
if sparse_language not in {"english", "italian"}:
|
||||
raise ValueError("unsupported Qdrant BM25 language")
|
||||
self.sparse_language = sparse_language
|
||||
self.candidate_evaluator = candidate_evaluator
|
||||
|
||||
def _evaluate_candidate(self, manifest: CorpusManifest) -> None:
|
||||
if self.candidate_evaluator is None:
|
||||
return
|
||||
report = self.candidate_evaluator(manifest)
|
||||
if getattr(report, "passed", False) is not True:
|
||||
raise PipelineError("candidate retrieval evaluation failed")
|
||||
|
||||
def _assert_workspace_binding(self) -> None:
|
||||
manifest = self.store.active_manifest()
|
||||
@@ -658,6 +667,7 @@ class CorpusPipeline:
|
||||
raise
|
||||
generation = read(context, "plan.json")["generation"]
|
||||
try:
|
||||
self._evaluate_candidate(CorpusManifest.model_validate(read(context, "manifest.json")))
|
||||
self.store.publish(generation)
|
||||
except Exception:
|
||||
compensate(context)
|
||||
@@ -791,6 +801,7 @@ class CorpusPipeline:
|
||||
manifest, {document.document_id: document.content for document in documents},
|
||||
generation=generation,
|
||||
)
|
||||
self._evaluate_candidate(manifest)
|
||||
self.store.publish(staged)
|
||||
self.gc(workspace_root=self.store.root.parent)
|
||||
except AtomicContentTooLargeError as error:
|
||||
|
||||
Reference in New Issue
Block a user