Class: RubyAmazonBedrock::PayloadBuilders::Base

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

Overview

Base class serves as an abstract class for payload builders. It provides the basic structure and enforces the implementation of certain methods in derived classes.

Instance Method Summary collapse

Constructor Details

#initialize(prompt, options = {}) ⇒ Base

Initializes a new instance of the Base class.

Parameters:

  • input (String)

    The input string for what needs to be generated.

  • options (Hash) (defaults to: {})

    optional parameters to customize payload building.

Options Hash (options):

  • :key (Any)

    Custom option key-value pairs.



13
14
15
16
# File 'lib/bedrock_runtime/payload_builders/base.rb', line 13

def initialize(prompt, options = {})
  @prompt = prompt
  @options = options
end

Instance Method Details

#buildHash

Abstract method to build the payload.

Returns:

  • (Hash)

    the constructed payload.

Raises:

  • (NotImplementedError)

    if the subclass does not implement this method.



21
22
23
# File 'lib/bedrock_runtime/payload_builders/base.rb', line 21

def build
  raise NotImplementedError
end

#model_idString

Abstract method to retrieve the model ID.

Returns:

  • (String)

    the Amazon Bedrock model ID.

Raises:

  • (NotImplementedError)

    if the subclass does not implement this method.



28
29
30
# File 'lib/bedrock_runtime/payload_builders/base.rb', line 28

def model_id
  raise NotImplementedError
end

#parametersHash

Abstract method to set the model parameters to be sent in the request.

Returns:

  • (Hash)

    the Amazon Bedrock model configuration parameters.

Raises:

  • (NotImplementedError)

    if the subclass does not implement this method.



35
36
37
# File 'lib/bedrock_runtime/payload_builders/base.rb', line 35

def parameters
  raise NotImplementedError
end

#typeSymbol

Abstract method to retrieve the model type.

Returns:

  • (Symbol)

    the model result type: :text (default) or :image.



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

def type
  :text
end