Class: Riffer::Providers::AmazonBedrock

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/providers/amazon_bedrock.rb

Instance Method Summary collapse

Methods inherited from Base

#generate_text, #stream_text

Methods included from Messages::Converter

#convert_to_message_object

Constructor Details

#initialize(api_token: nil, region: nil, **options) ⇒ AmazonBedrock

Initializes the Amazon Bedrock provider.

Parameters:

  • options (Hash)

    options passed to Aws::BedrockRuntime::Client

Options Hash (**options):

  • :api_token (String)

    Bearer token for API authentication (requires :region)

  • :region (String)

    AWS region

See Also:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/riffer/providers/amazon_bedrock.rb', line 12

def initialize(api_token: nil, region: nil, **options)
  depends_on "aws-sdk-bedrockruntime"

  api_token ||= Riffer.config.amazon_bedrock.api_token
  region ||= Riffer.config.amazon_bedrock.region

  @client = if api_token && !api_token.empty?
    Aws::BedrockRuntime::Client.new(
      region: region,
      token_provider: Aws::StaticTokenProvider.new(api_token),
      auth_scheme_preference: ["httpBearerAuth"],
      **options
    )
  else
    Aws::BedrockRuntime::Client.new(region: region, **options)
  end
end