Class: ActiveRecordVector::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_vector/providers/base.rb

Overview

Abstract base class for embedding providers.

Direct Known Subclasses

Cohere, Custom, Ollama, Openai

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



9
10
11
# File 'lib/active_record_vector/providers/base.rb', line 9

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/active_record_vector/providers/base.rb', line 7

def options
  @options
end

Instance Method Details

#embed(_text) ⇒ Object

Generate embedding vector array for input text string

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/active_record_vector/providers/base.rb', line 14

def embed(_text)
  raise NotImplementedError, "#{self.class.name}#embed must be implemented"
end

#embed_batch(texts) ⇒ Object

Generate batch embedding vector arrays for array of text strings



19
20
21
# File 'lib/active_record_vector/providers/base.rb', line 19

def embed_batch(texts)
  texts.map { |text| embed(text) }
end