Class: RubyAmazonBedrock::PayloadBuilders::Ai21Labs::Base
- Defined in:
- lib/bedrock_runtime/payload_builders/ai_21_labs/base.rb
Overview
Builds and returns a payload hash suitable for the AI21Labs 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
-
#build ⇒ Hash
Builds and returns a hash representing the payload.
- #model_id ⇒ Object
-
#parameters ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Methods inherited from Base
Constructor Details
This class inherits a constructor from RubyAmazonBedrock::PayloadBuilders::Base
Instance Method Details
#build ⇒ Hash
Builds and returns a hash representing the payload. The method prepares the data necessary for processing by an unspecified model. This includes setting various parameters such as content type, model id, and specific attributes related to the prompt and its processing characteristics.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bedrock_runtime/payload_builders/ai_21_labs/base.rb', line 31 def build { model_id: model_id, content_type: 'application/json', accept: '*/*', body: { prompt: @prompt, maxTokens: parameters[:maxTokens], temperature: parameters[:temperature], topP: parameters[:topP], stopSequences: parameters[:stopSequences], countPenalty: { scale: parameters[:countPenalty] }, presencePenalty: { scale: parameters[:presencePenalty] }, frequencyPenalty: { scale: parameters[:frequencyPenalty] } }.to_json } end |
#model_id ⇒ Object
49 50 51 |
# File 'lib/bedrock_runtime/payload_builders/ai_21_labs/base.rb', line 49 def model_id # noop end |
#parameters ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bedrock_runtime/payload_builders/ai_21_labs/base.rb', line 53 def parameters # rubocop:disable Metrics/CyclomaticComplexity { maxTokens: @options[:max_tokens] || 200, stopSequences: @options[:stop_sequences] || [], temperature: @options[:temperature] || 0, topP: @options[:top_p] || 1, countPenalty: @options[:count_penalty] || 0, presencePenalty: @options[:presence_penalty] || 0, frequencyPenalty: @options[:frequency_penalty] || 0 } end |