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