Class: Phronomy::Embeddings::RubyLLMEmbeddings
- Defined in:
- lib/phronomy/embeddings/ruby_llm_embeddings.rb
Overview
Embeddings adapter backed by RubyLLM.
Delegates to +RubyLLM.embed+ and returns the resulting vector as an
+Array
Instance Method Summary collapse
-
#embed(text) ⇒ Array<Float>
Embed text via RubyLLM.
-
#initialize(model: nil, provider: nil, assume_model_exists: false) ⇒ RubyLLMEmbeddings
constructor
A new instance of RubyLLMEmbeddings.
Constructor Details
#initialize(model: nil, provider: nil, assume_model_exists: false) ⇒ RubyLLMEmbeddings
Returns a new instance of RubyLLMEmbeddings.
22 23 24 25 26 |
# File 'lib/phronomy/embeddings/ruby_llm_embeddings.rb', line 22 def initialize(model: nil, provider: nil, assume_model_exists: false) @model = model @provider = provider @assume_model_exists = assume_model_exists end |
Instance Method Details
#embed(text) ⇒ Array<Float>
Embed text via RubyLLM.
32 33 34 35 36 37 38 |
# File 'lib/phronomy/embeddings/ruby_llm_embeddings.rb', line 32 def (text) opts = {} opts[:model] = @model if @model opts[:provider] = @provider if @provider opts[:assume_model_exists] = true if @assume_model_exists RubyLLM.(text, **opts).vectors end |