Class: RubyLLM::Protocols::InvokeModel::TitanMultimodalEmbeddings

Inherits:
InvokeModel
  • Object
show all
Defined in:
lib/ruby_llm/protocols/invoke_model/titan_multimodal_embeddings.rb

Overview

Amazon Titan multimodal embedding models over Bedrock InvokeModel.

Instance Method Summary collapse

Instance Method Details

#embed(text, model:, dimensions:, task_type: nil, title: nil, with: nil, provider_options: {}) ⇒ Object

rubocop:disable-next Lint/UnusedMethodArgument



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_llm/protocols/invoke_model/titan_multimodal_embeddings.rb', line 9

def embed(text, model:, dimensions:, task_type: nil, title: nil, with: nil, provider_options: {})
  ensure_no_embedding_media!(with)
  track_usage(:embedding) do
    responses = [text].flatten.map do |value|
      payload = render_embedding_payload(value, dimensions:, provider_options:)
      signed_post(embedding_url(model:), payload).tap { |response| record_embedding_attempt(response) }
    end

    parse_single_embedding_responses(responses, model:, text:)
  end
end