Class: RubyAmazonBedrock::PayloadBuilders::Cohere::CommandBase
- Defined in:
- lib/bedrock_runtime/payload_builders/cohere/command_base.rb
Overview
Builds and returns a payload hash suitable for the Cohere command 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
Builds and returns a hash representing the payload for command generation requests.
- #model_id ⇒ Object
-
#parameters ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity.
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 for command generation requests. This method prepares the data necessary for processing a command input through a specified AI model. It configures several parameters to control the behavior and output of the model in response to the command.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bedrock_runtime/payload_builders/cohere/command_base.rb', line 26 def build { model_id: model_id, content_type: 'application/json', accept: '*/*', body: { prompt: "#{@prompt}:", temperature: parameters[:temperature], p: parameters[:p], k: parameters[:k], max_tokens: parameters[:max_tokens], num_generations: parameters[:num_generations], return_likelihoods: parameters[:return_likelihoods], stop_sequences: parameters[:stop_sequences], stream: parameters[:stream], truncate: parameters[:truncate] }.to_json } end |
#model_id ⇒ Object
46 47 48 |
# File 'lib/bedrock_runtime/payload_builders/cohere/command_base.rb', line 46 def model_id # noop end |
#parameters ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bedrock_runtime/payload_builders/cohere/command_base.rb', line 50 def parameters # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity { temperature: @options[:temperature] || 0.9, p: @options[:top_p] || 0.75, k: @options[:top_k] || 0, max_tokens: @options[:max_tokens] || 20, num_generations: @options[:num_generations] || 1, return_likelihoods: @options[:return_likelihoods] || 'GENERATION', stop_sequences: @options[:stop_sequences] || [], stream: @options[:stream] || false, # logit_bias: @options[:logit_bias] || {}, truncate: @options[:truncate] || 'NONE' } end |