Module: RubyLLM::Providers::Voyage::Reranking Private

Defined in:
lib/ruby_llm/providers/voyage/reranking.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Voyage reranking request and response mapping.

Instance Method Summary collapse

Instance Method Details

#rerank(query:, documents:, model:, top_k: nil, return_documents: RubyLLM::Voyage::UNSET, truncation: RubyLLM::Voyage::UNSET, provider_options: {}) ⇒ RubyLLM::Voyage::Reranking

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes a Voyage reranking request.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_llm/providers/voyage/reranking.rb', line 11

def rerank(query:, documents:, model:, top_k: nil, return_documents: RubyLLM::Voyage::UNSET,
           truncation: RubyLLM::Voyage::UNSET, provider_options: {})
  payload = {
    query: query,
    documents: documents,
    model: model,
    top_k: top_k,
    return_documents: return_documents,
    truncation: truncation
  }.reject { |_key, value| value.nil? || value.equal?(RubyLLM::Voyage::UNSET) }
   .merge(provider_options.transform_keys(&:to_sym))
  response = @connection.post('rerank', payload)
  parse_rerank_response(response)
end