Class: RubyAmazonBedrock::PayloadBuilders::Amazon::Base

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

Overview

Builds and returns a payload hash suitable for the Amazon 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.

Direct Known Subclasses

TitanTextExpressV1, TitanTextLiteV1

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

Builds and returns a hash representing the payload for a text generation request. This method prepares the necessary data structure for processing an input text through a specified model. It includes various configuration parameters for text generation.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bedrock_runtime/payload_builders/amazon/base.rb', line 28

def build
  {
    model_id: model_id,
    content_type: 'application/json',
    accept: '*/*',
    body: {
      inputText: @prompt,
      textGenerationConfig: parameters
    }.to_json
  }
end

#model_idObject



40
41
42
# File 'lib/bedrock_runtime/payload_builders/amazon/base.rb', line 40

def model_id
  # noop
end

#parametersObject



44
45
46
47
48
49
50
51
# File 'lib/bedrock_runtime/payload_builders/amazon/base.rb', line 44

def parameters
  {
    maxTokenCount: @options[:max_tokens] || 4096,
    stopSequences: @options[:stop_sequences] || [],
    temperature: @options[:temperature] || 0,
    topP: @options[:top_p] || 1
  }
end