generated from coulomb/repo-seed
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>
35 lines
962 B
Python
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.
|
|
"""
|