embedding_base.py 699 B

1234567891011121314151617181920212223
  1. from abc import ABC, abstractmethod
  2. class Embeddings(ABC):
  3. """Interface for embedding models."""
  4. @abstractmethod
  5. def embed_documents(self, texts: list[str]) -> list[list[float]]:
  6. """Embed search docs."""
  7. raise NotImplementedError
  8. @abstractmethod
  9. def embed_query(self, text: str) -> list[float]:
  10. """Embed query text."""
  11. raise NotImplementedError
  12. async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
  13. """Asynchronous Embed search docs."""
  14. raise NotImplementedError
  15. async def aembed_query(self, text: str) -> list[float]:
  16. """Asynchronous Embed query text."""
  17. raise NotImplementedError