Class: RubyAmazonBedrock::PayloadBuilders::Anthropic::Base
- Defined in:
- lib/bedrock_runtime/payload_builders/anthropic/base.rb
Overview
Builds and returns a payload hash suitable for the Anthropic 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
Instance Method Summary collapse
-
#build ⇒ Hash
Constructs and returns a payload hash for text generation requests.
- #model_id ⇒ Object
- #parameters ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from RubyAmazonBedrock::PayloadBuilders::Base
Instance Method Details
#build ⇒ Hash
Constructs and returns a payload hash for text generation requests. This method is designed to prepare a structured payload comprising various parameters that dictate how the input text should be processed by the models.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bedrock_runtime/payload_builders/anthropic/base.rb', line 30 def build { model_id: model_id, content_type: 'application/json', accept: '*/*', body: { prompt: "\n\nHuman: #{@prompt}\n\nAssistant:", max_tokens_to_sample: parameters[:max_tokens_to_sample], temperature: parameters[:temperature], top_k: parameters[:top_k], top_p: parameters[:top_p], stop_sequences: parameters[:stop_sequences], anthropic_version: 'bedrock-2023-05-31' }.to_json } end |
#model_id ⇒ Object
47 48 49 |
# File 'lib/bedrock_runtime/payload_builders/anthropic/base.rb', line 47 def model_id # noop end |
#parameters ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/bedrock_runtime/payload_builders/anthropic/base.rb', line 51 def parameters { max_tokens_to_sample: @options[:max_tokens] || 200, temperature: @options[:temperature] || 0.5, top_k: @options[:top_k] || 250, top_p: @options[:top_p] || 1, stop_sequences: @options[:stop_sequences] || ['\n\nHuman'] } end |