Rom89823974978's picture
Drafting some parts
8521f60
raw
history blame contribute delete
536 Bytes
"""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