Class: VoyageAI::Embed
- Inherits:
-
Object
- Object
- VoyageAI::Embed
- Defined in:
- lib/voyageai/embed.rb
Overview
The response for an embeddings request that wraps the model / usage / embeddings.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #embedding(index: 0) ⇒ Array<Float>
-
#initialize(model:, usage:, embeddings:) ⇒ Embed
constructor
A new instance of Embed.
- #inspect ⇒ String
Constructor Details
#initialize(model:, usage:, embeddings:) ⇒ Embed
Returns a new instance of Embed.
34 35 36 37 38 |
# File 'lib/voyageai/embed.rb', line 34 def initialize(model:, usage:, embeddings:) @model = model @usage = usage = end |
Instance Attribute Details
#embeddings ⇒ Array<Array<Float>>
19 20 21 |
# File 'lib/voyageai/embed.rb', line 19 def end |
#model ⇒ String
11 12 13 |
# File 'lib/voyageai/embed.rb', line 11 def model @model end |
Class Method Details
.parse(data:) ⇒ Embed
23 24 25 26 27 28 29 |
# File 'lib/voyageai/embed.rb', line 23 def self.parse(data:) model = data["model"] usage = Usage.parse(data: data["usage"]) = data["data"].map { || ["embedding"] } new(model: model, usage: usage, embeddings: ) end |
Instance Method Details
#embedding(index: 0) ⇒ Array<Float>
48 49 50 |
# File 'lib/voyageai/embed.rb', line 48 def (index: 0) [index] end |
#inspect ⇒ String
41 42 43 |
# File 'lib/voyageai/embed.rb', line 41 def inspect "#<#{self.class.name} model=#{@model.inspect} embeddings=#{@embeddings.inspect} usage=#{@usage.inspect}>" end |