Files
llm-connect/llm_connect/embedding_adapter.py
tegwick e499edba90 feat: initial llm-connect package scaffold
Copy markitect.llm module into standalone llm_connect package.
All markitect.* imports replaced with llm_connect.* equivalents.
LLMError base class inlined (no markitect.exceptions dependency).
Verified: from llm_connect import create_adapter works.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 07:54:42 +01:00

35 lines
962 B
Python

"""
Abstract base class for embedding adapters.
Embedding adapters convert text into float vectors. This is a separate
hierarchy from :class:`LLMAdapter` (text generation) because the API
contract is fundamentally different: text in, float vectors out.
"""
from abc import ABC, abstractmethod
class EmbeddingAdapter(ABC):
"""Base class for all embedding adapters."""
@abstractmethod
def embed(self, texts: list[str]) -> list[list[float]]:
"""Embed a batch of texts into vectors.
Args:
texts: One or more strings to embed.
Returns:
A list of embedding vectors, one per input text,
in the same order as *texts*.
"""
@abstractmethod
def validate(self) -> bool:
"""Check that the adapter is configured correctly.
Returns:
``True`` if the adapter has a valid configuration
(e.g. API key present), ``False`` otherwise.
"""