Module: RubyLLM::Providers::Voyage::ContextualizedEmbeddings Private

Defined in:
lib/ruby_llm/providers/voyage/contextualized_embeddings.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 contextualized chunk embedding mapping.

Instance Method Summary collapse

Instance Method Details

#contextualized_embed(inputs, model:, input_type: RubyLLM::Voyage::UNSET, dimensions: nil, output_dtype: RubyLLM::Voyage::UNSET, encoding_format: RubyLLM::Voyage::UNSET, auto_chunk: nil, chunk_size: nil, chunk_overlap: nil, provider_options: {}) ⇒ RubyLLM::Voyage::ContextualizedEmbedding

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 contextualized chunk embedding request.



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

def contextualized_embed(inputs, model:, input_type: RubyLLM::Voyage::UNSET, dimensions: nil,
                         output_dtype: RubyLLM::Voyage::UNSET,
                         encoding_format: RubyLLM::Voyage::UNSET, auto_chunk: nil, chunk_size: nil,
                         chunk_overlap: nil, provider_options: {})
  payload = {
    inputs: inputs,
    model: model,
    input_type: contextualized_option(input_type, :voyage_default_input_type),
    output_dimension: dimensions || @config.voyage_default_output_dimension,
    output_dtype: contextualized_option(output_dtype, :voyage_default_output_dtype),
    encoding_format: contextualized_option(encoding_format, :voyage_default_encoding_format),
    enable_auto_chunking: auto_chunk,
    chunk_size: chunk_size,
    chunk_overlap: chunk_overlap
  }.compact.merge(provider_options.transform_keys(&:to_sym))
  response = @connection.post('contextualizedembeddings', payload)
  parse_contextualized_response(response, output_dtype: payload[:output_dtype])
end