Class: RubyAmazonBedrock::PayloadBuilders::Meta::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/bedrock_runtime/payload_builders/meta/base.rb

Overview

Builds and returns a payload hash suitable for the Meta model processing. This method constructs a payload with specific parameters like model_id, content_type, accept, and a body that includes various AI-related settings.

Instance Method Summary collapse

Methods inherited from Base

#initialize, #type

Constructor Details

This class inherits a constructor from RubyAmazonBedrock::PayloadBuilders::Base

Instance Method Details

#buildHash

Constructs and returns a payload formatted for text generation requests. This method assembles the necessary data structure for processing text input through an AI model, with various parameters to guide the generation process.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bedrock_runtime/payload_builders/meta/base.rb', line 25

def build
  {
    model_id: model_id,
    content_type: 'application/json',
    accept: '*/*',
    body: {
      prompt: @prompt,
      max_gen_len: parameters[:max_gen_len],
      temperature: parameters[:temperature],
      top_p: parameters[:top_p]
    }.to_json
  }
end

#model_idObject



39
40
41
# File 'lib/bedrock_runtime/payload_builders/meta/base.rb', line 39

def model_id
  # noop
end

#parametersObject



43
44
45
46
47
48
49
# File 'lib/bedrock_runtime/payload_builders/meta/base.rb', line 43

def parameters
  {
    max_gen_len: @options[:max_tokens] || 512,
    temperature: @options[:temperature] || 0.5,
    top_p: @options[:top_p] || 0.9
  }
end