Class: VoyageAI::Rerank

Inherits:
Object
  • Object
show all
Defined in:
lib/voyageai/rerank.rb

Overview

The response for an rerank request that wraps the model / usage / results.

Examples:

VoyageAI::Rerank.new(model: "rerank-2", usage: VoyageAI::Usage.new(total_tokens: 0), results: [])

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, usage:, results:) ⇒ Rerank

Returns a new instance of Rerank.

Parameters:



35
36
37
38
39
# File 'lib/voyageai/rerank.rb', line 35

def initialize(model:, usage:, results:)
  @model = model
  @usage = usage
  @results = results
end

Instance Attribute Details

#modelString

Returns:

  • (String)


11
12
13
# File 'lib/voyageai/rerank.rb', line 11

def model
  @model
end

#rerankingArray<Array<Float>>

Returns:

  • (Array<Array<Float>>)


19
# File 'lib/voyageai/rerank.rb', line 19

attr_accessor :results

#resultsObject

Returns the value of attribute results.



19
20
21
# File 'lib/voyageai/rerank.rb', line 19

def results
  @results
end

#usageUsage

Returns:



15
16
17
# File 'lib/voyageai/rerank.rb', line 15

def usage
  @usage
end

Class Method Details

.parse(data:) ⇒ Embed

Parameters:

  • data (Hash)

Returns:



23
24
25
26
27
28
29
30
# File 'lib/voyageai/rerank.rb', line 23

def self.parse(data:)
  model = data["model"]
  usage = Usage.parse(data: data["usage"])

  results = data["data"].map { |entry| Reranking.parse(data: entry) }

  new(model:, usage:, results:)
end

Instance Method Details

#inspectString

Returns:

  • (String)


42
43
44
# File 'lib/voyageai/rerank.rb', line 42

def inspect
  "#<#{self.class.name} model=#{@model.inspect} usage=#{@usage.inspect}>"
end