Class: VoyageAI::Reranking

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

Overview

The response of an individual re-ranking.

Examples:

VoyageAI::Reranking.new(index: 0, document: "Sample", relevance_score: 0.0)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, document:, relevance_score:) ⇒ Reranking

Returns a new instance of Reranking.

Parameters:

  • index (Integer)
  • document (String)
  • relevance_score (Float)


24
25
26
27
28
# File 'lib/voyageai/reranking.rb', line 24

def initialize(index:, document:, relevance_score:)
  @index = index
  @document = document
  @relevance_score = relevance_score
end

Instance Attribute Details

#documentString

Returns:

  • (String)


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

def document
  @document
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#modelInteger

Returns:

  • (Integer)


11
# File 'lib/voyageai/reranking.rb', line 11

attr_accessor :index

#relevance_scoreFloat

Returns:

  • (Float)


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

def relevance_score
  @relevance_score
end

Class Method Details

.parse(data:) ⇒ Reranking

Parameters:

  • data (Hash)

Returns:



38
39
40
41
42
43
44
# File 'lib/voyageai/reranking.rb', line 38

def self.parse(data:)
  index = data["index"]
  document = data["document"]
  relevance_score = data["relevance_score"]

  new(index: index, document: document, relevance_score: relevance_score)
end

Instance Method Details

#inspectString

Returns:

  • (String)


31
32
33
# File 'lib/voyageai/reranking.rb', line 31

def inspect
  "#<#{self.class.name} index=#{@index} relevance_score=#{@relevance_score}>"
end