Class: Phronomy::Embeddings::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/embeddings/base.rb

Overview

Abstract interface for embedding adapters.

Concrete implementations must override #embed and return a vector as an +Array+.

Direct Known Subclasses

RubyLLMEmbeddings

Instance Method Summary collapse

Instance Method Details

#embed(text, cancellation_token = nil) ⇒ Array<Float>

Embed the given text and return a vector representation.

Parameters:

  • text (String)

    the text to embed

  • cancellation_token (Phronomy::CancellationToken, nil) (defaults to: nil)

    optional; raises CancellationError when cancelled

Returns:

  • (Array<Float>)

    the embedding vector

Raises:

  • (NotImplementedError)


16
17
18
19
# File 'lib/phronomy/embeddings/base.rb', line 16

def embed(text, cancellation_token = nil)
  cancellation_token&.raise_if_cancelled!
  raise NotImplementedError, "#{self.class}#embed is not implemented"
end