Behaviour for embedding providers.
Implementations generate vector embeddings for text.
The host app configures which provider to use and provides
credentials via a :credentials_fn callback.
Summary
Callbacks
Number of dimensions in the embedding vectors.
Generate a single embedding for a text string.
Generate embeddings for a list of texts.
Identifier for the model that will produce embeddings under the
given opts. Used by the pipeline to record provenance alongside each
vector. Returns nil when the provider can't (or doesn't want to)
declare a stable id.
Functions
Generate embedding for a single text using the configured provider.
Generate embeddings for multiple texts using the configured provider.
Resolve the model id of the currently configured provider, or nil
if the provider doesn't implement model_id/1.
Callbacks
@callback dimensions(opts :: keyword()) :: pos_integer()
Number of dimensions in the embedding vectors.
Generate a single embedding for a text string.
Convenience wrapper — delegates to generate/2 by default.
@callback generate(texts :: [String.t()], opts :: keyword()) :: {:ok, [[float()]]} | {:error, term()}
Generate embeddings for a list of texts.
Returns {:ok, [[float()]]} where each inner list is a vector,
or {:error, reason}.
Identifier for the model that will produce embeddings under the
given opts. Used by the pipeline to record provenance alongside each
vector. Returns nil when the provider can't (or doesn't want to)
declare a stable id.
Functions
Generate embedding for a single text using the configured provider.
Generate embeddings for multiple texts using the configured provider.
Resolve the model id of the currently configured provider, or nil
if the provider doesn't implement model_id/1.