"""Abstract retriever interface.""" from __future__ import annotations from abc import ABC, abstractmethod from dataclasses import dataclass from typing import List @dataclass class Context: """A retrieved passage or document.""" id: str text: str score: float class Retriever(ABC): """Abstract base class for all retrievers.""" @abstractmethod def retrieve(self, query: str, *, top_k: int = 5) -> List[Context]: """Return the top‑k contexts for a query.""" raise NotImplementedError