Class: Riffer::Providers::AmazonBedrock

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

Overview

Amazon Bedrock provider for Claude and other foundation models. Requires the aws-sdk-bedrockruntime gem.

Constant Summary collapse

ANTHROPIC_MODEL_PATTERN =

Matches Anthropic models on Bedrock — bare (anthropic.claude-...) and cross-region (us.anthropic.claude-...) ids.

/(?:^|\.)anthropic\./

Constants inherited from Base

Base::WIRE_SEPARATOR

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#generate_text, #stream_text

Constructor Details

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

– : (?api_token: String?, ?region: String?, **untyped) -> void



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/riffer/providers/amazon_bedrock.rb', line 24

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

Class Method Details

.skills_adapter(model = nil) ⇒ Object

Returns the skill adapter for the Bedrock model — XML for Anthropic models (which Bedrock hosts alongside other vendors’), else Markdown. – : (?String?) -> singleton(Riffer::Skills::Adapter)



17
18
19
20
# File 'lib/riffer/providers/amazon_bedrock.rb', line 17

def self.skills_adapter(model = nil)
  return Riffer::Skills::XmlAdapter if model && ANTHROPIC_MODEL_PATTERN.match?(model)
  Riffer::Skills::MarkdownAdapter
end